This topic has been archived. It cannot be replied.
-
工作学习 / 专业技术讨论 / 有哪位朋友能帮着解答一下吗 ? 谢谢!
-dacong(大了聪明);
2005-8-31
{712}
(#2479801@0)
-
You only need 4 tables, Team, Member, Dog and an INT table. Regarding Queries, you need to join the tables. This is a question for IT beginner, for example, me.
-wonderlife(Wonderlife);
2005-8-31
(#2480229@0)
-
Then, how do you enforce the rules? such as a dog can belong to only one owner and one team?
-schen(睹往睹来);
2005-8-31
(#2480286@0)
-
Link the dog to INT table.
-wonderlife(Wonderlife);
2005-8-31
(#2480296@0)
-
Does that guarantee one-dog-one-owner? or one-dog-one-team? INT table usually is for many-to-many relationship.
-schen(睹往睹来);
2005-8-31
(#2480301@0)
-
Ok,in your INT table, you could have:
INT_Id (PK)
Team_Id
Employee_Id
.
.
.
In Dogs table,
you have foreign key to INT_Id (FK).
-wonderlife(Wonderlife);
2005-8-31
{134}
(#2480329@0)
-
Bad idea..Why can't you just make a composite PK including teamID and employeeID in the INT table. That way the Dog table does not lose it autonomous and self-contained nature for an entity.
I like the 4-table approach though. Just need to add some constraint/index/keys to perfect the solution, right? :)
-schen(睹往睹来);
2005-9-1
{299}
(#2482167@0)
-
Right, in order to enforce those business rules, we have to put constraints, checks, indexes there.
-wonderlife(Wonderlife);
2005-9-1
{597}
(#2482384@0)
-
good, point taken.
-schen(睹往睹来);
2005-9-1
(#2482549@0)
-
Thank you!
-dacong(大了聪明);
2005-8-31
(#2480568@0)
-
是4个表同时joint吗?条件是什么呢?
-ear(耳朵);
2005-9-1
(#2481327@0)
-
你不睡觉啊?If you like, you can definitely join 4 tables together. But I like join 3 tables each time.
Condition is "Equal"
-wonderlife(Wonderlife);
2005-9-1
{115}
(#2482093@0)