Instant Messaging Database buddy relationship (One-to-many) how to design.
Question 1:
For example, the number of an account, age, sex, description, etc. with a table can be fully accommodated, but each account has a lot of friends, friends put this table is not too good to do it?
Do you want to create a new table for each account to store friends?
Question 2: If this is not a friend but a gift number. I am the landlord, the landlord's friend, I want to send gifts to the landlord's friends. (Pending solution)
Ask 1 to solve:
To create a buddy relationship table.
Explain who is the best friend, which in turn is not tenable.
According to the behavior of QQ, if I am LZ (landlord) friend, then there is a relationship: I->lz (landlord)
LZ is my good friend, there is:lz-> me
If we're friends, there's:lz-> me and Me->lz
If it's big, the buddy table needs to be divided into tables. For example: 1-1000 of friends are stored in a table, 1001-2000 of friends are stored in table B.
As for the table, see your IM system capacity and the performance of the database you use.
Each account must have a system-recognized ID (generally used for shaping (2, 4, 8 bytes))
A buddy table is a combination of these IDs, usually 2-3 plastic fields, and a clustered index by the initiator ID.
Such a table, though a lot of records, absolute capacity is not very
1 (User basic information table, embedded ID) on multiple (Friend relationship table, Id&id ...) )
Pending solution.