Welcome Guest, Not a member yet? Register   Sign In
SQL architecture - multiple options on one row?
#1

[eluser]umbungo[/eluser]
OK.. so I am trying to figure out the best format to store information.

Taking a lighting example;

Say i have a bulb which is available in 40/60/100 W, and also screw and bayonet fitting.

so i could have;
Code:
PID | type | W   | fitting
1   | bulb | 40  | bayonet
2   | bulb | 60  | bayonet
3   | bulb | 100 | bayonet
4   | bulb | 40  | screw
5   | bulb | 60  | screw
6   | bulb | 100 | screw
This doesn't seem very efficient, in terms of database queries or data input. Or i could do something like;
Code:
KEY | PID   | type | W         | fitting
1   | 1,2,3 | bulb | 40,60,100 | bayonet
2   | 4,5,6 | bulb | 40,60,100 | screw
and then use 'explode' to extract 40 60 and 100, followed with some PHP to sort things out.

But there must be a better way?? Also this would prevent me from running queries such as wattage > 50, which would be a problem.
NB. there will be ~2K options combinations of say 400 'groups', and much more details stored in the db.

How should i handle this?? Do i have to go NOSQL? It seems like it would be quite a simple/common problem, is there a mysql solution that i'm simply unaware of??

As an aside; does anyone have an opinion on weather it would be best to combine the pages for SEO or make them separate? (ie one for each option combination). I'd guess separate would get more long-tail clicks from googlers but may present a duplicate content issue??.




Theme © iAndrew 2016 - Forum software by © MyBB