可以的,写段代码给你看
--创建主表userinfos,userid是这个表的主键
create table userinfos(userid int primary key not null, username varchar(20) not null);
--创建表scores,scid是这个scores表的主键
create table scores(scid int primary key not null, useridsc int not null,score int not null);
--建立主外键约束,使得成绩表里的useridsc这个列存放的学生编号,必须是userinfos表的userid列的值,也就是说,不允许还没有这个学生,就有了这个学生的成绩
alter table scores add constraint FK_scores_userinfos foreign key (useridsc) references userinfos(userid);
希望你能看懂