SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot
    Join Date
    Dec 2006
    Posts
    134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    The best way to go about adding "highlight" entries to a specific record

    If I have a table, lets say trip_information.
    Then for each trip there is are trip "highlights".
    Each "highlight" contains a title and a description.

    You don't know how many highlights there will be per trip, and you don't want to create one field in the table where someone would just paste HTML.

    How would one go about bulding a relational-setup where you can have such a thing? A great example is this:

    http://ca.contiki.com/tours/122-european-magic

    You see there's 'Trip Highlights' with a few pictures, a title, and a description. Surely all of these are not just HTML pasted into a field - right? :S

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,017
    Mentioned
    53 Post(s)
    Tagged
    2 Thread(s)
    there should be a one-to-many relationship between trips and trip_highlights

    one row per highlight, so you do not need to know how many there will be

    each highlight is related to the trip it belongs to with a foreign key
    r937.com | rudy.ca | Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Zealot
    Join Date
    Dec 2006
    Posts
    134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by r937 View Post
    there should be a one-to-many relationship between trips and trip_highlights

    one row per highlight, so you do not need to know how many there will be

    each highlight is related to the trip it belongs to with a foreign key
    So in the "trip_hightlights" there will be every single trip highlight entries no matter what the trip, its just a big general table of trip highlights and it's tied to each-other by the trip ID?

  4. #4
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,017
    Mentioned
    53 Post(s)
    Tagged
    2 Thread(s)
    yup
    r937.com | rudy.ca | Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  5. #5
    SitePoint Zealot
    Join Date
    Dec 2006
    Posts
    134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by r937 View Post
    yup
    Great, thanks!
    I guess then the same would go for the itinerary setup, like here:
    http://ca.contiki.com/tours/122-euro...agic/itinerary

    skipping the little pointer list, the detailed itinerary list of the days; same situation? Every single itinerary entry regardless of a trip will be stored in one table and each entry would be related to a trip by ID's.

    Thanks again r937/Rudy (i'll make that assumption based on your domain in your signature ), you've been a life-saver though this!


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
  •