Reputation: 95
I am learning UML to model a database for a class project. Essentially the database is for a social network. The tables are user, friends, profile, status, wall_posts, and comments. I'm having some trouble nailing down the exact relationships.
At first glance it appears that all tables have the composition relationship (of varying multiplicity); a user "has a" profile(1-1), a user "has" friends(1-0..*), wall_posts (1-0..*), and a wall_post "has" comments(1-0..*). If the user is removed, the effect cascades and should remove any records that have that user id. The user table has info like the uid's name (which is not replicated in the wall_posts table), so something like a message record would have to be removed.
Is there a flaw in my logic?
Upvotes: 1
Views: 611
Reputation: 656241
The part where a user "has" friends(1-0..*)
is flawed.
That should be an n-m between the user table and itself (or 0..*-0..*
in UML notation), because all those friends are not exclusive to one user. Everybody (hopefully) can have many friends. Could be implemented by a friendship
table that holds two (distinct) foreign keys to the user table and possibly additional attributes describing the relationship.
Upvotes: 2