Issue
I am making a gallery website. I learnt from tutorials how to do each parts but i don't know if i should make different tables for user information / their profile pictures / and photos added to gallery by users. Should I focus to make lowest number of tables possible (like putting profile pictures and photos together in table) or making different tables for everything. Does is affects speed of website?
I am using XAMPP and procedural PHP.
Solution
The rule of thumb is always identify separate entities (things) and put them in a separate tables. Think about relations between these entities:
- Photos belong to galleries,
- Photos belong to users,
- Galleries might be owned by one or more users ect.
(These are only examples - maybe it is different in your case)
This way you will start thinking naturally using relational database concepts.
The next step is to identify what type of relation exist between these entities. And so:
- User can have many photos but a single photo is owned by single user (one to many relation or 1:n)
- User can have many galleries, and each gallery can be owned by many users (many to many relation or m:n)
Based on the above you can then create "connections" between these tables of things using so called foreign keys. Read more about simple relational database design and you'll be fine.
Regarding speed. Don't worry about it for now. The database is designed to allow us to create many different related tables of things and it is highly optimized to do so. You can worry about optimizations once you'll reach millions of items in your tables.
Answered By - Jarek.D
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.