Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Database design for a private message system

Database design for a private message system

Scheduled Pinned Locked Moved Database
rubydatabasedesigngame-devquestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Joshua Tully
    wrote on last edited by
    #1

    So im designing a pm system for a game written in Ruby/On Rails and not quite sure how i would design the database side of the game to facilitate the desired features. The general message system looks like Table: users int userid ~ extra Table: messages int messageid int authorid longtext message datetime timestamp Table: message_to int key int messageid int recieverid What I'm looking to add is essentially custom folders. Meaning a user could create a "Diplomatic" folder and have the message appear under that folder. How would one go about facilitating the association between a message and a folder?

    W 1 Reply Last reply
    0
    • J Joshua Tully

      So im designing a pm system for a game written in Ruby/On Rails and not quite sure how i would design the database side of the game to facilitate the desired features. The general message system looks like Table: users int userid ~ extra Table: messages int messageid int authorid longtext message datetime timestamp Table: message_to int key int messageid int recieverid What I'm looking to add is essentially custom folders. Meaning a user could create a "Diplomatic" folder and have the message appear under that folder. How would one go about facilitating the association between a message and a folder?

      W Offline
      W Offline
      Wayne Gaylard
      wrote on last edited by
      #2

      You need to create a table for folders i.e. Table: folders int folderid text name and then in meesages table add int folderid. Then when you access a message you know which folder it belongs to.

      J 1 Reply Last reply
      0
      • W Wayne Gaylard

        You need to create a table for folders i.e. Table: folders int folderid text name and then in meesages table add int folderid. Then when you access a message you know which folder it belongs to.

        J Offline
        J Offline
        Joshua Tully
        wrote on last edited by
        #3

        Yes but that doesn't hand ownership of folders would one do Table: Folders int folderid varchar foldername int userid the do something like SELECT foldername FROM table WHERE userid="x";? then look into messages with SELECT message, folderid FROM table WHERE receiverid="x"; then output based on folder?

        W 1 Reply Last reply
        0
        • J Joshua Tully

          Yes but that doesn't hand ownership of folders would one do Table: Folders int folderid varchar foldername int userid the do something like SELECT foldername FROM table WHERE userid="x";? then look into messages with SELECT message, folderid FROM table WHERE receiverid="x"; then output based on folder?

          W Offline
          W Offline
          Wayne Gaylard
          wrote on last edited by
          #4

          Sorry, didn't get the part about folder ownership. This how I would set it up Tables: folders: id int name varchar userid int messages: id int fromid int toid int message varchar(250) messagedate datetime folderid int users: id int name varchar Then when you want to look up all messages from one person (say his id is 1) to another person (id = 2) in a particular folder (say id = 1) you would have a query like this

          SELECT
          m.message
          FROM
          messages m
          INNER JOIN
          folders f
          ON
          m.folderid = f.id
          WHERE
          m.fromid = 1
          AND m.toid = 2
          AND f.id = 1;

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups