Answer the question
In order to leave comments, you need to log in
Are there such a thing as a conditional unique index in any DBMS?
A conditional unique index could:
1) ensure that values in a field are unique for each unique value in an adjacent table field (solution: composite unique index);
2) ensure the uniqueness of the values in the field for each unique value in some field of the parent table.
For example, there are two tables:
I need to ensure that the addr field in the Line table is unique , not just unique (addresses in different cities can be the same), but unique for each unique value in the city_id field of the Group table . Is it possible?
Answer the question
In order to leave comments, you need to log in
You can make a Composite Unique Key on the fields addr, city_id or addr and group_id
For example:
in case you need some information from another table, your database probably needs some extra normalization. You should not restrict writing to one table based on any values from the related table, because then there is an ambiguous relationship
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question