Guard Customer Data
EasyDescription
Add two rules to customers:
- no two customers may share a phone number. Name this rule
uq_customers_phone. loyalty_pointscan be at most 100000. Name this rulechk_loyalty_max.
Customers without a phone number must still be allowed.
Then list the table's unique and check rules with this query:
CodeSELECT conname, pg_get_constraintdef(oid) AS definition FROM pg_constraint WHERE conrelid = 'customers'::regclass AND contype IN ('u', 'c') ORDER BY conname;
Finish with exactly this query.
Tables
| customers |
|---|
| customer_id (PK) |
| full_name |
| phone |
| city |
| country |
| date_of_birth |
| loyalty_points |
| created_at |