top of page

Урок 3

  • Рома
  • 31 мая 2015 г.
  • 1 мин. чтения

create table users ( id_user int(10) AUTO_INCREMENT, name varchar(20) NOT NULL, email varchar(50) NOT NULL, password varchar(15) NOT NULL, PRIMARY KEY (id_user) ); create table topics ( id_topic int(10) AUTO_INCREMENT, topic_name varchar(100) NOT NULL, id_author int(10) NOT NULL, PRIMARY KEY (id_topic), FOREIGN KEY (id_author) REFERENCES users (id_user) ); create table posts ( id_post int(10) AUTO_INCREMENT, message text NOT NULL, id_author int(10) NOT NULL, id_topic int(10) NOT NULL, PRIMARY KEY (id_post), FOREIGN KEY (id_author) REFERENCES users (id_user), FOREIGN KEY (id_topic) REFERENCES topics (id_topic) ); INSERT INTO users VALUES ('1', 'Кирилл', 'kirill@mail.ru', '1111'); INSERT INTO users (name, email, password) VALUES ('Вася', 'vasy@rambler.ru', '2222'), ('Семен', 'semen@yandex.ru', '3333'), ('Вася', 'vasy@mail.ru', '4444'); INSERT INTO topics (topic_name, id_author) VALUES ('О рыбалке', '1'), ('Велосипеды', '2'), ('Ночные клубы', '3'), ('К кому обратиться', '4'); INSERT INTO posts (message, id_author, id_topic) VALUES ('Думаю надо сделать так', '1', '1'), ('Согласен', '2','4'), ('А еще можно сделать так', '3', '1'), ('Согласен', '2', '1');

 
 
 

留言


© 2015 Все права защищены

bottom of page