database tables for each customer or database design with linked tables?
I'm just new to (mysql) database design, and would appreciate your
feedback with respect to the following question. I'm developing a website
linked to a mysql database that should contain customer info and product
info. For general customer info (name, address, date-of-birth etc) I've
created a table 'crm', for general product info (description of products
available) I've created a table 'products'.
My question is how to store the list of products selected by each
customer? This list will of course vary per customer and can also change
over time. Furthermore, the table 'products' may alo change over time (new
products being added or existing products being removed). First, I though
about a design with a 'customer product' table with selected products for
each customer, but after reading some comments on related pages on this
site I question whether that's a good design (as this may result in over
100K tables). An alternative solution may be a design with single table
'customer products' using links like this:
table 'crm' table 'customer products' table
'products'
-------------------------- -------------------------------
----------------
name | addr | first_prodref prodref | prodid | next_prodref prodid |
name | cost
- first_prodref in table 'crm' points to (index) prodref in table
'customer products'
- prodid in table 'customer products points to (index) prodid in table
'products'
- next_prodref in table 'customer products' points to the next prodref in
table 'customer products'
Would this alternative solution be ok or are there better suggestions?
Appreciate your feedback.
No comments:
Post a Comment