Database Design(資料庫設計)(視訊下載) (全部書籍)
馬克-to-win:
(一對多:one-to-many)
1) teacher and student.
(teacher表:兩列id(主鍵),name。
pupil表: 三列:id(主鍵),name,tid(外來鍵))
舉例: Teacher “qixy” has two students: liyaohua,fuwenlong. Teacher “huanglaosh” has two students: mashuai,jiaxiaohu.
create table pupil(id int not null,name char(10),tid int);
create table teacher(id int not null,name char(10));
INSERT INTO pupil (id,name,tid) VALUES(1,`liyaohua`,1);
INSERT INTO pupil (id,name,tid) VALUES(2,`fuwenlong`,1);
INSERT INTO pupil (id,name,tid) VALUES(3,`mashuai`,2);
INSERT INTO pupil (id,name,tid) VALUES(4,`jiaxiaohu`,2);