Jump to content


Photo

How should I set up the Database?


  • Please log in to reply
6 replies to this topic

#1 lpxxfaintxx

lpxxfaintxx
  • Members
  • PipPipPip
  • Advanced Member
  • 181 posts

Posted 05 March 2006 - 02:49 AM

I am using PHP-Fusion. I want to make it so that EVERY registered user has its OWN uploader and its OWN photo gallery. How should I set up the database so that each individual user has its own column? Should I create a new table, or should I insert a new field? How would the database work? Will it create a new field for every new uploaded file? AH! I'm getting so frustrated.

Please Help,
lpxxfaintxx

I really am desperate.

#2 lpxxfaintxx

lpxxfaintxx
  • Members
  • PipPipPip
  • Advanced Member
  • 181 posts

Posted 05 March 2006 - 11:17 AM

Maybe I might not have made it clear enough. If you want more info, please tell me.

#3 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,017 posts

Posted 05 March 2006 - 11:35 AM

Basically you need 2 tables, one for users and one for image filenames

user          gallery
=========     =======
userID  --+   galleryID
username  +-- userID
pwd           imagefile

When a user uploads an image file, add a new reocord to the gallery table with the user's id and the filename. Store the uploaded file in, say, "/images/username/filename.jpg".

A search on userID in the gallery table will pull that user's filenames.
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#4 lpxxfaintxx

lpxxfaintxx
  • Members
  • PipPipPip
  • Advanced Member
  • 181 posts

Posted 05 March 2006 - 01:27 PM

What if the users wanted to make categories?

#5 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,017 posts

Posted 05 March 2006 - 08:51 PM

Third table, category, and add category id to gallery records

user          gallery         category
=========     =======         ==========
userID  --+   galleryID  +---  catID
username  +-- userID     |     cat_name
pwd           imagefile  |
              catID  ----+

If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#6 lpxxfaintxx

lpxxfaintxx
  • Members
  • PipPipPip
  • Advanced Member
  • 181 posts

Posted 05 March 2006 - 09:12 PM

Sorry to sound like a noob but what does “----+” mean?

#7 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,017 posts

Posted 05 March 2006 - 09:20 PM

It's just to illustrate the foreign key/primary key joins in the database.
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users