在第一次遇到很多虐待之后,我问了这个问题,我已经冷静下来,我正在再次尝试并尝试更具体。
我为 Uni 完成了一项作业,以下是其中一个问题的提示:
Write Create Table SQL statements for the relational schema that you have created
Place the text in the specified location in the file: ASS1_SQL.TXT
• All tables must have primary keys.
• All tables must have appropriate foreign key constraints.
• Each foreign key column must have identical column name, datatype and size of the primary key
that it refers to
• Add any NOT NULL constraints as dictated by the ERD
• The following columns data types and sizes must be used
suppid, stkid number(2)
suppname, stkname varchar2(30)
sellprice, purchaseprice number(6,2)
我对此的回应是:
CREATE Table SUPPLIER(
suppid Number(2) NOT NULL,
suppname varchar2(30),
stkid Number(2) NOT NULL,
citycode Number(2) NOT NULL,
Primary Key (suppid),
Foreign Key (citycode) references CITY
)
CREATE Table STOCKITEM(
stkid Number(2) NOT NULL,
stkname varchar2(30) ,
sellprice Number(6,2) ,
purchaseprice Number(6,2) ,
suppid Number(2) ,
Primary Key (stkid) ,
whid Number(2) NOT NULL,
suppid Number(2) Foreign Key references SUPPLIER ,
whid Number(4) Foreign Key references WAREHOUSE
)
在您说我指向我尚未创建的表(并将我的问题标记下来)之前,请注意我已经在使用的数据库中创建了WAREHOUSE
和表。CITY
此代码有效并创建表。但是,我得到了 0 分(满分 10 分),没有任何解释。上面的代码比最初略有改进,因为(我相信)我已经修复了 NOT NULL 属性。
Do my NOT NULL and FOREIGN KEY Constraints seem to have the right syntax?
ERD 可在https://www.dropbox.com/sh/eohlj5h073kwp4u/Ot08kbdY7Q的 pdf 文件中找到
在否决这个问题之前,请先咨询我,我可以调整它。我是这个网站的新手,所以请给我一个机会