开发者

Referential integrity

I开发者_JS百科 have the following structure,

USERS (id_user (PK));

USERS_PROJECTS (id_user (FK), id_project (FK));

PROJECTS (id_project (PK), id_owner);

This structure keeps the integrity in the way that when user doesn't exist he cannot be associated to a new project, but what about id_owner? This attribute should also be referencing table users and id_user. So, very project can have many users associated with it, but one of them is the owner of the project. I would like to have referential integrity defined so that when project is created and id_owner entered, the user alredy exists in users table. How would you do it?

How about adding id_owner as a FK referencing table users?

Thanks


Yes, you will need to add id_owner as a FK referencing table users, exactly as you say.


I think you've answered you own question.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜