SQL (Teradata) Help
14 hours ago, leegbr said:The id is the primary and foreign key between the two tables.
That wouldn't work. A primary key must be unique. If the primary key of the address table is also its foreign key (i.e. it matches customer id), then you can only ever have a 1:1 relationship.
The customer table should have an id, the address table should have both an id (its primary key) and a customer_id (foreign key that references a customer) if you want a 1:n relationship.
So either you have a 1:1 relationship, which means you can't have more than one type 5 address per customer and you really have both duplicate customers and addresses, or you have a 1:n relationship and you need to join on some other column. Or you added an id and didn't actually set it as a primary key, meaning it has no unique constraint.

Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now