Home > Software design >  Persons & Addresses Table Relation in SQL?
Persons & Addresses Table Relation in SQL?

Time:08-30

I have a table Persons with Id and Name columns. Let's say Id=100, Name = Al

Address table:

  • Id=1, Address= 123 Street, FK_Persons=100,
  • Id=2, Address= Near Building#22, FK_Persons=100

Is this one to many relationship?

CodePudding user response:

Yes, it is a one to many relationship, if there are no other constraints on the tables. You can create multiple addresses and assign it to one Person object, that's why it is a one-to-many relationship.

CodePudding user response:

For a single, unique address, you can have zero to one person

Address -> Person : 0, 1

For a single, unique person, you can have zero to many addresses

Person -> Address : 0, N

You then end up with a relationship such as : (0, 1) : (0, N), which can be simplified to 1 : N

This is indeed a one to many relationship

  •  Tags:  
  • sql
  • Related