How to organize data?

MilantoMinsk

Member
Joined
May 2, 2014
Messages
7
Programming Experience
Beginner
Hi,

I don't know how to organize dana in a database that consists out of two tables. The first table is a list of Products with its specific columns (ID, description, price, etc.). The second table should be a list of Customers with the list of Products they bought. How do I organize table no. 2? Should I make a column with cells that contains a list of bought Products? How do I do that? Or should I assign each customer with a different table? In that case, where do I put information about Customers (Name, Date of Purchase, Number...).

I must mention that I am relatively new to Visual Basic, and before I get started with concrete database coding it is necessary to get a clear idea what do I want for my program to do.

Thanks
 
What you describe would most likely involve at least three tables, possibly more. You'd want one for products, one for customers and then at least one for the products that each customer bought. In the very simplest case:

Product: ProductId (PK), ProductName
Customer: CustomerId (PK), CustomerName
Purchase: ProductId (FK), CustomerId (FK)

You will obviously want other columns too, e.g. Quantity in Purchase, but that minimal schema shows the relationships between the tables. You might want to go a step further and have a table to store records of the overall purchase and then have that related to one or many records in another table for the items included in that purchase. That sort of schema is often used as an example so you shouldn't have too much trouble finding references to it online.
 
Back
Top