Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a database design pattern name for reducing duplicate join table data?

I have two tables with a join table to allow a many-to-many relationship.

enter image description here

It's a very familiar design pattern. It indicates which Branches each Member has access to.

As the number of members and branches increases I end up with a lot of data in the join table that is duplicated across members. Members tend to have access to the same groups of Branches as other Members.

So I'm looking at normalizing my data by creating a MemberProfile table that is effectively immutable. And rather than creating MemberBranch records for every Member I check for a matching MemberProfile, use if it already exists, or create one if it doesn't:

The idea being if I have a million Members with only a hundred access profiles this will save me a lot of space in my database.

enter image description here

I'm happy that it all works and that the development effort is worth is.

My question is "Is this a standard database design pattern, and if so, what is it called?"

EDIT: It's been pointed out that this is compressing the data not normalizing it. Which is the intent behind the design.

like image 437
Derek Tomes Avatar asked Jun 02 '26 17:06

Derek Tomes


1 Answers

Unless your many:many table is always the join of particular other base tables, one is not normalizing. You aren't normalizing here. Normalization does not introduce new column names. It just rearranges the current ones among different base tables.

You are just compressing/encoding your data. There is not necessarily any benefit in this, since now some queries and updates will be slower although your database is smaller. (You have reported that it is worth it in your case.)

like image 152
philipxy Avatar answered Jun 05 '26 06:06

philipxy