我想请一些帮助。
我创建了三个表,如下所示,一个TRACK,一个COMPOSER和一个ARTIST,我想创建一个约束,阻止插入已经是艺术家的作曲家,反之亦然。
因此,我想创建一个触发器,当我插入一个已经在艺术家中的新作曲家时显示错误消息,如果我插入作曲家中的艺术家则显示相同的内容。
我希望我很清楚。请帮帮我
create table track (
title varchar (255),
number integer,
duration interval,
primary key (title, number)
foreign key (title) references band (title)
);
create table composer (
title varchar (255),
number integer,
name varchar (255),
primary key (title, number, name)
foreign key (title, number) track references (title, number)
foreign key (name) references person (name)
);
create table artist (
title varchar (255),
number integer,
name varchar (255),
primary key (title, number, name)
foreign key (title, number) track references (title, number)
foreign key (name) references person (name)
);