Welcome Guest, Not a member yet? Register   Sign In
Khaos :: KhACL
#50

[eluser]adamp1[/eluser]
I have a change I think which would be better. Basically it upgrades the database scheme. I have used InnoDB tables instead due to the ability to have foreign keys. I have also looked at your code which you used to perform the selects and added more INDEX's and UNQIUE INDEX's to speed up the fetching of data.

Code:
--
-- Table structure for table `khacl_axos`
--

CREATE TABLE IF NOT EXISTS `khacl_axos` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `name` varchar(254) NOT NULL,
  PRIMARY KEY  (`id`),
  UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

--
-- Table structure for table `khacl_aros`
--

CREATE TABLE IF NOT EXISTS `khacl_aros` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `lft` int(10) unsigned NOT NULL default '0',
  `rgt` int(10) unsigned NOT NULL default '0',
  `name` varchar(254) NOT NULL,
  `link` int(10) unsigned default NULL,
  PRIMARY KEY  (`id`),
  UNIQUE KEY `name` (`name`),
  KEY `lft` (`lft`),
  KEY `rgt` (`rgt`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

--
-- Table structure for table `khacl_access`
--

CREATE TABLE IF NOT EXISTS `khacl_access` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `aro_id` int(10) unsigned NOT NULL default '0',
  `aco_id` int(10) unsigned NOT NULL default '0',
  `allow` char(1) default NULL,
  PRIMARY KEY  (`id`),
  KEY `aro_id` (`aro_id`),
  KEY `aco_id` (`aco_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

--
-- Table structure for table `khacl_access_actions`
--

CREATE TABLE IF NOT EXISTS `khacl_access_actions` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `access_id` int(10) unsigned NOT NULL default '0',
  `axo_id` int(10) unsigned NOT NULL default '0',
  `allow` char(1) default NULL,
  PRIMARY KEY  (`id`),
  KEY `access_id` (`access_id`),
  KEY `axo_id` (`axo_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

--
-- Table structure for table `khacl_acos`
--

CREATE TABLE IF NOT EXISTS `khacl_acos` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `lft` int(10) unsigned NOT NULL default '0',
  `rgt` int(10) unsigned NOT NULL default '0',
  `name` varchar(254) NOT NULL,
  `link` int(10) unsigned default NULL,
  PRIMARY KEY  (`id`),
  UNIQUE KEY `name` (`name`),
  KEY `lft` (`lft`),
  KEY `rgt` (`rgt`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Constraints for dumped tables
--

--
-- Constraints for table `khacl_access`
--
ALTER TABLE `khacl_access`
  ADD CONSTRAINT `khacl_access_ibfk_2` FOREIGN KEY (`aco_id`) REFERENCES `khacl_acos` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `khacl_access_ibfk_1` FOREIGN KEY (`aro_id`) REFERENCES `khacl_aros` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `khacl_access_actions`
--
ALTER TABLE `khacl_access_actions`
  ADD CONSTRAINT `khacl_access_actions_ibfk_2` FOREIGN KEY (`axo_id`) REFERENCES `khacl_axos` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `khacl_access_actions_ibfk_1` FOREIGN KEY (`access_id`) REFERENCES `khacl_access` (`id`) ON DELETE CASCADE;

Another thing I have done is changed the varchar lengths from 255 to 254 since some server software doesn't support 255 chars, I suppose I just do it to try and make my database design as easy for someone to use elsewhere.

I don't know if using the InnoDB would be hugely slower, but since when you do a check() you pull all the records and loop through iteratively I don't think it will be too much slower.

EDIT: One more thing, using InnoDB tables will also mean that some of the DELETE queries can be removed, making the library simpler, and of course can use transactions.


Messages In This Thread
Khaos :: KhACL - by El Forum - 01-29-2008, 10:49 AM
Khaos :: KhACL - by El Forum - 01-29-2008, 11:42 AM
Khaos :: KhACL - by El Forum - 01-29-2008, 12:35 PM
Khaos :: KhACL - by El Forum - 01-30-2008, 07:10 AM
Khaos :: KhACL - by El Forum - 01-30-2008, 05:11 PM
Khaos :: KhACL - by El Forum - 01-30-2008, 08:17 PM
Khaos :: KhACL - by El Forum - 01-31-2008, 03:49 AM
Khaos :: KhACL - by El Forum - 01-31-2008, 09:14 AM
Khaos :: KhACL - by El Forum - 01-31-2008, 10:03 AM
Khaos :: KhACL - by El Forum - 01-31-2008, 10:33 AM
Khaos :: KhACL - by El Forum - 01-31-2008, 10:39 AM
Khaos :: KhACL - by El Forum - 01-31-2008, 10:50 AM
Khaos :: KhACL - by El Forum - 01-31-2008, 03:14 PM
Khaos :: KhACL - by El Forum - 02-03-2008, 11:00 AM
Khaos :: KhACL - by El Forum - 02-03-2008, 01:35 PM
Khaos :: KhACL - by El Forum - 02-04-2008, 12:22 PM
Khaos :: KhACL - by El Forum - 02-05-2008, 03:45 AM
Khaos :: KhACL - by El Forum - 02-25-2008, 12:42 PM
Khaos :: KhACL - by El Forum - 02-25-2008, 01:16 PM
Khaos :: KhACL - by El Forum - 02-25-2008, 02:53 PM
Khaos :: KhACL - by El Forum - 02-25-2008, 02:59 PM
Khaos :: KhACL - by El Forum - 02-25-2008, 03:55 PM
Khaos :: KhACL - by El Forum - 02-25-2008, 04:03 PM
Khaos :: KhACL - by El Forum - 02-29-2008, 09:56 AM
Khaos :: KhACL - by El Forum - 03-02-2008, 06:23 AM
Khaos :: KhACL - by El Forum - 03-02-2008, 07:03 AM
Khaos :: KhACL - by El Forum - 03-02-2008, 07:28 AM
Khaos :: KhACL - by El Forum - 03-02-2008, 07:34 AM
Khaos :: KhACL - by El Forum - 03-02-2008, 07:44 AM
Khaos :: KhACL - by El Forum - 03-02-2008, 08:05 AM
Khaos :: KhACL - by El Forum - 03-02-2008, 08:20 AM
Khaos :: KhACL - by El Forum - 03-02-2008, 09:06 AM
Khaos :: KhACL - by El Forum - 03-02-2008, 09:12 AM
Khaos :: KhACL - by El Forum - 03-02-2008, 09:19 AM
Khaos :: KhACL - by El Forum - 03-02-2008, 09:26 AM
Khaos :: KhACL - by El Forum - 03-02-2008, 09:46 AM
Khaos :: KhACL - by El Forum - 03-02-2008, 10:47 AM
Khaos :: KhACL - by El Forum - 03-08-2008, 05:37 PM
Khaos :: KhACL - by El Forum - 03-09-2008, 10:22 AM
Khaos :: KhACL - by El Forum - 03-09-2008, 10:24 AM
Khaos :: KhACL - by El Forum - 03-09-2008, 12:21 PM
Khaos :: KhACL - by El Forum - 03-20-2008, 05:25 AM
Khaos :: KhACL - by El Forum - 03-20-2008, 06:14 AM
Khaos :: KhACL - by El Forum - 03-20-2008, 07:08 AM
Khaos :: KhACL - by El Forum - 03-20-2008, 07:42 AM
Khaos :: KhACL - by El Forum - 03-20-2008, 11:31 AM
Khaos :: KhACL - by El Forum - 03-20-2008, 11:40 AM
Khaos :: KhACL - by El Forum - 03-21-2008, 05:16 AM
Khaos :: KhACL - by El Forum - 03-21-2008, 05:25 AM
Khaos :: KhACL - by El Forum - 03-21-2008, 07:54 AM
Khaos :: KhACL - by El Forum - 03-21-2008, 08:31 AM
Khaos :: KhACL - by El Forum - 03-21-2008, 12:35 PM
Khaos :: KhACL - by El Forum - 03-21-2008, 12:38 PM
Khaos :: KhACL - by El Forum - 03-21-2008, 01:28 PM
Khaos :: KhACL - by El Forum - 03-21-2008, 01:33 PM
Khaos :: KhACL - by El Forum - 03-21-2008, 03:18 PM
Khaos :: KhACL - by El Forum - 03-21-2008, 06:37 PM
Khaos :: KhACL - by El Forum - 03-26-2008, 05:13 AM
Khaos :: KhACL - by El Forum - 03-28-2008, 02:16 AM
Khaos :: KhACL - by El Forum - 03-30-2008, 02:17 AM
Khaos :: KhACL - by El Forum - 03-30-2008, 04:07 AM
Khaos :: KhACL - by El Forum - 03-30-2008, 04:26 AM
Khaos :: KhACL - by El Forum - 03-30-2008, 05:32 AM
Khaos :: KhACL - by El Forum - 03-30-2008, 06:28 AM
Khaos :: KhACL - by El Forum - 03-30-2008, 09:36 AM
Khaos :: KhACL - by El Forum - 03-30-2008, 10:23 AM
Khaos :: KhACL - by El Forum - 03-30-2008, 10:25 PM
Khaos :: KhACL - by El Forum - 03-31-2008, 02:59 AM
Khaos :: KhACL - by El Forum - 03-31-2008, 03:20 AM
Khaos :: KhACL - by El Forum - 03-31-2008, 06:43 AM
Khaos :: KhACL - by El Forum - 04-11-2008, 11:33 AM
Khaos :: KhACL - by El Forum - 04-11-2008, 11:48 AM
Khaos :: KhACL - by El Forum - 04-12-2008, 02:17 AM
Khaos :: KhACL - by El Forum - 04-14-2008, 02:32 AM
Khaos :: KhACL - by El Forum - 04-14-2008, 11:11 AM
Khaos :: KhACL - by El Forum - 05-02-2008, 01:04 AM
Khaos :: KhACL - by El Forum - 05-02-2008, 02:05 AM
Khaos :: KhACL - by El Forum - 05-19-2008, 05:01 PM
Khaos :: KhACL - by El Forum - 05-19-2008, 05:31 PM
Khaos :: KhACL - by El Forum - 05-19-2008, 05:40 PM
Khaos :: KhACL - by El Forum - 06-09-2008, 10:26 AM
Khaos :: KhACL - by El Forum - 06-17-2008, 02:31 PM
Khaos :: KhACL - by El Forum - 06-17-2008, 02:33 PM
Khaos :: KhACL - by El Forum - 06-25-2008, 09:43 AM
Khaos :: KhACL - by El Forum - 06-25-2008, 09:44 AM
Khaos :: KhACL - by El Forum - 06-26-2008, 06:54 AM
Khaos :: KhACL - by El Forum - 07-24-2008, 11:29 PM
Khaos :: KhACL - by El Forum - 07-27-2008, 06:06 PM
Khaos :: KhACL - by El Forum - 09-09-2008, 03:51 PM
Khaos :: KhACL - by El Forum - 05-06-2009, 03:18 AM
Khaos :: KhACL - by El Forum - 06-16-2009, 03:35 AM
Khaos :: KhACL - by El Forum - 07-24-2009, 12:48 AM
Khaos :: KhACL - by El Forum - 11-02-2010, 06:18 AM



Theme © iAndrew 2016 - Forum software by © MyBB