Todas las tablas del ejemplo Blog

CREATE TABLE posts (
    id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    title VARCHAR(50),
    body TEXT,
    created DATETIME DEFAULT NULL,
    modified DATETIME DEFAULT NULL
);

/* Then insert some posts for testing: */
INSERT INTO posts (title, body, created)
    VALUES ('The title', 'This is the post body.', NOW());
INSERT INTO posts (title, body, created)
    VALUES ('A title once again', 'And the post body follows.', NOW());
INSERT INTO posts (title, body, created)
    VALUES ('Title strikes back', 'This is really exciting! Not.', NOW());
CREATE TABLE comments ( id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, subject VARCHAR(50), body VARCHAR(1500), post_id int, created DATETIME DEFAULT NULL, modified DATETIME DEFAULT NULL ); /* algunos valores de test */ INSERT INTO comments (subject,body,post_id,created) VALUES ('Good','Good article',1, NOW()); INSERT INTO comments (subject,body,post_id,created) VALUES ('What?','I don\'t understand',2, NOW()); INSERT INTO comments (subject,body,post_id,created) VALUES ('ola','ola k ase??',3, NOW());

CREATE TABLE themes (
 id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
 title VARCHAR(50),
 created DATETIME DEFAULT NULL,
 modified DATETIME DEFAULT NULL
);


/* algunos valores de test */
INSERT INTO themes (title,created)
 VALUES ('MVC', NOW());
INSERT INTO themes (title,created)
 VALUES ('cakePHP', NOW());
INSERT INTO themes (title,created)
 VALUES ('Depression', NOW());
CREATE TABLE tags (
 id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
 tag VARCHAR(50),
 created DATETIME DEFAULT NULL,
 modified DATETIME DEFAULT NULL
);


/* algunos valores de test */
INSERT INTO tags (tag,created)
 VALUES ('MVC', NOW());
INSERT INTO tags (tag,created)
 VALUES ('CakePHP', NOW());
INSERT INTO tags (tag,created)
 VALUES ('JS', NOW());

CREATE TABLE posts_tags (
 id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
 post_id INT,
 tag_id INT
);