On Thursday, July 12, 2012 12:08:21 PM UTC-7, Jamie Hodge wrote: > > I was asking if the records and joins tables could be structured in a > manner that better embodied the business logic, i.e. a way in which it was > impossible for an approval record to exist without an accompanying item and > author pair.
Well you could use a database trigger to enforce this constraint (delete trigger on authors_items that raises an exception if an approval for the item's asset and author exists, insert trigger on approvals to make sure that an entry for the asset's item and author exists). You may also be able to use a composite foreign key if you denormalize your database such that authors_items also contained an asset_id column with the asset id related to the item. I'm not a fan of denormalization for non-performance reasons, though, so I'd recommend the trigger route. One thing that would everything simpler is to not separate the assets table from the items table, so if you don't have a good reason to keep them separate, you should probably combine them. Jeremy -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/sequel-talk/-/6_hePUkRIbwJ. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sequel-talk?hl=en.
