Answer the question
In order to leave comments, you need to log in
What is the best way to organize database table schemas (contacts-persons-companies)?
I think how best to organize the tables.
Essence: A repository of entities that can be persons or companies, some of which provide construction services, some legal. Each entity can have 0 or more phones, emails, and other means of communication. Number of about 500,000 entries.
It is necessary to organize the output of persons, companies, search, in all fields, checking and combining duplicates by mail / phone, etc. search by phone / email for the withdrawal of both companies and persons, by company the ability to see the persons associated with it. Synchronization with another database - if this phone / email has a connection, etc. is_builder = 0, and they have is_builder = 1, then during synchronization we change it to is_builder = 1, I don’t know where this field is better for a person or storage
Plans for organizing tables
Tablecontacts
Answer the question
In order to leave comments, you need to log in
We close the issue with duplicate Yandex emails - we stop at checking and bringing it to ya.ru while saving it to the database.
With the rest, especially with the separation of entities, it remains unclear.
Including: It is
necessary to organize the output of persons, companies, search, in all fields, checking and combining duplicates by mail / phone, etc. search by phone / email for the withdrawal of both companies and persons, by company the ability to see the persons associated with it. companies
Synchronization with another database - if this phone / email has a connection, etc. is_builder = 0, and they have is_builder = 1, then during synchronization we change it to is_builder = 1, I don’t know where this field is better for a person or storage.
So, in short, how is it better to design a database
Table - contact
Tables - contact_person and contact_company
Tables - contact_phone, contact_email and contact_social
I correctly understood that in order to perform these tasks, make a bunch where the main contact is, and from it go for example contact_person and contact_phone
--- Added on 01/24/2018 ---
In general I decided to do this for myself, I can share it with someone who can help
Table - contact for a bunch
In it is a type (person / company) and its ID
C on the other side is a type (phone / email / social) and its ID
1. It is customary to name entities in the singular.
Contact has only shared fields. Additional in contact_person and contact_company (PK is FK).
2. Transliterated: inn, kpp, okpo, opf
3. Mobile/work - different store_contact.type
4. Phones all converted to a single E.164 format before insertion into the database
5. Email all converted to a single format (in lowercase and, possibly with the replacement ya.ru) before inserting into the database
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question