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

前端 未结 1 1320
感情败类
感情败类 2021-01-07 11:24

We presently use a pen/paper based roster to manage table games staff at the casino. Each row is an employee, each column is a 20 minute block of time and each cell represen

相关标签:
1条回答
  • 2021-01-07 12:04

    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.

    Casino Employee Graph Data Model

    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

    0 讨论(0)
提交回复
热议问题