Difference between one to one and one and only one relationship in SQL Server

siddangoud
 
on Apr 08, 2021 06:02 AM
888 Views

Hi all

Please tell me the difference between one to one relationship and one and only one in sql server

thanks 

Siddu

Download FREE API for Word, Excel and PDF in ASP.Net: Download
Andrea
 
on Apr 08, 2021 06:02 AM
Hi @siddangoud,
Please try the following

How to copy rows from one table to another in SQL Server

It might help you.

Cheers Andrea.
dharmendr
 
on Apr 08, 2021 06:29 AM

Hi siddangoud,

If one department can have one employee then, department to employee is a one to one relationship, while if one department can have multiple employees then, department to employee is a one to many relationship.

Thats means table has one row that is associated with one row in another table.

siddangoud
 
on Apr 08, 2021 07:33 AM
dharmendr
 
on Apr 08, 2021 11:33 PM

only one means lets say

Student can have one and only one login (e.g. user123) and that login can only be assigned to Student1.

When Student1 graduates, no one else can be assigned the login user123.

one means lets say

A student Student1 can only have one room at a time. A room can only have one student at a time.

Next year, Student1 will be assigned a new room and at that point his/her room from this year will be assigned to a new student.