I’ve hit a bit of a wall … here is my simplified schema:
TABLE users
id
TABLE assets
id
userid
TABLE presentations
id
userid
At this point, it’s easy to create a relationship between USERS -> ASSETS and USERS -> PRESENTATIONS … but where I run into a bit of a brain fart is when I introduce TEMPLATES for the PRESENTATIONS:
TABLE templates
id
You see, each TEMPLATE has several positions… not all TEMPLATES have the same amount of positions. Each position houses an ASSET or is empty.
I’m having a hard time trying to figure out which way is the best way to connect PRESENTATIONS -> TEMPLATES (and position) -> ASSETS … and keep in mind, not all ASSETS are associated with a PRESENTATION.
Proposed Schema:
TABLE presentations
id
TABLE templates
id
TABLE positions
id
templateid
assetid
But there is a problem with this. This assumes that each TEMPLATE can just a random amount of POSITIONS. Yes, a TEMPLATE has a 1 – n relationship with POSITIONS, but not really. Because a TEMPLATE wouldn’t be a TEMPLATE if it wasn’t repeatable. TEMPLATE 1 has 4 positions, and will always have 4.
OK, let’s see as promised:
Now you have templates that have fixed positions. Every presentation uses one template. For every presentation and every position inside this presentation you can define one asset or none. You must make sure that in table AssetForPresentation only position ids are used that are actually member of the template used by this presentation. If a position of a given presentation has no asset, just don’t create an entry in table AssetForPresentation.