All pastes #583811 Raw Edit

k4st

public text v1 · immutable
·published 2007-06-22 14:59 UTC
rendered paste body
/* 
			categories            forums                topics
			----------            ------                ------
			category_id <--.      forum_id <----.       topic_id
			name            `---> category_id <-.`----> forum_id
			                 `-------------------`----> category_id
			
			
			
			post                  post_tags             tags
			----                  ---------             ----
			post_id <-----------> post_id        .----> tag_id
			name                  tag_id <------^       name
		*/
		
		/*
		
		CREATE TABLE posts (
			post_id int(10) auto_increment,
			name varchar(255),
			primary key(post_id)
		);
		
		CREATE TABLE post_tags (
			post_id int(10),
			tag_id int(10)
		);
		
		CREATE TABLE tags (
			tag_id int(10) auto_increment,
			name varchar(30),
			primary key(tag_id)
		);
		
		INSERT INTO posts (post_id,name) VALUES (1,'first'), (2,'second'),(3,'third');
		INSERT INTO post_tags (post_id,tag_id) VALUES (1,1),(1,2),(2,1);
		INSERT INTO tags (tag_id,name) VALUES (1,'tag1'),(2,'tag2');
		
		*/