此列列表没有匹配的唯一键或主键。我不确定如何为我的案子解决

no matching unique or primary key for this column-list. Im not sure how to solve it for my case

我一直在尝试在我的数据库中创建这个 table。我们被告知使用 Oracle-Apex 来创建数据库。所以我不断收到无法解决的错误:

如果我删除代码的最后一行,它会创建 table 正常且没有任何错误。 以下是此处引用的其他 table 的屏幕截图:

公司Table

分支机构Table

IDK 如果这是菜鸟的错误,我只花了大约一个小时就学会了 apex/sql 然后就去制作数据库了。感谢你们对我的帮助! :)

外键引用的列在源 table 中必须具有唯一索引(或者它们必须是 table 的主键)。您的代码由于以下外键声明而失败,其中目标不是唯一的:

foreign key (BranchNo) references Branch(BranchNo)

在这里,我认为您需要一个引用 Branch 主键的复合外键,而不是两个不同的键。 Branch(CCode) 已经引用了 Company(CCode),因此没有必要将该关系放入 Equipment table.

create table Equipment(
    CCode int,
    BranchNo int,
    EquipNo it,
    Description varchar2(50),
    NumberOfEquip int,
    primary key(CCode, BranchNo, EquipNo),
    foreign key (CCode, BranchNo) references Branch(CCode, BranchNo)
);