I keep on encountering this performance anxiety when building out the database structure of my projects. I'm hoping to get an outside opinion on the matter.
Which approach would you say is better when building a large scale project?
Option A. 1 large table with many columns, or
Option B. Break data up into 2 small tables with few columns, but linked with ids.
Here is an example:
Say you are building a project that showcases things to do in an area. We will call these Activities. You have an index page that list all the Activities as cards/thumbnails. Simple data that is just the Activity Title and the Activity Image.
When you view the single Activity page, there are ~20 more columns worth of data that you want to show about the activity. ie. Description, how physically demanding it is, it's location, is it indoor or outdoor, is it family friendly. etc.
Lets also say there are many places throughout the site where you would see the simple cards for the activity (title and image only). but only one time you would need all the details (when viewing the single activity page).
Which is better?:
Option A (single table)
Activity Table
-----------------------------------------------------------------------
id
title
image_id
status
description
physical_level
environment
family_friendly
location_id
start_date
end_date
start_time
Option B (multiple tables)
Activity Table
-----------------------------------------------------------------------
id
title
image_id
status
Activity Details Table
-----------------------------------------------------------------------
id
activity_id
description
physical_level
environment
family_friendly
location_id
start_date
end_date
start_time
end_time
Does it take more cpu to join tables or more to select columns in tables?
What is better for searching, if say we were wanting to search for activities based on environment field?
What is better to query with?
Option A: Activity::select(['id', 'title', 'image_id'])->all() for querying activities on index page and Activity::find($id) for querying activity for single/show page.
Option B: Activity::all() for querying activities on index page and Activity::with(['activityDetails']) for querying activity for single/show page.
I appreciate any advice