Welcome Guest, Not a member yet? Register   Sign In
I need help with relationships between parent category and child category on a innodb engine.
#5

[eluser]InsiteFX[/eluser]
Code:
-- --------------------------------------------------------

--
-- Table structure for table `categories`
--

CREATE TABLE IF NOT EXISTS `categories` (
  `id`        int(11)            NOT NULL auto_increment,
  `name`    varchar(255)        NOT NULL default '',
  `short_desc`    varchar(255)        NOT NULL default '',
  `long_desc`    text            NOT NULL,
  `status`    enum('active', 'inactive') NOT NULL default 'active',
  `sort_order`    int(3)            NOT NULL default '0',
  `parent_id`    int(11)            NOT NULL default '0',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ;

--
-- Dumping data for table `categories`
--

INSERT INTO `categories` VALUES (1, 'Cat-1', '', '', 'active', 0, 0);
INSERT INTO `categories` VALUES (2, 'Cat-2', '', '', 'active', 0, 0);
INSERT INTO `categories` VALUES (3, 'Cat-3', '', '', 'active', 0, 0);

-- Next comes the posts table:
-- --------------------------------------------------------

--
-- Table structure for table `posts`
--

CREATE TABLE IF NOT EXISTS `posts` (
  `id`        int(11)               NOT NULL auto_increment,
  `title`    varchar(255)           NOT NULL,
  `tags`    varchar(255)           NOT NULL,
  `status`    enum('draft', 'published') NOT NULL,
  `body`    text               NOT NULL,
  `category_id`    int(11)               NOT NULL,
  `pub_date`    datetime           NOT NULL,
  `user_id`    int(11)               NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ;

--
-- Dumping data for table `posts`
--

INSERT INTO `posts` VALUES (1, 'Home', 'home', 'published', 'This is just a test of the home page.\n\nThanks for your patience.', 3, '2008-07-13 15:23:26', 1);
INSERT INTO `posts` VALUES (1, 'Testing', 'test', 'published', 'This is just a test.\n\nThanks for your patience.', 3, '2008-07-13 15:23:26', 1);
INSERT INTO `posts` VALUES (2, 'Another test', 'test', 'published', 'Another test.\r\n\r\nWho knew this could be such fun?', 2, '2008-07-13 15:23:26', 1);
INSERT INTO `posts` VALUES (3, 'Just Another Test, part 3', 'testing testing', 'published', 'just another test!', 1, '2008-07-13 15:58:52', 1);

-- Next, the comments table:
-- --------------------------------------------------------

--
-- Table structure for table `comments`
--

CREATE TABLE IF NOT EXISTS `comments` (
  `id`        int(11)        NOT NULL auto_increment,
  `name`    varchar(255)    NOT NULL,
  `email`    varchar(255)    NOT NULL,
  `body`    varchar(255)    NOT NULL,
  `post_id`    int(11)        NOT NULL,
  `pub_date`    datetime    NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ;

--
-- Dumping data for table `comments`
--

INSERT INTO `comments` VALUES (1, 'InsiteFX', '[email protected]', 'This is a comment.', 1, '2010-03-13 15:26:05');

Enjkoy
InsiteFX


Messages In This Thread
I need help with relationships between parent category and child category on a innodb engine. - by El Forum - 03-30-2010, 09:30 PM



Theme © iAndrew 2016 - Forum software by © MyBB