Разложение троичных отношений на бинарные отношения
Я разрабатываю базу данных, которая обрабатывает пользователей, учетные записи и проекты со следующими отношениями и ограничениями:
An account has many users A user belongs to many accounts An account has many projects A project belongs to only one account A user collaborates in many projects (redundant note: each one of them belonging to its own account).Другими словами, пользователь может сотрудничать во многих проектах одной учетной записи. Но поскольку пользователь может принадлежать к нескольким учетным записям, он может участвовать во многих проектах нескольких учетных записей. Это приводит меня к троичнойcollaborates отношения:
Прочитав пару статей о преобразовании троичных отношений в бинарные, я пришел к следующим эквивалентным отношениям:
Здесь возникает два вопроса:
Is this conversion correct? I have found that I have to add additional checks at application level to handle insertions. For instance, before adding a new (User,Project)
I have to check that the user belongs to the same account that the project belongs to.
Is it really necessary to establish the relationship between Account
and User
? Once the relationship between User
and Project
has been added, couldn't we know the account a user belongs to by accessing the project?
Спасибо!!