Sandeep Bansal
Sandeep Bansal

Reputation: 6394

Does this ERD make sense?

I'm trying to replicate an email service provider where emails can be stored and also sent out based on subscribers. I'm focusing on the data structure atm but I can't help but to think I may have done something wrong.

As you can see in the diagram, towards the Subscriber, List and Subscriber List relationship. I'm trying to achieve the scenario of..

A subscriber can be part of many lists, but a list can hold many subscribers.

Does this diagram make sense on this matter?

Thanks

enter image description here

Upvotes: 1

Views: 1156

Answers (1)

Giovanni B
Giovanni B

Reputation: 1032

Looks good to me. Because you have a many to many relationship between subscribers and lists, you need a mapping table (subscriberlist) to hold the relationships.

If you're asking about the ERD as a whole, it's hard to say if it's what you need. In regards to subscribers having many lists and lists having many subscribers, the way you are doing that is the way to go.

EDIT: I'm not sure why you have a column called Lists in the subscriber table. The SubscriberList table should hold all of the mappings between Subscribers and Lists and trying to replicate this data anywhere else is going to create an issue of denormalization.

EDIT2: The classic example of this that I always think of in these many to many relationships is Users and Roles. In just about any complex web application you have lots of Users and multiple Roles. The only way to allow for a User to have many Roles (and each Role to have many Users) is to create a mapping table as you have shown in your ERD.

A nice short and to the point explanation can be found about 1/3 of the way down this article under the heading "Many-to-Many Relationships": http://www.deeptraining.com/litwin/dbdesign/FundamentalsOfRelationalDatabaseDesign.aspx

Upvotes: 2

Related Questions