Answer the question
In order to leave comments, you need to log in
Is it possible to link one field to another through a comma (for example)?
Good day! There is a table with realtors and houses. I need a connection so that one house could have, for example, 3-4 realtors, and the same realtor can be in another house. At this stage, I have implemented only a selection by id from the realtors table and add their id to the house table in the varchar field, separated by a comma, so that I can then select their names and phones. But I would like to implement this with the help of connections so that if the realtor is deleted, then his id would be deleted from all the houses to which he is attached. In the way that I did, it is difficult to implement. Thanks in advance for the replies!
Answer the question
In order to leave comments, you need to log in
You need a Many-To-Many bundle. The bottom line is this:
1. Houses exist separately (knowing nothing about realtors)
2. Realtors exist separately (knowing nothing about houses)
3. A third table is introduced that is responsible for the ID link (house_id, rieltor_id)
Thus, knowing house_id, for example - you can choose all tied up realtors. Knowing rieltor_id - you can select all linked houses.
And so that when the realtor is deleted, he is also removed from the houses - you will need to set up FOREIGN KEY
Search the net for these topics. Shaft materials.
And in many frameworks, it comes out of the box.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question