SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Guru
    Join Date
    Aug 2004
    Location
    Taunton, UK
    Posts
    787
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Database design advice

    I could do with some advice on the structuring of my database.

    My site is an accommodation site and it has 3 levels of advertising. Each advertising level allows the user to add a different number of photographs to their listing.

    Bronze: 4 photos
    Silver: 8 photos
    Gold: 12 photos

    Currently I have a table in my database called "accommodation_tb" that contains all the information for each listing.

    I would like to know whether I should just have 12 photo fields in this table or to have a separate photo table with an accommodation id field that ties the photo to the accommodation table.

    Also do you think it is better to have 12 file input boxes as part of the form or to deal with adding photos separately?

    Thanks in advance

    Paul
    Mediakitchen Limited
    App Development | Website Design & Development | Flash Game Development
    Somerset, UK
    http://www.mediakitchen.co.uk

  2. #2
    SitePoint Addict Mastodont's Avatar
    Join Date
    Mar 2007
    Location
    Czech Republic
    Posts
    375
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    have 12 photo fields in this table
    No.
    have 12 file input boxes as part of the form
    It is an option, but I vote for second choice.

  3. #3
    SitePoint Guru
    Join Date
    Sep 2008
    Posts
    977
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you could have it like this

    accommodation_tb
    | accomm_id | accommodation name | etc |

    photos
    accomm_id (FK)| photo_name |

    Thne in your input form (for uploading the images) have an input box for each image.

    Then in your web page that displays the 12 images, query 'photos' using the accomm_id

    You should add CONSTRAINTS to 'photos' so that if an accommodation removes its listing, the photos are removed as well (or what happens to them is as determined by your constraint).


    bazz

  4. #4
    SitePoint Guru
    Join Date
    Aug 2004
    Location
    Taunton, UK
    Posts
    787
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Mastodont and IBazz - I am going to go with a separate photo table

    I am thinking that I will have an "Add Photos" admin page with the relevant number of image placeholder gifs displayed with a file input field below each.

    Rather than make them upload all 12 at once, do you think it is a good idea to have a button next to each file input saying "Upload" and therefore let the user upload each photo separately and display a thumbnail of the photo when it has uploaded or would you think it makes more sense to just let them browse for all 12 images then do the upload of all 12 at once?
    Mediakitchen Limited
    App Development | Website Design & Development | Flash Game Development
    Somerset, UK
    http://www.mediakitchen.co.uk

  5. #5
    SitePoint Guru
    Join Date
    Sep 2008
    Posts
    977
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    what if there aren't 12 photos? I would strat with individual uploads.


    bazz

  6. #6
    SitePoint Guru
    Join Date
    Aug 2004
    Location
    Taunton, UK
    Posts
    787
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the reply Ibazz - do you mean just have one file input on screen at once and let them upload one photo at a time until they reach their quota?

    I was thinking I could retrieve the number of photos they are allowed from the database based on the advertising package choice.

    So if they are allowed 12, I would have 12 dummy placeholders with file input boxes. If the user only wanted to add one photo, they would just complete one file input.

    If they leave the other 11 file inputs untouched, would I still be able to let them click "Submit" and just retrieve the details of the one they have chosen a file for?
    Mediakitchen Limited
    App Development | Website Design & Development | Flash Game Development
    Somerset, UK
    http://www.mediakitchen.co.uk

  7. #7
    SitePoint Guru
    Join Date
    Sep 2008
    Posts
    977
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    What I meant was that if they are able to uploaid all 12 but, choose to upload only 9 that your script might need to account for that. It is an issue I am approaching and that is my thought so far.

    sending pm to you

    bazz

  8. #8
    SitePoint Guru
    Join Date
    Aug 2004
    Location
    Taunton, UK
    Posts
    787
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmm that is my next hurdle. I am thinking I can dynamically generate the file input boxes then somehow pull out the image files from the ones the user completes. Hopefully that is possible?

    I have just read about something called swfupload that may help me though
    Mediakitchen Limited
    App Development | Website Design & Development | Flash Game Development
    Somerset, UK
    http://www.mediakitchen.co.uk

  9. #9
    SitePoint Addict Mastodont's Avatar
    Join Date
    Mar 2007
    Location
    Czech Republic
    Posts
    375
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    IMHO is not wise to offer so many input boxes. Let them add 1-3 images, confirm successful upload and then send form for another batch.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •