数据库建立表间关联有什么作用

来源:百度知道 编辑:UC知道 时间:2024/06/13 22:50:24

就是在表与表之间建立起链接就行了,这个链接就叫做外键—FC;列入:create table stu(stuid int,sName varchar2(20));
create table score(stid int,cid int);
alter table stu add constraint pk_stuid primary key(stuid);
alter table score add constraint fk_stuid foreign key(stid) references stu(stuid); stuid这个属性就是foreign key就是外键;他就是链接stu表和score表的桥梁。

建立关联后才能在查询时等到全面的信息。因为避免数据冗余,一张表不能包含所有信息

参照完整性

http://topic.csdn.net/t/20031021/09/2377617.html
http://zhidao.baidu.com/question/53146008.html

可以建立一对一关系,一对多关系,多对多关系。建了外键的话。可以找在其他表中的相关信息都找出来了。

实现多表查询!