代码改变世界

MySQL-ER图

2018-05-08 15:51  yelena  阅读(767)  评论(0编辑  收藏  举报

CREATE TABLE keshi(
           kname VARCHAR(5) PRIMARY KEY,
           address VARCHAR(5),
           tele INT,
           dname VARCHAR(10)

)
DESC keshi;
CREATE TABLE bingfang(
           bid INT PRIMARY KEY,
           chuangwei INT,
           kname VARCHAR(5),
           CONSTRAINT bingfang_keshi_fk
           FOREIGN KEY (kname) REFERENCES
           keshi(kname)
           
)
DESC bingfang;
CREATE TABLE yisheng(
           dname VARCHAR(5) PRIMARY KEY,
           zhicheng VARCHAR(10),
           kname VARCHAR(5),
           age INT,
           gongzuozhenghao INT,
           CONSTRAINT yisheng_keshi_fk
           FOREIGN KEY (kname) REFERENCES
           keshi(kname)
)
DESC yisheng;
CREATE TABLE bingren(
          bingli INT,
          rname VARCHAR(5),
          sex VARCHAR(2),
          zhenduan VARCHAR(20),
          dname VARCHAR(5),
          bid INT,
          CONSTRAINT bingren_yisheng_fk
          FOREIGN KEY (dname) REFERENCES
          yisheng(dname)
)
DESC bingren;