Design Challenge #1 - Having the same primary key in two or more logical entities
The general scenarioYou are a data modeler designing a data mart, and have come across at least two different entities on your logical data model that happen to have the same primary key. On your physical data model, would you keep them in separate tables or merge them into a single table because these entities share the same key? Don’t answer just yet! I’m not looking for a response such as “separate tables” or “single table”. I’m looking for a set of guidelines on when to go which route. Read on for the specifics. Thanks to Ben Ettlinger for providing the idea behind this scenario. The detailed scenarioIn your role as data mart data modeler, you have identified the following two main questions this data mart must answer:
So your Actual Expense and Forecasted Expense logical entities look something like this (primary keys are above the line):
What should the physical entity (or entities) look like if the primary key to both of these entities is the Month and Department? What I’m looking for is not just an answer, but guidelines on when to choose which design. Imagine you are writing these guidelines for someone with minimal data modeling experience. Guidelines can be in the form of if-then-else logic, for example:
Guidelines can also be in the form of a flowchart or spreadsheet, whatever medium you think is most conducive to explaining the options. Let your imagination run on this one. There are no restrictions and no wrong answers. |
