Reputation: 11
I have been reading about weak entities and I think I am getting confuse about somethings. Let's say I have users, categories, activities and articles.
1. Categories depends on users to be created.
2. Activities depends on categories.
3. Articles depends on activities.
Now I have two questions.
1. Are all of it a weak entity towards User?
2. I have read that a weak entity primary key is dependant on the strong entity. But in this case Category has a primary key on its own so that Activity can link to it and Activity have a primary key on its own so that Articles can link to it. So did I violate the weak entity rule? If so, what can I possibly do? Ps, I have read that by adding a surrogate key, my weak entity would become a strong entity but am still confuse because the weak entity is dependant on the strong entity. Thanks, here is the image of the ER diagram that I am currently doing. ER Diagram
Upvotes: 1
Views: 231
Reputation: 8611
This depends not only on the relationship between your entities, but also on the information you record about them.
For instance, let's say a user creates a category.
If the resulting category has a globally unique name or ID, you can use that as its primary key, and it will be a strong entity, that doesn't depend on the user who created that category, even if you decide to record that user with the category. You may even decide not to do that at all, in which case the user creating the category is just an event occurring as part of the system's use that, apparently, doesn't need to be recorded.
Only when a category does not have a primary key consisting of its own attributes; e.g., let's say it has no ID and a name that is not globally unique, but that is unique per user, then you need to add the user's primary key to its primary key, turning it into a weak entity that depends on the user.
Upvotes: 0