• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Understanding of SQL Relationships

 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My apologizes if this is not the right post .

One-to-one relationships are single-valued in both directions.

My understanding with the above is that

Consider a Zip Table

ZipNo Studentname

12 Harry
13 Kiran

And a Student Table


ID Name ZipNo

101 Harry 12

and there should not be any more student with zipno 12 . Then this will be a One to One

Am i right ?
 
Campbell Ritchie
Sheriff
Pie
Posts: 49827
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, that is not a one-to-many relationship because it is not a relationship.
It is only a relationship when the data join different tables.

Student table-----Tuition fees table

That will be a one-to-one relationship

Student table

Campbell 1234
Ravi 1235

Tuition Fees table
1234 $1.23
1235 $938475937459676734096740364376093470687234096732472340.99

You can have a one-to-many relationship

Student table as before
Residences table
King's Hall 99
Queen's Hall 98

Accommodation table
1234 99
1235 99

You can work out from that, both students shown live at King's Hall at present, and one has rather more tuition fees to pay than the other.
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Campbell , Your explanation is very nice .

I understood how the tables should be written for supporting relationships.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic