sql - Many to many relationship with additional foreign key that has constraint -
i have database design
installations _______________ id groups (relation 1:n installations) _______________________________________ id installation_id services (relation 1:n installations) ________ id installation_id buttons (relation 1:n services) ___________________________________ id service_id buttons_enabled _______________ group_id button_id service_id
actually have simplified because in fact there m:m relationship between services , installations.
what constraint buttons_enabled have button services related installations of groups.
so example
installation
inst1
inst2
groups
g1 inst1
g2 inst11
services
s1 inst1
s2 inst1
s3 inst2
buttons
b1 s1
b2 s1
b3 s2
b4 s3
buttons_enabled
g1 b1
g1 b4
last row physically correct not logical beacuse relate 1 group of installation 1 services of installations (b4 related service3 related inst2. g1 related inst1).
how can avoid it?
thanks
Comments
Post a Comment