Database modelling remove bridge table

喜你入骨 提交于 2021-01-29 17:10:33

问题


I have designed a database with some outside help and I am thinking about a major change to the database model because of a problem creating reports in Power BI I have recently encountered here: SQL Power BI Report with Bridge Table

Disclaimer: if I could ask anyone within my firm, I would, but I can't.

We have a three-layer structure

  1. A main table Firms, with information about the year and unique key/name for each firm
  2. A bridge table Firm_Bridge which information about the type of the firm linked to Firm_Types
  3. Many end Tables with information about sales and stuff

For these end tables, there are two types

  • Single type tables that only matter for one Type (End_Table_Type_A or End_Table_Type_B) (often the case)

  • Multi type tables that matter for more than one type (End_Table_Type_all) (rarely the case)

This is a made-up example similar to the real model

I am wondering if it was better to simplify this structure and directly connect the single type end tables to the firm table. I can still use the bridge table to document the type of firm and also connect the End_Table_Type_All to the firm's table. I imaging like this.

I hope this would avoid the problem that I have in my other question when summarizing stuff of end tables across years from Firms and reduce the complexity of our data model, as most tables are only single type end tables. I can exclude one join for most queries.

I am afraid I am missing something and that the current way is the proper way to model this.

What would happen in the changed model if I were to join the 'Firm_Type' to 'Firms' and then the single Type end table 'End_Table_Type_A'. Would it fetch the single end type table for each type?

Then, my idea would be stupid and I need to find another solution to my problem.


回答1:


Just to give this closure. It seems to be indeed a stupid idea, because I would duplicate rows connected to the end tables, as soon as I merge the information of the type with the Firms table.



来源:https://stackoverflow.com/questions/65347482/database-modelling-remove-bridge-table

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!