M
M
Maxim Dyachenko2017-10-13 15:19:56
MySQL
Maxim Dyachenko, 2017-10-13 15:19:56

How to properly design the database: one user - many galleries - many images?

I want to make the following functionality, I have a user who can create a certain number of galleries (the gallery can have a name, selfnail), a certain number of pictures can be stored in each gallery.
As I imagine it, there is a user(user_id primary) table, when the user creates a gallery, I create a table (gallery_id primary, user_id, gallery_name, gallery_thumb), and when the user uploads images to the gallery, I create another table (img_id primary, gallery_id, img_name).
Is this the right decision? After all for each user 2 tables are created.
Thanks to all!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Fedorov, 2017-10-13
@jdun_developer

As I imagine it, there is a user(user_id primary) table, when the user creates a gallery, I create a table (gallery_id primary, user_id, gallery_name, gallery_thumb), and when the user uploads images to the gallery, I create another table (img_id primary, gallery_id, img_name)

The structure is correct, but why create a separate table for each user? store all galleries in one table, just like images

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question