Photo Database Need Help

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
maboroshi
Forum Commoner
Posts: 25
Joined: Thu Nov 13, 2003 10:10 am

Photo Database Need Help

Post by maboroshi »

Well I have to say my biggest learning curve has been mysql. Mostly because all that data normalization stuff does not intrigue me to much.

I have been messing about with building a MySQL Database for photos. I tried using the binary method for storing images into a database (that failed). Please note I am not asking about this method I am specifying a path in my db

What I would like to be able to do is build a table that has:

a category for images so I was thinking category_id int not null auto_increment primary key, a category_description text not null, here is where I am having problems, thumbnail_path varchar(255) not null, and photo_path varchar(255) I would have to build another table for the images themselves my problem is how they relate I am not really understanding that part.

so I build that table category_id int not null auto_increment now what would go after that would it be thumbnail_id or photo_id, or what. Am I just completely lost with this whole concept

any help is always appreciated
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

They relate in one to many fashion I guess: many images belongs to the same category and each image belongs to exactly one category.So include category_id int into your images table structure and set it to id of corresponding category for each image.

Ask me tomorrow or later, if my explanation isn't clear enough. I'm little sleepy now :roll:
maboroshi
Forum Commoner
Posts: 25
Joined: Thu Nov 13, 2003 10:10 am

Hey Thank You

Post by maboroshi »

Hey Thanks I was able to figure it out
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post by McGruff »

A good, normalised design really is essential. http://www.oreilly.com/catalog/javadtab ... r/ch02.pdf
maboroshi
Forum Commoner
Posts: 25
Joined: Thu Nov 13, 2003 10:10 am

Hey Cool

Post by maboroshi »

Hey thanks for the link

if you are interested this is what my table structure looks like

create table categories ( category_id int not null auto_increment primary key, category_description varchar(255), key category_id(category_id));

create table images (image_id int not null auto_increment primary key, image_title varchar(50), image_description text not null, thumb_path varchar(255), image_path varchar(255), category_id int not null default '0' );

to me it does not look like there is going to be repeat data let me know what you think


Cheers
Post Reply