skip to Main Content

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.

2

Answers


  1. i think You Are beginner So you may learn more from here

    https://www.youtube.com/channel/UC8Nbgc4vUi27HgBv2ffEiHw

    Login or Signup to reply.
  2. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search