Ok so we have Table 1
(T1) and Table 2
(T2)
Structure:
T1 (main table):
ID (Auto-Increment)
Name
Properties
T2 (properties table):
ID
Property Name
Let's say table 1
has two entries. Table 2
has 4 properties.
What i want to do is set the properties of entry 1 in table 1
to map to property 1, 2 and 3 in table 2
. For entry 2 in table 1, i want to map it to property 2, 3 and 4 in table 2.
For example, let's say we have two products, a BALL and a CUBE. Those would be listed in table 1
. Now let's say table 2
holds all available COLORS.
Table 2:
ID COLOR
1 RED
2 BLUE
3 GREEN
4 YELLOW
Table 1:
ID NAME AVAILABLE_COLORS
1 BALL (TABLE 2 ENTRY 1, TABLE 2 ENTRY 2, TABLE 2 ENTRY 3, in other words RED BLUE GREEN)
2 CUBE (TABLE 2 ENTRY 2, TABLE 2 ENTRY 3, TABLE 2 ENTRY 4, in other words BLUE GREEN YELLOW)
How would i get the available colors to point to the colors table? Basically i want to make sure if i change a property (say color red->black), it gets automatically changed for all table 1 entries.
usually if i would only need to assign one color to one item, and that color cannot be used in another item, i would simply add a column in table 2
with "belongs to" or something like that, and this way i can set multiple colors to match the same entry in table 1
, however, i can only assign a color to one entry that way... i cannot assign per say red to both ball and cube.
Anyone got any idea?