如何理解Sql语言中ANY的用法
2个回答
展开全部
这样写的意思应该是本表的Cpno是外键,参照本表的Cno主键。这样建立的不是两个表外键关系,而是同一个表。我觉得这样S、T和C之间的实体关系有些乱。理顺course.student和teacher之间的关系是正确添加外键的关键。如何添加表的外键关系,请看如下实例:
CREATE DATABASE CLOTH_INFO
CREATE TABLE User_info
(
id INT(4) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (id)(主键)
)
CREATE TABLE cloth_info(
id_number INT(4) NOT NULL AUTO_INCREMENT,
PRIMARY KEY(id_number)(主键)
)
CREATE TABLE cloth_sale_info(
id_number INT(4) NOT NULL,
cloth_id INT(4) REFERENCES cloth_info(id_number),(外键)
user_id INT(4) REFERENCES User_info(id)(外键)
)
CREATE TABLE cloth_store_info(
id_number INT(4) NOT NULL ,
cloth_id INT(4) REFERENCES cloth_info(id_number)(外键)
)
CREATE DATABASE CLOTH_INFO
CREATE TABLE User_info
(
id INT(4) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (id)(主键)
)
CREATE TABLE cloth_info(
id_number INT(4) NOT NULL AUTO_INCREMENT,
PRIMARY KEY(id_number)(主键)
)
CREATE TABLE cloth_sale_info(
id_number INT(4) NOT NULL,
cloth_id INT(4) REFERENCES cloth_info(id_number),(外键)
user_id INT(4) REFERENCES User_info(id)(外键)
)
CREATE TABLE cloth_store_info(
id_number INT(4) NOT NULL ,
cloth_id INT(4) REFERENCES cloth_info(id_number)(外键)
)
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询