
This would mean we have one column for storing multiple values, which is very hard for maintenance and querying. We can’t add the primary key of one table into the other, or both, because this only stores a single relationship, and we need many. This means a student has many classes, and a class has many students.

A class can have many students (for example, there may be 20 students in one class).A student can be enrolled in multiple classes at a time (for example, they may have three or four classes per semester).We capture details about students who attend classes, among other things. Let’s say we are creating a database for a university (which is an example I’ve used often). However, for many-to-many relationships, it’s a bit different. Handling a one-to-one relationship or a one-or-many relationship can be done by adding the primary key of one table into the other table as a foreign key. Many-to-many: Multiple records in one table are related to multiple records in another table.One-to-many: A record in one table is related to many records in another table.One-to-one: A record in one table is related to one record in another table.There are three ways in which a table can be related to another table: The only few exceptions I've implemented 1 to 1 relationships are when we inherited previous databases with tables that had 100+ columns, and we split them up for performance and storage issues, but not for pure designing reasons.When normalizing a database or adding tables to an existing database, we need to be able to relate tables to each other. Maybe if you had a particular case scenario to share we could delve more in detail. Which one really represents the entity you are trying to store? Do you really need 2 different tables for them? Does your entity exist only when both records are created?ġ to 1 relationships always raise an eyebrow when designing. If the existance of stuff depends on more and more depends on stuff then there is a problem of the chicken and the egg. Also, in databases that don't support deferrables foreign keys or multiple inserts in one statement (thanks to for this note), you won't be able to insert the rows without disabling the foreign key first.

Linking both ways would be redundant for one of the relationships, as you just need 1 to know the nature of the link.

As far as I understand, a one-to-one relationship between two tables means that each row in one table matches exactly one row in the other.
