Home computickets An example of a many-to-many relationship

An example of a many-to-many relationship

Author

Date

Category

Hello!
I can’t understand the many-to-many relationship.
What does she mean?
Please give an example when this connection needs to be established.


Answer 1, authority 100%

“One-to-many” is a type of table relationship, when one record of the main table can be associated with several records of the subordinate table. This is the most common type of relationship between tables.
Well, for example, if you create a telephone directory, then you need to take into account that one person can have several phones (2 mobile, 1 home and 1 business). Or another example: a student (records about students are stored in the main table) studies at a university – he studies several subjects (records about subjects are stored in a subordinate table), for which he takes exams and tests.


Answer 2, authority 73%

For example, we have a list of people:

people

id | name | last_name

and list of books

books

id | name | author

In order to preserve the relationship (who likes which book), a many-to-many relationship is needed, which is implemented through a third table:

people_book_like

people_id | book_id | liked_time



Answer 3, authority 64%

We will not go far and take examples from life:
Let’s create a database describing the work of a school

  1. Each school is guaranteed to have 1 principal. This is a 1 to 1 relationship. 1 school – & gt; 1 director

  2. Each school has several classes, this is a 1-to-many relationship. 1 school – & gt; many classes

  3. Now subject teachers. If we try to draw up a table of the relationship of teachers with classes, we get a rather complicated picture: 1 teacher can teach in several classes, at the same time, several teachers can teach in one class. This is the classic many-to-many relationship. Multiple Teachers & lt; – & gt; Several classes.

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions