mysql - Problems with creating database tables?
仅有的幸福
仅有的幸福 2017-05-18 10:50:40
0
1
679

I am a novice and have designed a social networking website. For example, there is a table of user avatar pictures and a table of user album pictures. Should I build these two tables separately, or merge them into one table (different types The pictures are distinguished by the type field), what are the advantages of each?

仅有的幸福
仅有的幸福

reply all(1)
漂亮男人

Theoretically, two tables need to be separated. First, a user has only one avatar, so the relationship between user ID and avatar photo is 1:1;
For the same user and his album pictures, there is a 1:n relationship. , the avatar pictures and user albums each have their own tables, which are logically clear and easy to manage; both tables are associated with users using userId.
But in fact, from a database perspective, there is no difference between putting them in one table and putting them separately (maybe there will be a difference in query efficiency when the amount of data becomes large)
You create a picture table and calibrate it by Type in the picture table Whether it is an avatar or an album photo, you still need to set the userId in the picture table to identify who it belongs to.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template