Skeletor Skeletor - 1 year ago 40
PHP Question

Should I separate the "files" table to "audios", "images" and "documents" or should all be in one place?

I have a File model and of course files table for uploaded files. They are separated by a "type" column and are used in different places like gallery and player.

id | name | type | mime ...
0 | nature | image | image/jpeg
1 | desert | image | image/jpeg
2 | jazz | audio | audio/mp3
3 | pop | audio | audio/mp3

I was thinking if it would be better to create separated models, controllers and tables, or should I use it all in one. I can't decide which system would be more efficient.

Answer Source

I decided to used them separated and so I did. But after a while I needed videos and documents too. I had to create for each type new model, controller and views, which was not quite convenient. So my decision changed. I guess it would be better to use only file model for all media types.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download