Stupid question...

Discussion in 'General Marketing' started by kuepper, Jul 18, 2006.

  1. #1
    How does an app like del.icio.us add tags to urls. They must have two tables in a database, tags and urls, but how do they associate tags with urls and visa versa?
     
    kuepper, Jul 18, 2006 IP
  2. T0PS3O

    T0PS3O Feel Good PLC

    Messages:
    13,219
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Could be with a third table, a lookup table:

    Table Tags:

    ID - Tag Name
    1 - Apple
    2 - Digital Point

    Table URLS:
    ID - URL
    1 - http://www.microsoft.com
    2 - http://www.apple.com
    3 - http://forums.digitalpoint.com
    4 - http://www.digitalpoint.com/tools/

    Table Lookup:
    Tag ID - URL ID
    1 - 2
    2 - 3
    2 - 4

    Now if they want to display all the Digital Point tagged URLs:

    SELECT url FROM table_urls LEFT JOIN table_lookup ON table_urls.id = table_lookup.url_id LEFT JOIN table_tags ON table_lookup.tag_id = table_tags.id WHERE table_tags.name = 'Digital Point';

    Result:
    http://forums.digitalpoint.com
    http://www.digitalpoint.com/tools/
     
    T0PS3O, Jul 18, 2006 IP
  3. kuepper

    kuepper Peon

    Messages:
    80
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks - exactly what I was looking for!
     
    kuepper, Jul 18, 2006 IP