Tuesday, February 23, 2010

Database planning - ER diagram and query thoughts

ER Diagram
So, with some refreshing to help out my memory of CIS 330 material, I have constructed a first-draft entity-relationship (ER) diagram for the database.  I'm the slightest bit iffy on whether I've indicated the participation and many-to-one constraints via the correct notation; see the legend (added mainly for my own reference) for my understanding of it.  I also can't remember if foreign keys should be indicated--I seem to recall that they should be given a dashed underline, but I left that out because I'm not sure.  At any rate, I've unconventionally included a bunch of extra notes (including mentions of the foreign keys) to provide further explanation and clarification.

Additional iterations and modifications of this setup are of course likely to occur.  I will try to post updated diagrams as they do.  (Maybe I'll make this into an Illustrator file, but for now, it was easiest for me to work it out in my head and put it directly onto paper.)

Please please click on the image to see it in full size... it's quite difficult to read at the embedded size.


Queries
While I'm thinking about it, here's a very preliminary and unfinished list of SQL queries I'll need to figure out...  (Capitalized terms are entity names; terms in single quotes are attribute names.  I don't know if that's correct syntax, but it's simple notation for myself and readers.)
  • Get all Users currently logged in but not playing a game
  • Get all default Tracks
  • Get all Tracks created by a User
  • Get all Tracks... [should I allow access to tracks created by other users?]
  • Create a new Track - store the 'filepath', associate with a 'creator' = User.fb_id
  • Create a new Game - associate a Track, a User.fb_id as organizer, and 'in_play' = false
  • Add Users (unconfirmed) to a game - 'joined' = false
  • Confirm a User's participation in a game - set 'joined' = true
  • Set (update) a player's position on the game board grid - change 'xpos' and 'ypos' for given User.fb_id
  • Get the player whose turn it is now/next
  • Delete a Game when it's finished - this will include removal from Game table and all entries with that Game.id in player_group

No comments:

Post a Comment