Search code examples
javadatabasepoker

How to insert range of cards in database cell


How can I insert a range of cards like AA-QQ (AA, KK, QQ) in a cell of a database?

I will use Java.

I can't use 2 columns like in this answer because cards aren't numbers.

EDIT:

Maybe I found. I can do a join.

Second table:

ID  CARD1  CARD2  CARD3
--  -----  -----  -----
1   AA     KK     QQ

But if I have four pair of card in next row?


Solution

  • The best practice would be to use two tables for this purpose.

    MainTable:
    Id    rest of the approoriate fields
    1        ...........
    2        ............
    
    Card Event Table:
    id main_table_id           order   card
    1     1                      1       kk
    2     1                      2       qq
    3     1                      3       JJ
    4     1                      4       AA
    

    Here you can use foreign key to point to MainTable id. That way you dont have to bother about number of cards