Welcome to WebmasterWorld Guest from 54.147.20.131

Forum Moderators: open

Message Too Old, No Replies

Database design for download presets

     

tunafish

4:00 pm on Sep 14, 2010 (gmt 0)

5+ Year Member



Newbie with databases, I would like some advise please..
I have agencies who can download photo's.
Standard each agency can download "medium" & "large" photos.
Now from their account page I would like them to make extra custom presets and manage those.

I looked in the database of some blog software how they handle categories and wrapped my head around this example.
Is this the right approach?

Cheers


agency 1 has preset "medium" & "large"
agency 2 has preset "medium", "large" & "Bill custom"

-----------
| presets |
-----------
| preset_id | preset_name | preset_dimensions |
| 1 | medium | 800x600 |
| 2 | large | 3000x2000 |
| 3 | Bill custom | 640x420 |

----------------
| preset_assoc |
----------------
| presassoc_id | presassoc_preset_id | presassoc_agency_id |
| 1 | 1 | 1 |
| 2 | 2 | 1 |
| 3 | 1 | 2 |
| 4 | 2 | 2 |
| 5 | 3 | 2 |

------------
| agencies |
------------
| agency_id | agency_name |
| 1 | Joe ltd |
| 2 | Bill inc |

rocknbil

3:56 pm on Sep 16, 2010 (gmt 0)

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member



I would do this

| preset_id | preset_name | preset_dimensions |
| 1 | medium | 800x600 |
| 2 | large | 3000x2000 |
| 3 | Bill custom | 640x420 |

like this

// Somewhere in your programming,
// PHP
$sizes = ('small','medium','large','custom');

#perl
@sizes = ('small','medium','large','custom');

| preset_id | preset_name | preset_w | preset_h |
| 1 | 1 | 800 | 600
| 2 | 2 | 3000 | 2000
| 3 | 3 | 640 | 420

names would be accessed
$size_name = $sizes[$row[1]];

for both languages.

Two reasons. First numeric lookups will always be faster than textual ones. Second there is the eventuality (or likelihood) these values will be used in other areas of the programming to size or crop the images and you can access them directly rather than associating the textual values with the numeric ones.

tunafish

4:08 pm on Sep 16, 2010 (gmt 0)

5+ Year Member



That's a great tip there, thanks much for that!
 

Featured Threads

Hot Threads This Week

Hot Threads This Month