Storing column for data that doesn't exist for majority of rows
3
votes
1
answer
139
views
I'm using mariadb.
I have a single table that keeps track of
video_count
and image_count
for a few different sites. I.e.
type | enum('SITE1','SITE2','SITE3')
video_count | int(11)
image_count | int(11)
video_count
will exist for ALL sites but image_count
only exists for SITE3
. Also, SITE3 will be a minority of rows.
So does it make sense to arrange the data this way on one table?
I'd like to query ALL rows...but is it a problem if it's redundant and expensive knowing that 90% of my rows will have 0
for image_count?
It'd be perfect if I could do something like SELECT * from TABLE BUT DON't GET video_count WHERE type != 'SITE3'"
Is that even a possible query in SQL? Or does it now make sense to create separate tables for 'SITE1...SITEN'? Ty!
Asked by user2402616
(211 rep)
May 27, 2022, 07:16 PM
Last activity: May 27, 2022, 10:48 PM
Last activity: May 27, 2022, 10:48 PM