Thread: DB structure

    #1
  1. For POny!
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2012
    Location
    Amsterdam
    Posts
    416
    Rep Power
    115

    DB structure


    Hi guys,

    Say I would like to track hits on products or articles
    Would you create an extra table to store these hits (with articleID as foreign key), or just put them in the article table itself?

    Something tells me the last option makes most sense,
    since an article can have only 1 sort of hits and in that way its a one to one relationship. Hmm typing this I am almost certain this is correct anyone wanna agree or disagree?

    Code:
    article table     
    ------------ 
    articleID           
    hits
    
    VS
    
    article table   hits table
    ------------   +  ----------
    articleID          articleID
                        hits
  2. #2
  3. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,146
    Rep Power
    4274
    you're fine for articles

    where are the produict hits going to go?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
  4. #3
  5. For POny!
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2012
    Location
    Amsterdam
    Posts
    416
    Rep Power
    115
    Originally Posted by r937
    you're fine for articles

    where are the produict hits going to go?
    Hi r937

    I should have been more precise. for article and products I use the same structure. So the hits are bound to 1 product. I assume an extra table is not required than since its a 1-to-1 relation.

    For instance each time someone views a product it's hitrating increases.

IMN logo majestic logo threadwatch logo seochat tools logo