Database model for a 24/7 Staff roster at a casino

浪子不回头ぞ 提交于 2019-12-01 01:15:22

Thanks for spending the time to put a quality question together. Your requirements are great and your specifications of your system are very detailed. I was able to translate your specs into a graph data model for Neo4j. See below.

Above you'll see a fairly explanatory graph data model. In case you are unfamiliar with this, I suggest reading Graph Databases: http://graphdatabases.com/ -- This website you can get a free digital PDF copy of the book but in case you want to buy a hard copy you can find it on Amazon.

Let's break down the graph model in the image. At the top you'll see a time indexing structure that is (Year)->(Month)->(Day)->(Hour), which I have abbreviated as Y M D H. The ellipses indicate that the graph is continuing, but for the sake of space on the screen I've only showed a sub-graph.

This time index gives you a way to generate time series or ask certain questions on your data model that are time specific. Very useful.

The bottom portion of the image contains your enterprise data model for your casino. The nodes represent your business objects:

  • Game
  • Table
  • Employee
  • Skill

What's great about graph databases is that you can look at this image and semantically understand the language of your question by jumping from one node to another by their relationships.

Here is a Cypher query you can use to ask your questions about the data model. You can just tweak it slightly to match your questions.

MATCH (employee:Employee)-[:HAS_SKILL]->(skill:Skill),
      (employee)<-[:DEALS]-(game:Game)-[:LOCATION]->(table:Table),
      (game)-[:BEGINS]->(hour:H)<-[*]-(day:D)<-[*]-(month:M)<-[*]-(year:Y)
WHERE skill.type = "Blackjack" AND 
      day.day = 17 AND 
      month.month = 1 AND 
      year.year = 2014
RETURN employee, skill, game, table

The above query finds the sub-graph for all employees who have the skill Blackjack and their table and location on a specific date (1/17/14).

To do this in SQL would be very difficult. The next thing you need to think about is importing your data into a Neo4j database. If you're curious on how to do that please look at other questions here on SO and if you need more help, feel free to post another question or reach out to me on Twitter @kennybastani.

Cheers,

Kenny

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!