Database Management
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesDatabase Management

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today!
  #1  
Old August 31st, 2003, 08:06 AM
robertliu robertliu is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 1 robertliu User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Simple database for photo gallery - need help

I'm trying to create a photo gallery for my website using PHP & MySQL.

However, I'm getting a little confused on how to set up my database.

Here's what I got so far:

============================================
Table 1: photos_image
-----------------------------

image_no - primary key
comment - text to accompany image
filename - filename of image
directory - links to which gallery image belongs to


Table 2: photos_gallery
-----------------------------
directory - primary key (Each gallery will be in separate folder)
gallery_name - name of gallery (User friendly name to display to user)
============================================

What I want it to do is when a user selects a certain gallery from a drop down list, a page will load up with the images of the associated directory name.

I have all the images listed in one table, (which would realistically contain more than 250 images - but still allowing for expansion so up to 10000), and would be searching through the image table, and matching the directory name for the gallery selected. Is this the most efficient way to do what I'm trying to do? {did i make any sense?}

or would it be better to have one table per gallery? - in this case is there a limit to the number of tables allowed per database?

Any better ideas?
Thanks

Reply With Quote
  #2  
Old August 31st, 2003, 09:12 AM
mitakeet's Avatar
mitakeet mitakeet is offline
Last Day: May 28, 2005
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Jul 2003
Location: Maryland
Posts: 4,575 mitakeet User rank is Sergeant (500 - 2000 Reputation Level)mitakeet User rank is Sergeant (500 - 2000 Reputation Level)mitakeet User rank is Sergeant (500 - 2000 Reputation Level)mitakeet User rank is Sergeant (500 - 2000 Reputation Level)mitakeet User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 8 h 5 m 34 sec
Reputation Power: 20
Access time (as measured by page reads) is a function of indexes. If you have a value in your where clause you should consider indexing it. I say CONSIDER because indexes have overhead associated with it on inserts, updates and deletes. However, if you are only retrieving rows, you should index all the columns that you are querying against (most databases support indexing multiple columns). You should consider indexing 'directory' so that you can show just those values for a gallery and image_no so you don't have to do a table scan once the user has selected a given image.

There is no benefit to putting the data in separate tables unless you do massive updates and deletes against only a single gallery (by massive, I am talking a minimum of a couple of thousand rows). I once built a database where I had multiple nearly identical data sources, but they would be updated independantly. I had one table for each data source so I could do a simple truncate and bcp for a given source and not have to deal with logging all those (millions of) transactions.

Your database sound like it is not potentially large enough to have performance issues, so just leave it in a single table and build the appropriate indexes.
__________________

Left DevShed May 28, 2005. Reason: Unresponsive administrators.
Free code: http://sol-biotech.com/code/.
Secure Programming: http://sol-biotech.com/code/SecProgFAQ.html.
Performance Programming: http://sol-biotech.com/code/PerformanceProgramming.html.

It is not that old programmers are any smarter or code better, it is just that they have made the same stupid mistake so many times that it is second nature to fix it.
--Me, I just made it up

The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man.
--George Bernard Shaw

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesDatabase Management > Simple database for photo gallery - need help


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway