-- phpMyAdmin SQL Dump
-- version 3.1.2
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Jul 10, 2009 at 09:56 AM
-- Server version: 5.0.51
-- PHP Version: 5.2.9

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";

--
-- Database: `zfblog`
--

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

--
-- Table structure for table `article`
--

CREATE TABLE IF NOT EXISTS `article` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `author_id` int(10) unsigned default NULL,
  `title` varchar(100) NOT NULL default '',
  `posted` datetime NOT NULL default '0000-00-00 00:00:00',
  `titleURL` varchar(100) character set ascii NOT NULL default '',
  `text` text NOT NULL,
  `plainText` text NOT NULL,
  `format` enum('html','wiki') character set latin1 collate latin1_general_ci NOT NULL,
  `viewCount` int(10) unsigned NOT NULL default '0',
  PRIMARY KEY  (`id`),
  UNIQUE KEY `titleURL` (`titleURL`),
  KEY `author_id` (`author_id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin2 AUTO_INCREMENT=72 ;

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

--
-- Table structure for table `articlerating`
--

CREATE TABLE IF NOT EXISTS `articlerating` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `article_id` int(10) unsigned NOT NULL default '0',
  `ipAddr` varchar(16) NOT NULL default '',
  `votingDateTime` datetime NOT NULL default '0000-00-00 00:00:00',
  `rating` int(10) unsigned NOT NULL default '0',
  PRIMARY KEY  (`id`),
  KEY `article_id` (`article_id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin2 AUTO_INCREMENT=318 ;

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

--
-- Table structure for table `author`
--

CREATE TABLE IF NOT EXISTS `author` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `username` varchar(100) NOT NULL default '',
  `email` varchar(50) character set ascii NOT NULL default '',
  PRIMARY KEY  (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin2 AUTO_INCREMENT=4 ;

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

--
-- Table structure for table `category`
--

CREATE TABLE IF NOT EXISTS `category` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `name` varchar(100) NOT NULL default '',
  `titleURL` varchar(100) character set ascii NOT NULL default '',
  PRIMARY KEY  (`id`),
  UNIQUE KEY `name` (`name`,`titleURL`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin2 AUTO_INCREMENT=8 ;

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

--
-- Table structure for table `categoryarticle`
--

CREATE TABLE IF NOT EXISTS `categoryarticle` (
  `article_id` int(10) unsigned NOT NULL default '0',
  `category_id` int(10) unsigned NOT NULL default '0',
  PRIMARY KEY  (`article_id`,`category_id`),
  KEY `category_id` (`category_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin2;

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

--
-- Table structure for table `comment`
--

CREATE TABLE IF NOT EXISTS `comment` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `article_id` int(10) unsigned NOT NULL default '0',
  `message` text NOT NULL,
  `name` varchar(50) NOT NULL default '',
  `email` varchar(100) NOT NULL default '',
  `www` varchar(200) character set latin1 collate latin1_german2_ci default NULL,
  `posted` datetime NOT NULL default '0000-00-00 00:00:00',
  PRIMARY KEY  (`id`),
  KEY `article_id` (`article_id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin2 AUTO_INCREMENT=177 ;

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

--
-- Table structure for table `trackback`
--

CREATE TABLE IF NOT EXISTS `trackback` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `article_id` int(10) unsigned NOT NULL,
  `posted` datetime NOT NULL,
  `title` varchar(50) default NULL,
  `excerpt` varchar(200) default NULL,
  `url` varchar(500) NOT NULL,
  `blogName` varchar(100) default NULL,
  `isSpam` tinyint(1) NOT NULL default '1',
  `ipAddr` varchar(20) character set ascii NOT NULL,
  PRIMARY KEY  (`id`),
  KEY `article_id` (`article_id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin2 AUTO_INCREMENT=2021 ;

--
-- Constraints for dumped tables
--

--
-- Constraints for table `article`
--
ALTER TABLE `article`
  ADD CONSTRAINT `article_ibfk_1` FOREIGN KEY (`author_id`) REFERENCES `author` (`id`) ON DELETE SET NULL ON UPDATE CASCADE;

--
-- Constraints for table `articlerating`
--
ALTER TABLE `articlerating`
  ADD CONSTRAINT `articlerating_ibfk_1` FOREIGN KEY (`article_id`) REFERENCES `article` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `categoryarticle`
--
ALTER TABLE `categoryarticle`
  ADD CONSTRAINT `categoryarticle_ibfk_1` FOREIGN KEY (`article_id`) REFERENCES `article` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `categoryarticle_ibfk_2` FOREIGN KEY (`category_id`) REFERENCES `category` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `comment`
--
ALTER TABLE `comment`
  ADD CONSTRAINT `comment_ibfk_1` FOREIGN KEY (`article_id`) REFERENCES `article` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `trackback`
--
ALTER TABLE `trackback`
  ADD CONSTRAINT `trackback_ibfk_1` FOREIGN KEY (`article_id`) REFERENCES `article` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
