Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Let me preface my response by saying that putting every possible combination in a database feels wrong. I'll get to why in a minute. </p> <p>I'd start with a table called Cards. There would be 1 record for every possible card and it would include fields for Suit, Face value, rank and yes, a CardID as a primary key. Also index the suit, and face value. </p> <p>If you want to table out every possible Hold'em hand, then I would make separate tables for the pocketCards(pocketID, pCardID1, pCardID2), flopCards(flopID, fCardID1, fCardID2, fCardID3) then a table for the TurnAndRiver(turnAndRiverID, turnCardID, riverCardID). Then a Hand table with (handID, pocketID, flopID, turnAndRiverID, handScore). </p> <p>HandScore would be a calculated field run off of a table or scalar value function.</p> <p>By separating out those bits, you avoid a great deal of the duplication, but you will still have to worry about card selection and overlap. </p> <p>Ideally, I would forgo the hand tables and calculate the hand and score in what ever application I was building to consume this data. </p> <p>Putting too much of your logic in the database may make it hard to adapt when the client asks you to model Omaha or five-card draw for example. </p> <p>In reguard to your index question, yes, I would use a primary key as that will allow you to quickly reference a specific hand in your code. </p> <p><strong>Update</strong> </p> <p>In response to the OP's Edit: It sounds like you are using the wrong tool for this task. What is the value of having the data in a Database if you are always going to select the exact same recordset? Examine other options (like a flat XML file, or a static DataSet in your code for example). It will save you the connection time and the overhead of running a server for what is essentially static data. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload