polymorphic associations - Database schema design - how to store specific application settings against entities -
i'm trying design database tables store configuration settings entities , applications associated with. can far have hit "brick wall". i'll show mean... (do not take following: pictures, literal business problem, pictures easy way of explaining problem you).
criteria
- we have catlog of pictures.
- we have several applications can consume number of these pictures.
- we want configure how display these pictures depending on application.
bear in mind each application has specific , unique way can configured show pictures.
so it's clear need 2 tables picture , application , junction table show m-m relationship, many pictures can in many applications - see below:
i have highlighted in red column "config_table" - have strong suspicion bad, very, bad. showing paricular app config table store settings in. see below:
so - there speicific app configurations apply pictures, depending on app talking about. assuming design broken, believe it - how design database model correctly? (hope makes sense)
the design not far off being correct. don't need application.config_table
column. instead, each application ought know table pertains own use of pictures.
so example in picmanager application, this:
select p.*, c.* picture_appliation pa inner join picture p on pa.pic_id = p.pic_id left outer join picman_config c on p.pic_id = c.pic_id pa.app_id = 100;
and in each of other applications, you'd code different config table in query.
don't try make "automatic" or "data-driven". write code appropriate in each application. can use data-driven methods data values (e.g. app_id=100), not code. data data. code code.
you may want write 1 reusable class that's employed in applications, that's subclasses for.
Comments
Post a Comment