Answer the question
In order to leave comments, you need to log in
What is the structure of the database for storing phones of people and companies?
There is a contact table for people and a contact table for companies.
A person can have several phones
A company can have several phones
One phone can have only one owner - a person or a company.
What is the best structure for this task? How to link tables of phones and contacts?
Found a similar question How to store phones in the database?
Is there a separate table with phone numbers for people, a separate table with phone numbers for companies? What other options are there? Or is this the best option?
Answer the question
In order to leave comments, you need to log in
Questions about the physical model:
According to the physical model, we can offer:
SELECT Company.Name AS CompanyName,
Person.Name AS PersonName,
PhoneStorage.Description,
Phone.Number,
Phone.Description AS PhoneDescription
FROM PhoneStorage
INNER JOIN Phone ON PhoneStorage.Phone = Phone.ID
LEFT OUTER JOIN Person ON PhoneStorage.Person = Person.ID
LEFT OUTER JOIN Company ON PhoneStorage.Company = Company.ID
ORDER BY Phone.Number, PersonName
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question