Jump to content

gizmola

Administrators
  • Posts

    5,878
  • Joined

  • Last visited

  • Days Won

    139

Posts posted by gizmola

  1. this is driving me mad, been trying to formulate one SQL query for 2 days now, please someone put me out of my misery!

     

    Doing a query on 2 tables:-

     

    messages table.

    ID // key field, int

    threadID // key field of thread this message is in

    title, body, etc. // stuff

     

    unreadmessages table

    ID // key field

    msgID // corresponds to the ID of a message record

    threadID // key field of thread this message is in

    userID // userID - indicates the user hasnt yet read the associatde message record.

     

     

    Speaking of headaches, I have a huge one at the moment, and I must confess I\'m not up to the task of scrutinizing your code, but I do have a kneejerk reaction to this design.

     

    IMNSHO, I feel you should have a table called msgread. When a reader reads a message, insert a row into this table, as oppossed to your current design. The first and most obvious reason for this is:

     

    1. WHen you start you have let\'s say 10 users. There\'s let\'s assume 500 messages in the forum. Now user 11 signs up. Are you going to have the system go out and add Didnotread rows for all 500 messages? Ouch. Based on the way forums are used, I think it\'s a much better design, not to mention, one that spreads the transaction load, to simply add a row to a readmsg table when someone pulls up a message.

  2. If you mean lookup values, I\'m prejudiced towards keeping that type of stuff in the database. This is what is generally referred to as having a \"data driven\" design.

     

    In general small tables like these should be cached by the database, and retrieval is as close to instantaneous as the database can be. There are many different things that can become a bottleneck in an application, and I\'ve found it\'s best to create the system first, then tune around the bottlenecks, rather than to assume you know what the bottlenecks will be and start making design decisions based around those assumptions.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.