Click here to Skip to main content
15,889,879 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am creating an ordering system that uses an Access database to read and write data. The database has many tables. In particular, I am stuck on the products table. I have other tables for category and manufacturer. I have put the ManufacturerID as a primary key in the manufacturers table and as a foreign key in the products table. I have also put the category as the primary key in the category table and as a foreign key in the products table. Is this the correct way of doing the relationships?

Also, I'm thinking of adding a users column in the orders table, so that an order search can be refined by which employee took that order. I currently have a users table which I use for the login system. Would I need to create a relationship between the UserName in the users table and the UserName in the orders table for this to work?

What I have tried:

I tried creating a one to many relationship from the category and the manufacturer to the product table.
Posted
Updated 26-May-18 5:27am

1 solution

Quote:
Is this the correct way of doing the relationships?
It all depends on the requirements. One way is to try to read out the relationships in natural language. Based on your design, it says
Quote:
each product is made by only one distinct manufacturer, and belongs to only one distinct category.
Does that correctly depict the requirements?
For example:
manufacturer table        product table          category table
manufacturer_id (PK) +--< manufacturer_id (FK)   ...
manufacturer_name         product_id (PK)        category_name (FK)
...                       category_id (FK) >---+ category_id (PK)
                          ...                    ...
 
Share this answer
 
v3
Comments
CHill60 26-May-18 17:07pm    
OP has tried to respond via a solution
Peter Leow 27-May-18 1:19am    
Thank you, CHiLL60.
Member 13779854 27-May-18 21:56pm    
Thanks, yes the example suits what I'm doing.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900