How do I normalize a database with lots of many-to-many relationships?

Posted on

Question :

I am building a database that is based around a business project, in this case called a “Program.” Each Program will have multiple Reports, Clients, and Partners.

My first thought was to place each Program, Report, Client, and Partner into their own table and then use a linking table for the Report, Client, and Partner tables to the Program table’s primary key.

Can I link all of them with a single table by just making repeat entries? I am not sure if this even makes sense, I am kind of lost as to how one descirbes an ERD in a post like this.










ProgramID (FK)

My concern is that because a Program may have multiple Reports, Clients and Partners, that I cannot do this in one link table and istead need 3 link tables, one for each. Any help would be great… sorry if I am not to clear on this.

Answer :

You should start by writing all the relationships between those tables. From your description, I could not find out how Partner would be related to Client, Program or User. However, the diagram below is a start based on the information provided. Note that you can’t use 1 Link table to link all table from what I understand in this case.

EDIT – New ERD based on new requirements

enter image description here

It is very clear but you should probably first read some “introduction to relational databases” before you proceed, because from the way you are asking I feel it would be beneficial for you to get some basics first. No offence, it may save you lot of time later.

To give you few fast rules of a thumb

  • You never ever connect more then two tables with one link. Try to connect tables step by step. Always take a pair of them and try to join them. Do not try to solve the whole thing at once.
  • you only need the link table if there is so called many to many relationships, i.e. if a client can have many programs and at same time one program can have many clients. It seems to me that it might not be needed in your case.
  • In all other cases you just place “anothertableID” to one of the tables. In your example it would be good to start with putting ProgramID to ReportTable, ClientTable, PartnerTable. Maybe it is what you need.

To give an more elaborated answer you should give more information about structure of your problem.

Leave a Reply

Your email address will not be published. Required fields are marked *