Results 1 to 4 of 4

Thread: Tag schema

  1. #1
    Join Date
    Sep 2005

    Unanswered: Tag schema


    I'm trying to mirror a delicious type schema in MS-SQL - so far I have three tables. One for tags, one for bookmarks and one to join the two together.

    Bookmark holds the URLS
    Tag holds the Tags
    TagMap holds the Bookmarks and Tags.

    SELECT b.*,COUNT(*) As Count,
    FROM TagMap bt, Bookmark b, Tags t
    WHERE bt.TagID = t.ID
    AND b.ID = bt.BookmarkID
    GROUP BY b.ID,b.Description,b.BookmarkURL,b.userID,b.Date,t .tagName

    My question is.

    1). is there a better way than this?
    2). If I'm listing all my bookmarks, with all their associated tags ala delicious what would my query look like? Perhaps this isn't possible with my existing schema - and the server side programming code should filter the results. Yes / No?

    Just looking for some feedback on sql logic?

  2. #2
    Join Date
    Apr 2007
    What is your query trying to accomplish?
    Microsoft SQL Server MVP

    N 5604'39.26"
    E 1255'05.63"

  3. #3
    Join Date
    Sep 2005

    Replicate the delicious home page.
    here's what in a perfect world I'd like my rows to look like:

    URL, saveCount, TAGS, 5, 'one,two,Three'

    with the schema as it is. - for an example.

  4. #4
    Join Date
    Apr 2002
    Toronto, Canada
    Quote Originally Posted by paul_anthony
    Bookmark holds the URLS
    Tag holds the Tags
    TagMap holds the Bookmarks and Tags.
    my own take on this is that the bookmarks and tagmap table are necessary, but the tags table is optional

    optional if you want to allow users to add their own tags ("folksonomy"), and mandatory, for relational integrity, if you want only pre-authorized tags to be used

    for more ideas, see

    feel free to post again if you have more questions | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

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