patternMinor
What is the correct way to enforce unique "IS-A" relationship?
Viewed 0 times
uniqueenforcethewhatwaycorrectrelationship
Problem
Let's say we have a Person relation, and with that Employee which IS-A Person, Manager, which ISA Person as well.
What is the correct way to ensure that a Manager isn't an Employee and vice versa ?
I didn't know what to look for when asking the question, there most likely already exists an answer to that question.
Person cannot be at the same time an employee and a manager.
Maybe with another example.
Circle is a shape, Rectangle is a shape, how do I ensure Rectangle is not a Circle (and vice versa)?
Hence my question, What is the correct way to enforce unique "IS-A" relationship?
What is the correct way to ensure that a Manager isn't an Employee and vice versa ?
I didn't know what to look for when asking the question, there most likely already exists an answer to that question.
Person (PK:personId, name, ...);
Manager(PK:#personId); -- A manager ISA person
Employee(PK:#personId); -- An employee ISA person
INSERT INTO Person (1,'Peter',...);
INSERT INTO Manager (1); -- OK
INSERT INTO Employee(1); -- Nope, error.Person cannot be at the same time an employee and a manager.
Maybe with another example.
Shape (shapeId);
Rectangle(shapeId, width, length);
Circle(shapeId, radius);Circle is a shape, Rectangle is a shape, how do I ensure Rectangle is not a Circle (and vice versa)?
Hence my question, What is the correct way to enforce unique "IS-A" relationship?
Solution
Relation
Application that refer to the Person and Position relations should have unique personID attribute and should have the single attribute positionID that can have one and only one value at once.Context
StackExchange Database Administrators Q#215190, answer score: 3
Revisions (0)
No revisions yet.