データベースにテーブルを作成していますが、テーブル間のリレーションを作成しようとすると、クエリで奇妙な問題が発生します。
これが私の質問です:
CREATE TABLE ogrnizationarticle (
OAID Int NOT NULL ,
_Text VARCHAR(255) NOT NULL ,
ARank Int NULL DEFAULT NULL ,
Acomment VARCHAR(255) NULL DEFAULT NULL ,
Author VARCHAR(45) NULL DEFAULT NULL ,
PRIMARY KEY (OAID, _Text) ,
foreign key (OAID) references organization(OID),
);
-- -----------------------------------------------------
-- Table nasshope.organization_Article_comment
-- -----------------------------------------------------
CREATE TABLE organizationArticleComment (
O_Article_ID Int NOT NULL ,
Comment VARCHAR(255) NOT NULL ,
Article VARCHAR(255) NOT NULL ,
Comment_Like Int NULL DEFAULT NULL ,
_Date DATETIME NULL DEFAULT NULL ,
PRIMARY KEY (O_Article_ID, Comment, Article) ,
foreign key (O_Article_ID) references ogrnizationarticle(OAID),
);
そしてここにエラーがあります
Msg 1776, Level 16, State 0, Line 13
There are no primary or candidate keys in the referenced table 'ogrnizationarticle' that match the referencing column list in the foreign key 'FK__organizat__O_Art__42ACE4D4'.
Msg 1750, Level 16, State 0, Line 13
Could not create constraint. See previous errors.