Background
I have a MySQL table for which each record represents a region- and/or platform-specific version of an item. For any given item, there will be several versions; there's no primary key and mostly indexed columns.
I start with worldwide records, one for each platform-version of the item. Then I add records for any region-specific values, then add records for any country-specific values. The thing is that I only plan to add values that are unique to that region or country; in other words, all records are going to have null values because I don't want to enter repeated values, so I want records to inherit values from other records.
item | platform | region | country | date | price | [...]
1 | 1 | [WW] | null | 2013-04-01 | 100 |
1 | 2 | [WW] | null | 2013-04-01 | 100 |
1 | null | [EU] | null | 2013-04-20 | 80 |
1 | null | [UK] | null | null | 70 |
I plan to use PHP to display the relevant records for a given country. The thing is, I want to be able to combine/inherit values from that country's region record and the worldwide record. So the UK would have two total records: each one inheriting a platform
value from the [WW]
record, both inheriting the date
value from [EU]
record, and both having the price
value from the [UK]
record.
1 | 1 | [UK] | 2013-04-20 | 70
1 | 2 | [UK] | 2013-04-20 | 70
The question I want to know is there a solution/procedure/method of doing it in MySQL only? Or is the only way to do it is via PHP coding?