Please help me setting up a database structure.

Discussion in 'Databases' started by retry, Apr 11, 2009.

  1. #1
    Hi.

    I need some help setting up a structure. It's just "logic" really, however I can't seem to think clearly today.

    Anyway, I'm building a script which cathes a rss feed hourly. It's really a simple feed with 50 new lines(words phrases) each hour. I would like to save this to a sql server.

    I will need to be able to compare this lists(a list is the 50lines I get every hour) as easy as possible.

    Do you have a suggestion how you would set it up?

    Thanks in advance.

    Kindly regards

    Retry
     
    retry, Apr 11, 2009 IP
  2. crivion

    crivion Notable Member

    Messages:
    1,669
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    210
    Digital Goods:
    3
    #2
    to compare with what?
     
    crivion, Apr 12, 2009 IP
  3. weboweb

    weboweb Peon

    Messages:
    25
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    If I understand correctly, every hour a new feed item is added, and each item contains its own set of 50 lines. If this is the case, I'd set it up like so:

    feed_items
    ========
    id (auto increment)
    date (timestamp or int(10))
    title (varchar 100)


    item_lines
    ========
    id (auto increment)
    feed_item_id (foreign key to feed_items.id)
    content (varchar 100)

    Then in your programming language, retrieve the feed, grab the contents of the latest RSS item and split each row of text into an array. You would then insert the data using something along the lines of the following pseudocode:

    INSERT INTO feed_items(date, title) VALUES ( '${time()}', '$title');

    $feed_item_id = SELECT LAST_INSERT_ID();

    INSERT INTO item_lines( feed_item_id, content) VALUES
    ($feed_item_id, 'line one'),
    ($feed_item_id, 'line two'),
    ($feed_item_id, 'line three')

    And so on.
     
    weboweb, Apr 12, 2009 IP
  4. T.Guru

    T.Guru Peon

    Messages:
    78
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    So yes, you will need to tell us on what you want to do the comparison. And also how you want to compare those two databases. We'll then be more able to help you out.
     
    T.Guru, Apr 16, 2009 IP