Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the best SQL scheme for this project?

Tags:

sql

php

i want to make a php app that let people submit photos/videos/sounds

Now, everything uploaded a record will be added to SQL database with file infos in this way:

Photos_table : File_Name | Picture_Type | Picture_Width | Picture_height

Videos_table : File_Name | Duration | Codec

Sounds_table : File_Name | Bitrate | Duration | Codec

The App will displays all recent items of all kinds. Is it good to do like the previous scheme, or making all infos in ONE table like this :

File_Name | Picture_Type | Picture_Width | Picture_height | Duration | Codec | Bitrate

I mean what's the fastest way to gather the infos, i just think the first scheme is more organized than the last one.

Thanks

like image 929
CodeOverload Avatar asked Mar 05 '10 20:03

CodeOverload


People also ask

How is SQL used in projects?

SQL makes it more effortless to interface with databases and structure a management information system. SQL Server Integration Services is very useful for huge companies having a huge amount of data to store and manage.


2 Answers

Definitely not all in one. If you are uploading media then I would create a table of all media:

Media_table: ID | MediaPath | ETC

Photos_table : MediaID | Picture_Type | Picture_Width | Picture_height

Videos_table : MediaID | Duration | Codec

Sounds_table : MediaID | Bitrate | Duration | Codec

Look into database normalization.

like image 164
Dustin Laine Avatar answered Sep 20 '22 04:09

Dustin Laine


There will not be a big performance difference. However, using your second method does denormalize your database a bit which is considered bad practice.

like image 39
Ben Hoffman Avatar answered Sep 22 '22 04:09

Ben Hoffman