Let's say I have a type hierarchy: (just an example)
the general entity customer:
CREATE TABLE customer(custom er_id int, customer_name varchar(250),
customer_type int)
three specific customer subtypes: 1 - business, 2 - home, 3 -
university
represented by the following three tables (being subtypes, they share
ID space for customer_id)
CREATE TABLE business_custom er(customer_id int, business_sector int,
.... )
CREATE TABLE home_customer(c ustomer_id int, household_incom e_bracket
int, ...)
CREATE TABLE university_cust omer(customer_i d int, number_students int,
....)
Is it possible to make a foreing key constraint that says:
the customer_id in busineness_cust omer table must reference only those
customer_id in the customer table where customer_type == 1?
the customer_id in home_customer table must reference only those
customer_id in the customer table where customer_type == 2?
Thanks!
- Robert
the general entity customer:
CREATE TABLE customer(custom er_id int, customer_name varchar(250),
customer_type int)
three specific customer subtypes: 1 - business, 2 - home, 3 -
university
represented by the following three tables (being subtypes, they share
ID space for customer_id)
CREATE TABLE business_custom er(customer_id int, business_sector int,
.... )
CREATE TABLE home_customer(c ustomer_id int, household_incom e_bracket
int, ...)
CREATE TABLE university_cust omer(customer_i d int, number_students int,
....)
Is it possible to make a foreing key constraint that says:
the customer_id in busineness_cust omer table must reference only those
customer_id in the customer table where customer_type == 1?
the customer_id in home_customer table must reference only those
customer_id in the customer table where customer_type == 2?
Thanks!
- Robert
Comment