Quote:
Originally Posted by monion
This just seems like the wrong way to be doing this...
That is indeed the wrong way to design a DB.
You tables and columns should never be named using actual data. Like creating individual tables for each vendor. You database should be able to scale perfectly without you ever having to alter the actual tables.
If you would have to create a new table or column to add data to your database, it is (usually) not designed properly.
Quote:
Originally Posted by monion
As to your ?, I understand everything but the 2nd part of the 2nd part:
Consider this:
- +--------+ +--------------+
-
| vendor | | item |
-
+--------+ +--------------+
-
| id PK | | id PK |
-
| name | | name |
-
+--------+ | price |
-
| vendor_id FK |
-
+--------------+
-
-
+--------+ +--------------+
-
| site | | site_item |
-
+--------+ +--------------+
-
| id PK | | item_id FK |
-
| name | | site_id FK |
-
+--------+ | allowed |
-
+--------------+
The "site_item" table there is the important part. It links the items in "site" with the items in "item", so if you ever need to find out whether a particular site is allowed to sell a specific item, you would search the "site_item" table for the row that has the correct IDs and then just read the "allowed" value.
Does that make more sense?