Answer the question
In order to leave comments, you need to log in
How to properly organize a one-to-many relationship?
Simple relationships are used throughout the mySQL project.
Example:
1. A table where "client types" are stored
2. A table with the clients themselves, there is a field - "Client type", (this field has a connection in mysql with another table by ID) referring to table No. 1. Everything is standard. One client can have one type.
And if I need, for example, that one client would have a connection with two types, with two records in table No. 1? How to do it right.?
I assume that you can make a field and store an array of IDs of these types there. But then there will be no more connections in mysql, and it is not clear how to then select clients with a certain type.
How is this generally implemented?
Answer the question
In order to leave comments, you need to log in
And if I need, for example, that one client would have a connection with two types, with two records in table No. 1?This is a many-to-many relationship. Organized by an intermediate table, each record of which links a pair of the first and second main tables.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question