在被引用表 'times' 中没有与外键 'FK__states__fTime__1B0907CE' 中的引用列列表匹配的主键或候选键.
createtablefood(fIDchar(5)primarykey,fNamechar(20),fTypesmallint,check(fTypein(-1,0,1...
create table food(
fID char(5) primary key,
fName char(20),
fType smallint, check(fType in (-1, 0, 1, 2)),
fPrice float, check(fPrice > 0),
fHave bit default 1,
fImage image,
)
select * from food
create table desk(
dId char(5) primary key,
dState smallint check(dState in (-1, 1, 0)) default 0,
)
select * from desk
create table times(
fTime date,
dId char(5),
checkoutTime date,
primary key(fTime, dId),
foreign key(dId) references desk(dId)
)
select * from times
create table states(
fTime date,
fId char(5),
dId char(5),
fNum smallint check(fNum >= 0),
backState smallint check(backState in (-1, 0, 1)),
primary key(fTime, fId, dId),
foreign key(fTime) references times(fTime),
上面times出错
foreign key(fId) references food(fId),
foreign key(dId) references desk(dId)
) 展开
fID char(5) primary key,
fName char(20),
fType smallint, check(fType in (-1, 0, 1, 2)),
fPrice float, check(fPrice > 0),
fHave bit default 1,
fImage image,
)
select * from food
create table desk(
dId char(5) primary key,
dState smallint check(dState in (-1, 1, 0)) default 0,
)
select * from desk
create table times(
fTime date,
dId char(5),
checkoutTime date,
primary key(fTime, dId),
foreign key(dId) references desk(dId)
)
select * from times
create table states(
fTime date,
fId char(5),
dId char(5),
fNum smallint check(fNum >= 0),
backState smallint check(backState in (-1, 0, 1)),
primary key(fTime, fId, dId),
foreign key(fTime) references times(fTime),
上面times出错
foreign key(fId) references food(fId),
foreign key(dId) references desk(dId)
) 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询