Referencing this great answer by PerformanceDBA:
The referenced answer approaches the problem of supertype subtype by :
using a Discriminator in the base-type ( which could be constrained by using FK and lookup table for TYPE)
creating a simple FUNCTION to check exclusivity which gets called using CHECK constraint in the subtype.
My question : if the discriminator is part of the primary key of the base-type and a User Defined Function is USED to check for exclusivity , would a design like this break any relational design or would it make the design simpler ( given that the PK is not multi valued of course) ?
Here is an example for illustration:
ProductID | Description |
---|---|
120001 | This product is Car ( starts with 120) |
150001 | This Product is Boat (starts with 150) |
160001 | This Product is Jet (starts with 160) |
can call a function that checks for the ID of product and insert this into the desired table ( Jet table , Boat Table or Car table ) based on the ID?
if that is the case , can I get rid of the Discriminator column and the look up table too ?
is there any shortcoming of this approach ?
UPDATE to illustrate the two design approaches :