mysql 如何判断一个表是主表还是从表

来源:百度知道 编辑:UC知道 时间:2024/06/05 06:37:03
希望懂得帮帮忙,谢了。
现在数据库里只有三个表,这三个表就如同student,sc,course。存在着主从关系,切忌你只知道这三个表的表名和数据库名,其他的如字段什么的,你都不知道,然后让你找出它们之间的主从关系,那个从表的外键和哪个主表的主键相连,仅此而已,这个我已解决。

--books表中有字段有bId,pId等字段。
--another有bId,pId等字段(create table another select bId,pid,bAuthor from books;--相关字段以及内容来自books表)。
--books和publising建立外键,参照publishing中的id字段。
alter table books add constraint FK_books_publishing foreign key (pid) references publishing (id) on update cascade;
--another和publishing之间创建外键,参照publishing中的id字段。
alter table another add constraint FK_another_publishing foreign key (pId) references publishing (id) on update cascade;
--举个简单的更新列子:
update publishing set id = 17,pname = '爱好者' where id='14';
--当执行这条语句时(更新publishing表),books表和another表同时进行更新。
--主表更新字段数据等,副表也随之更新,从上面可以看出,主表是publishing,副表是books和another。

--希望能帮到你

现在不知道,如何判断你说的主表和从表是什么意思?

这个问题太深奥,最好有个E-R,问问当事建表的人

此话怎讲?。。。。。。。。。。。。。