Guldstrand Posted July 24, 2021 Share Posted July 24, 2021 What is the best way to store a few formats/types on different mass media? Like "vhs", "dvd", "blu-ray" for movies or "lp", "cassette", "cd" etc for music. Is it ok with an ENUM field with all types / formats or should I have a separate table just for these? (I already have a table with all genres.) Quote Link to comment https://forums.phpfreaks.com/topic/313426-enum-or-separate-table/ Share on other sites More sharing options...
Barand Posted July 24, 2021 Share Posted July 24, 2021 I am not a great fan of ENUM, preferring to have choices like your "media type" in a table with an id, and store the id in the data table as a foreign key. Having such values in a table makes it easy to form a list of choices for the user, a task which is a PITA if the values are stored as enum. Quote Link to comment https://forums.phpfreaks.com/topic/313426-enum-or-separate-table/#findComment-1588567 Share on other sites More sharing options...
requinix Posted July 24, 2021 Share Posted July 24, 2021 Every time you need a new format you'll have to modify your table schema. That's not a good thing. There is no exhaustive list of formats you can rely on, which means you are coming up with this list on your own and deciding "yeah, I think that's all of them". That's not a good thing. If there's 20 different media formats then you've got an ENUM with 20 different entries. That's not a good thing. It's the same problem as you had with the list of genres. 1 Quote Link to comment https://forums.phpfreaks.com/topic/313426-enum-or-separate-table/#findComment-1588570 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.