Welcome to WebmasterWorld Guest from 54.167.202.184

Forum Moderators: open

Message Too Old, No Replies

Database design for download presets

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

New User

5+ Year Member

joined:Feb 11, 2010
posts: 14
votes: 0


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 |
3:56 pm on Sept 16, 2010 (gmt 0)

Senior Member

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

joined:Nov 28, 2004
posts:7999
votes: 0


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.
4:08 pm on Sept 16, 2010 (gmt 0)

New User

5+ Year Member

joined:Feb 11, 2010
posts:14
votes: 0


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

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members