homepage Welcome to WebmasterWorld Guest from 54.237.38.30
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / Databases
Forum Library, Charter, Moderator: open

Databases Forum

    
Database design for download presets
tunafish



 
Msg#: 4201689 posted 4:00 pm on Sep 14, 2010 (gmt 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 |

 

rocknbil

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



 
Msg#: 4201689 posted 3:56 pm on Sep 16, 2010 (gmt 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.

tunafish



 
Msg#: 4201689 posted 4:08 pm on Sep 16, 2010 (gmt 0)

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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Databases
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved