How to design a database for modular widgets -


i'm stumped , hoping smart people out there can me!

my knowledge of database design middle of road @ best. enough me in trouble really. i'm programmer first , foremost.

i'm trying build website , design of back-end database has got me stumped.

i'm going give contrived example here sake of explanation, example spot on need achieve.

image minute building database old school fans of game car wars, or similar. in game player can pick 1 of several base cars, , customize use in game.

there attributes every base car have player customize, such engine, transmission, , armor. every car has these slots, , player's can drop appropriate items these slots. in addition these common slots, each car has n number of mounts. varies per car, though every car has @ least one, , large car have dozen or more. players can place weapons, or utility items these mounts. once player has configured car, saved build. build defines, base car chose, choices engine, transmission, , armor, weapons , items placed each mount. personalized build.

at first level, table layout pretty simple. have:

there car table contains fields basic stats on car, fields indicate can support engine, transmission, , armor. (for example small car might support v4 engine , light armor, while large car might support v8 , heavy plating).

engine, transmission, , armor tables define available choices player items.

there mounts table defines size of mount, car belongs to, , on car physically located.

and of course weapons table, , items table, defining weapons , items can go mounts, data such size control on can go mount.

this first layer , works well. problem second layer, defining how these connect in case of saved build. can't figure out how connect dots between car, mount, , weapons/items in mounts in context of saved build.

in build table, can have point base car, , choices engine, transmission, , armor easy enough. storing weapons/items chose though becomes bit more tricky. if ignore moment need know mount each placed into, fact remains have n number of weapons/items mounted. each build have variable amount. have one(build) many(weapons) relationship how define relationship without making unique instance of weapon or item each build? of course there added complexity of fact need store not weapons , items player chooses, specific mount put them into.

now work way out of mess if create duplicate instances of each weapon or item, instance pointing the build belongs in, , mount is stored in, means every build need create duplicates of every weapon or item chosen, , seems totally stupid , wasteful.

i'm sure there simple solution problem. i'm either being blind , missing it, or lack of experience database design prevents me seeing need see. pretend obi wan kenobi , hope!

i'll sure edit provide further details if requested. thanks!

edit: not sure why matter, sake of complete information using django website db abstracted away. use sqlite locally development, live server uses mysql.

create additional table purpose define link between items, mounts, , builds.

each entry in buildlink table item id, mount id, , id of build belongs to. many 1 relationship build table.


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -