Skip navigation links

MySQL Forums :: Foreign Keys (Referential Integrity) :: Normalise and uniqueness of a dataset where the combination of three columns is unique and one column is a many to many relationship


Advanced Search

Normalise and uniqueness of a dataset where the combination of three columns is unique and one column is a many to many relationship
Posted by: diego gullo ()
Date: December 06, 2012 05:42AM

I am faced with a unique requirement and I cannot figure out the elegant way of implementing this without a trigger, but that sounds like a workaround rather than proper design.

Lets say we have this non normalised dataset

Object ID (PK) Server Name domain role priority
1 server1.domain.name ALL 1 P
2 server2.domain.name 1,2,3 2 B
3 server3.domain.name 1,2,3,4,5 1 S
4 server4.domain.name ALL 3 S
5 server5.domain.name 3,4,5 2 S
6 server6.domain.name ALL 2 B
7 server7.domain.name 1,2,3,4,5 1 S DUP
8 server8.domain.name ALL 3 S DUP

Above DUP means duplicate as in this breaks the following constraints

-combination of domain, role and priority is unique (see the red lines break this uniqueness)
-domain column is a list of IDs or ALL is assumed (i implement this with a many to many relationship so if there is none ALL is assumed )

What design would you apply (if you could provide create statements would be great but not necessary) to have the above relations and constraints normalised?

Thanks in advance for replying

The text included in this forum might not show the raw data well. Please check this image to clarify it
http://bizmate.dreamhosters.com/normalise_unique_multipleFields.png

Options: ReplyQuote


Subject Views Written By Posted
Normalise and uniqueness of a dataset where the combination of three columns is unique and one column is a many to many relationship 413 diego gullo 12/06/2012 05:42AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.