That's a good question. I don’t understand why someone marked you. (therefore, I noted that you support, because we are all here to study). In any case, this question shows that you do not fully understand the essence of the relationship (no rudeness is intended). Of these, four (only technically only 3) types:
One to one
One to many
Many to one
Many to many
One to one (1: 1): In this case, the table was divided into two parts in order to comply with the normalization or, more usually, the open closed principle.
Normalization : you may have a business rule that each client has only one account. Technically, you could say in this case that the client and the account can be in the same table, but this violates the normalization rules, so you separate them and do 1: 1.
Open-Close principle : a client table, may have an identifier, first name and last name and address. Later, someone decides to add a date of birth, and with it the ability to calculate age along with a bunch of other much-needed fields. This is a more simplified one-to-one example, but you use it mainly to expand your database without breaking existing code. A lot of written code (unfortunately) is closely related to the database, so changes in the table structure will violate the code. Adding 1: 1, like this, will expand the table to meet new requirements without changing the original, thereby allowing old codes to continue to function normally and new code to use the new db functions.
The disadvantage of normalizing and expanding tables using 1: 1 ratios is performance. Often on heavily used systems, the first goal of improving database performance is to de-normalize and combine these tables into one table and optimize indexes, which eliminates the need for joins and reading from multiple tables. Normalization / de-normalization is neither good nor bad, because it depends on the needs of the system. Most systems usually begin to normalize a change when necessary, but this change must be done very carefully, as already mentioned, if the code is closely related to the database structure, this will almost certainly lead to a system crash. those. when you join 2 tables, one ceases to exist, all the code that includes that now the unsafe table fails until it is modified (in terms of db, imagine that you are linking to any of the tables in 1: 1, when you delete these tables, it breaks the relationship, and therefore the structure needs to be changed a lot to compensate.Unfortunately, such bad projects are much easier to detect in the database world than in the software world in most cases, and you usually don’t notice that something went wrong so in code until everything falls apart) if the system is not properly designed with separation of problems .
This is the closest thing you can get for inheritance in object-oriented programming. But this is not quite the same.
One to Large (1: M) / Several to One (M: 1): These two relationships (e.g. 4 become 3) are the most popular types of relationships. They are both the same type of relationship, the only thing that changes is your point of view. Example. The customer has many telephone numbers, or, alternatively, many telephone numbers may belong to the customer.
In object-oriented programming, this will be considered a composition. This is not inheritance, but you say that one element consists of many parts. This is usually represented by arrays / lists / collections, etc. Inside classes, not inheritance structure.
Many for many (M: M): This type of relationship with existing technology is not possible. For this reason, we need to break it into two relations between each other and their association with the "association" table. Many parties from two to several relationships are always in the table of links / links.
For your example, the person who said you need a lot for many is right. Because from two to many there are effectively a lot (which means more than one) for many relationships. This is the only way to make your system work. If you are not going to explore the field of relational calculus to find a new type of relationship that would allow this.
You also have two options for such relationships (m2m): either create a compound key in the linker table so that the combination of fields becomes a unique entry (if you are interested in db optimization, this is a slower choice, but it takes up less space). Alternatively, you create a third field with an auto-generated id column and make it the primary key (for db optimization, this is a faster choice, but takes up more space).
In your example, specifically above ...
Examples of the real world are telephone numbers, users, and companies. A company can have many phone numbers, a user can have many phone numbers, but ideally the user should not provide the same phone number as the company, since the database will have duplicate content.
This would be a many, many relationship with a phone number table as a linker table between companies and users. As explained, to make sure the phone number is not repeated, you simply set it as a primary key or use a different primary key and set a unique phone number field.
For such questions, it really is how you express them. What makes you confused about this, and how you will overcome this confusion, to see the solution is simple. Rephrase the problem as follows. Start with the question - this is one to one, if the answer is no, go ahead. Then ask, this is one for many if the answer does not move on. The only remaining option is a lot. Be careful, make sure that you carefully consider the first two questions before moving on. Many inexperienced database users often complicate issues, ranging from one to many, like many of many. Again, the most popular type of relationship today is one for many (I would say 90%), from many to many and from one to one, with the remaining 10% 7/3. But these numbers are just my personal perspective, so do not quote them as industry standard statistics. I want to make too much confidence that this is definitely not one for many, before choosing many for many. It is worth the extra effort.
So now, to find the linker table between them, determine which of them are your main tables, and which fields should be shared between them. In this case, the tables of companies and users must share the phone. Hense you need to make a new phone table as a linker.
The warning signal of misunderstanding should show as soon as you decide that none of them work for you. This should be enough to tell you that you are simply mis-formulating the relationship issue. Over time, you improve, but this is an important skill and really should be mastered as soon as possible for your own sanatorium.
Of course, you can also go to an object-oriented database, which will allow you to use a number of other relationships, called "hierarchical". This is great if you are thinking of becoming a programmer. But I would not recommend this because it is going to hurt your head when you start looking for ways to combine different types of relationships. Especially considering that there is no great need, since almost all databases in the world consist only of these three types of relationships, if they are not something special.
I hope this was a reasonable answer. Thanks for taking the time to read it.