Table or Sub-Table?
Hi,
I'm building a database for my company we do production and sales and I'm confused when to make a related table and when to make a sub-table. I understand when I make a table invoice - with subtable Invoice lines (items).
I have made the following database:
I am worried to have too many sub-tables in sub-tables.
Just a little background we work with 3 different product groups: finished products, half finished products and raw supplies. I want to use the database to keep inventory of our supplies and products (this works) and when we have an order to see if I have:
a) enough finished products to fill the order and/or
b) combination of half finished products and raw supplies to fill the order and/or
c) enough raw supplies to fill the order
I am now at the point where I want to make a table with the possible combinations to create a half products and finished products, so that I can automate the system to tell me if and how I can fill an order and see if I have enough products or need to order more raw supplies.
Any advice or help will be appreciated.
18 replies
-
Hi I would be asking a simple set of questions that determine the relationships.
Can a Contact have more than 1 invoice? Yes
Can an invoice relate to more than one Contact? No
So we now know we have a 1:N relationship between Contacts and Invoices. Now ask
Does an Invoice HAVE to have a Contact? Yes
We now also know that Invoices is a sub-table of Contacts (Composition is ON) which prevents an Invoice being an orphan (one with no Contact)
I would also be careful about splitting out Parts, WIP and Finished Products into their own tables. If, on the whole, they have similar properties then it's more than likely that they all belong in the same table. For these I'd say they all live somewhere, have a value, can be counted, have a SKU, etc so they belong in the same table.
I always aim to have as few tables as possible
Hope that helps. Good luck and always feel free to come back. Maybe share your model again soon?
Regards John
-
Thank you John,
I get what you are saying, and I'm glad that I'm on the right track. The confusion starts when combining data from multiple tables and sub-tables.
My idea always starts with what the easiest way to enter the data is. Once it's entered it's the way data is related and how the data can show you the results or answers you need.
If any of you want to contribute or reply, please do so.
-
Let’s start with Trades. Can you explain what they are? Thanks
-
Don't worry about too many tables. The important thing is if the data is different enough to need a new table. Most people don't make enough tables. If you find yourself making field names with a number after it to track different instance of similar data. Then you need a new table. Like the employees assigned to a job. Even if it is typically one or two employees per job, most people would create two fields employee1 and employee2. But even this case you would want to create a child table to jobs called workers.
-
and
Thanks guys,
I think I know where to go from here. I'm ready for an elegant solution with enough tables, but not too many to make it work .
Thanks again.
-
Here is something I made awhile back that show what could be done for your work orders as product/supply mgmt. It is made for 1 level between supplies and product. If you have half products that go into finished then that is another redesign that I'm currently figuring out.
Content aside
- 3 mths agoLast active
- 18Replies
- 152Views
-
5
Following