what is the best way to store Numbers of a Bingo Card in database table [closed]











up vote
-3
down vote

favorite












I wanna create a web-based bingo game using MVC and EF, I want to store 24 numbers for each card in the database table as a record,I'm not sure how to create my Bingo cards table,one way that comes to my mind is design a table with 24 integer field for each cell's number this way when I fetch the record in business logic I can't traverse the numbers because they are in the separate fields(actually I can but I think this way is not the right way to do)the other way is I concatenate all numbers together and separate it with comma and store it as a string so when I fetch the record I can split the string of comma and have all numbers in an array or something
so what is the best solution for this situation ?
how can I design my table for storing numbers of a bingo card ?










share|improve this question













closed as primarily opinion-based by DavidG, T.S., Graham, Shiladitya, Matthew L Daniel Nov 11 at 4:53


Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.















  • Welcome to StackOverflow. Please read the help section on how to ask and then edit your question, as this will help the community better understand your specific issue and provide you with a good answer: stackoverflow.com/help/how-to-ask
    – Graham
    Nov 11 at 3:45















up vote
-3
down vote

favorite












I wanna create a web-based bingo game using MVC and EF, I want to store 24 numbers for each card in the database table as a record,I'm not sure how to create my Bingo cards table,one way that comes to my mind is design a table with 24 integer field for each cell's number this way when I fetch the record in business logic I can't traverse the numbers because they are in the separate fields(actually I can but I think this way is not the right way to do)the other way is I concatenate all numbers together and separate it with comma and store it as a string so when I fetch the record I can split the string of comma and have all numbers in an array or something
so what is the best solution for this situation ?
how can I design my table for storing numbers of a bingo card ?










share|improve this question













closed as primarily opinion-based by DavidG, T.S., Graham, Shiladitya, Matthew L Daniel Nov 11 at 4:53


Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.















  • Welcome to StackOverflow. Please read the help section on how to ask and then edit your question, as this will help the community better understand your specific issue and provide you with a good answer: stackoverflow.com/help/how-to-ask
    – Graham
    Nov 11 at 3:45













up vote
-3
down vote

favorite









up vote
-3
down vote

favorite











I wanna create a web-based bingo game using MVC and EF, I want to store 24 numbers for each card in the database table as a record,I'm not sure how to create my Bingo cards table,one way that comes to my mind is design a table with 24 integer field for each cell's number this way when I fetch the record in business logic I can't traverse the numbers because they are in the separate fields(actually I can but I think this way is not the right way to do)the other way is I concatenate all numbers together and separate it with comma and store it as a string so when I fetch the record I can split the string of comma and have all numbers in an array or something
so what is the best solution for this situation ?
how can I design my table for storing numbers of a bingo card ?










share|improve this question













I wanna create a web-based bingo game using MVC and EF, I want to store 24 numbers for each card in the database table as a record,I'm not sure how to create my Bingo cards table,one way that comes to my mind is design a table with 24 integer field for each cell's number this way when I fetch the record in business logic I can't traverse the numbers because they are in the separate fields(actually I can but I think this way is not the right way to do)the other way is I concatenate all numbers together and separate it with comma and store it as a string so when I fetch the record I can split the string of comma and have all numbers in an array or something
so what is the best solution for this situation ?
how can I design my table for storing numbers of a bingo card ?







c# sql entity-framework relational-database






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 11 at 2:37









Mohammad

33




33




closed as primarily opinion-based by DavidG, T.S., Graham, Shiladitya, Matthew L Daniel Nov 11 at 4:53


Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.






closed as primarily opinion-based by DavidG, T.S., Graham, Shiladitya, Matthew L Daniel Nov 11 at 4:53


Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.














  • Welcome to StackOverflow. Please read the help section on how to ask and then edit your question, as this will help the community better understand your specific issue and provide you with a good answer: stackoverflow.com/help/how-to-ask
    – Graham
    Nov 11 at 3:45


















  • Welcome to StackOverflow. Please read the help section on how to ask and then edit your question, as this will help the community better understand your specific issue and provide you with a good answer: stackoverflow.com/help/how-to-ask
    – Graham
    Nov 11 at 3:45
















Welcome to StackOverflow. Please read the help section on how to ask and then edit your question, as this will help the community better understand your specific issue and provide you with a good answer: stackoverflow.com/help/how-to-ask
– Graham
Nov 11 at 3:45




Welcome to StackOverflow. Please read the help section on how to ask and then edit your question, as this will help the community better understand your specific issue and provide you with a good answer: stackoverflow.com/help/how-to-ask
– Graham
Nov 11 at 3:45












1 Answer
1






active

oldest

votes

















up vote
0
down vote



accepted










Good question!



You're right, storing it in 24 different integer fields is definitely a bad way to go. Concatenating them with commas might seem like a reasonable compromise, but it's inflexible, as you're treating them as text, not integers, so later on if you wanted to run queries such as SELECT MAX(CardNumber) FROM BingoCardNumbers WHERE CardID = 1 you couldn't do anything like that.



My suggestion would be to have two different tables, BingoCards and BingoCardNumbers. The BingoCards table would have a CardID, as well as other information relevant to the card, such as who the card belongs to, so maybe you'd want a UserID column in there too. No card numbers are stored in this table.



Then, in the BingoCardNumbers table, that would have three columns, CardID, which is the primary key from the first table, NumberIndex (1-24, which is the index of the number in the card), and finally CardNumber, which is the actual number itself. Then, if you want to get all the numbers for a particular card, you can simply do:



SELECT CardNumber FROM BingoCardNumbers WHERE CardID = 1 ORDER BY NumberIndex





share|improve this answer

















  • 1




    Usually we wouldn't answer a question like this as it is opinion based.
    – DavidG
    Nov 11 at 2:58






  • 1




    While it's true that it's opinion based, almost any DBA is going to say that storing it in 24 fields is not a good idea at all, so I'm trying to show a better way, as well as my thinking behind doing it a different way. By all means, other people should add other answers, but I think this is a pretty good "normalized" way of doing it.
    – Sam Leatherdale
    Nov 11 at 3:06






  • 1




    @Mohammad Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise
    – DavidG
    Nov 11 at 3:06






  • 1




    @Mohammad That's just how this site works, we don't like questions that have opinionated answers.
    – DavidG
    Nov 11 at 3:12






  • 1




    @Mohammad Nobody is saying your question is bad, just that you're better asking it somewhere else.
    – DavidG
    Nov 11 at 3:28


















1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote



accepted










Good question!



You're right, storing it in 24 different integer fields is definitely a bad way to go. Concatenating them with commas might seem like a reasonable compromise, but it's inflexible, as you're treating them as text, not integers, so later on if you wanted to run queries such as SELECT MAX(CardNumber) FROM BingoCardNumbers WHERE CardID = 1 you couldn't do anything like that.



My suggestion would be to have two different tables, BingoCards and BingoCardNumbers. The BingoCards table would have a CardID, as well as other information relevant to the card, such as who the card belongs to, so maybe you'd want a UserID column in there too. No card numbers are stored in this table.



Then, in the BingoCardNumbers table, that would have three columns, CardID, which is the primary key from the first table, NumberIndex (1-24, which is the index of the number in the card), and finally CardNumber, which is the actual number itself. Then, if you want to get all the numbers for a particular card, you can simply do:



SELECT CardNumber FROM BingoCardNumbers WHERE CardID = 1 ORDER BY NumberIndex





share|improve this answer

















  • 1




    Usually we wouldn't answer a question like this as it is opinion based.
    – DavidG
    Nov 11 at 2:58






  • 1




    While it's true that it's opinion based, almost any DBA is going to say that storing it in 24 fields is not a good idea at all, so I'm trying to show a better way, as well as my thinking behind doing it a different way. By all means, other people should add other answers, but I think this is a pretty good "normalized" way of doing it.
    – Sam Leatherdale
    Nov 11 at 3:06






  • 1




    @Mohammad Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise
    – DavidG
    Nov 11 at 3:06






  • 1




    @Mohammad That's just how this site works, we don't like questions that have opinionated answers.
    – DavidG
    Nov 11 at 3:12






  • 1




    @Mohammad Nobody is saying your question is bad, just that you're better asking it somewhere else.
    – DavidG
    Nov 11 at 3:28















up vote
0
down vote



accepted










Good question!



You're right, storing it in 24 different integer fields is definitely a bad way to go. Concatenating them with commas might seem like a reasonable compromise, but it's inflexible, as you're treating them as text, not integers, so later on if you wanted to run queries such as SELECT MAX(CardNumber) FROM BingoCardNumbers WHERE CardID = 1 you couldn't do anything like that.



My suggestion would be to have two different tables, BingoCards and BingoCardNumbers. The BingoCards table would have a CardID, as well as other information relevant to the card, such as who the card belongs to, so maybe you'd want a UserID column in there too. No card numbers are stored in this table.



Then, in the BingoCardNumbers table, that would have three columns, CardID, which is the primary key from the first table, NumberIndex (1-24, which is the index of the number in the card), and finally CardNumber, which is the actual number itself. Then, if you want to get all the numbers for a particular card, you can simply do:



SELECT CardNumber FROM BingoCardNumbers WHERE CardID = 1 ORDER BY NumberIndex





share|improve this answer

















  • 1




    Usually we wouldn't answer a question like this as it is opinion based.
    – DavidG
    Nov 11 at 2:58






  • 1




    While it's true that it's opinion based, almost any DBA is going to say that storing it in 24 fields is not a good idea at all, so I'm trying to show a better way, as well as my thinking behind doing it a different way. By all means, other people should add other answers, but I think this is a pretty good "normalized" way of doing it.
    – Sam Leatherdale
    Nov 11 at 3:06






  • 1




    @Mohammad Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise
    – DavidG
    Nov 11 at 3:06






  • 1




    @Mohammad That's just how this site works, we don't like questions that have opinionated answers.
    – DavidG
    Nov 11 at 3:12






  • 1




    @Mohammad Nobody is saying your question is bad, just that you're better asking it somewhere else.
    – DavidG
    Nov 11 at 3:28













up vote
0
down vote



accepted







up vote
0
down vote



accepted






Good question!



You're right, storing it in 24 different integer fields is definitely a bad way to go. Concatenating them with commas might seem like a reasonable compromise, but it's inflexible, as you're treating them as text, not integers, so later on if you wanted to run queries such as SELECT MAX(CardNumber) FROM BingoCardNumbers WHERE CardID = 1 you couldn't do anything like that.



My suggestion would be to have two different tables, BingoCards and BingoCardNumbers. The BingoCards table would have a CardID, as well as other information relevant to the card, such as who the card belongs to, so maybe you'd want a UserID column in there too. No card numbers are stored in this table.



Then, in the BingoCardNumbers table, that would have three columns, CardID, which is the primary key from the first table, NumberIndex (1-24, which is the index of the number in the card), and finally CardNumber, which is the actual number itself. Then, if you want to get all the numbers for a particular card, you can simply do:



SELECT CardNumber FROM BingoCardNumbers WHERE CardID = 1 ORDER BY NumberIndex





share|improve this answer












Good question!



You're right, storing it in 24 different integer fields is definitely a bad way to go. Concatenating them with commas might seem like a reasonable compromise, but it's inflexible, as you're treating them as text, not integers, so later on if you wanted to run queries such as SELECT MAX(CardNumber) FROM BingoCardNumbers WHERE CardID = 1 you couldn't do anything like that.



My suggestion would be to have two different tables, BingoCards and BingoCardNumbers. The BingoCards table would have a CardID, as well as other information relevant to the card, such as who the card belongs to, so maybe you'd want a UserID column in there too. No card numbers are stored in this table.



Then, in the BingoCardNumbers table, that would have three columns, CardID, which is the primary key from the first table, NumberIndex (1-24, which is the index of the number in the card), and finally CardNumber, which is the actual number itself. Then, if you want to get all the numbers for a particular card, you can simply do:



SELECT CardNumber FROM BingoCardNumbers WHERE CardID = 1 ORDER BY NumberIndex






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 11 at 2:50









Sam Leatherdale

11517




11517








  • 1




    Usually we wouldn't answer a question like this as it is opinion based.
    – DavidG
    Nov 11 at 2:58






  • 1




    While it's true that it's opinion based, almost any DBA is going to say that storing it in 24 fields is not a good idea at all, so I'm trying to show a better way, as well as my thinking behind doing it a different way. By all means, other people should add other answers, but I think this is a pretty good "normalized" way of doing it.
    – Sam Leatherdale
    Nov 11 at 3:06






  • 1




    @Mohammad Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise
    – DavidG
    Nov 11 at 3:06






  • 1




    @Mohammad That's just how this site works, we don't like questions that have opinionated answers.
    – DavidG
    Nov 11 at 3:12






  • 1




    @Mohammad Nobody is saying your question is bad, just that you're better asking it somewhere else.
    – DavidG
    Nov 11 at 3:28














  • 1




    Usually we wouldn't answer a question like this as it is opinion based.
    – DavidG
    Nov 11 at 2:58






  • 1




    While it's true that it's opinion based, almost any DBA is going to say that storing it in 24 fields is not a good idea at all, so I'm trying to show a better way, as well as my thinking behind doing it a different way. By all means, other people should add other answers, but I think this is a pretty good "normalized" way of doing it.
    – Sam Leatherdale
    Nov 11 at 3:06






  • 1




    @Mohammad Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise
    – DavidG
    Nov 11 at 3:06






  • 1




    @Mohammad That's just how this site works, we don't like questions that have opinionated answers.
    – DavidG
    Nov 11 at 3:12






  • 1




    @Mohammad Nobody is saying your question is bad, just that you're better asking it somewhere else.
    – DavidG
    Nov 11 at 3:28








1




1




Usually we wouldn't answer a question like this as it is opinion based.
– DavidG
Nov 11 at 2:58




Usually we wouldn't answer a question like this as it is opinion based.
– DavidG
Nov 11 at 2:58




1




1




While it's true that it's opinion based, almost any DBA is going to say that storing it in 24 fields is not a good idea at all, so I'm trying to show a better way, as well as my thinking behind doing it a different way. By all means, other people should add other answers, but I think this is a pretty good "normalized" way of doing it.
– Sam Leatherdale
Nov 11 at 3:06




While it's true that it's opinion based, almost any DBA is going to say that storing it in 24 fields is not a good idea at all, so I'm trying to show a better way, as well as my thinking behind doing it a different way. By all means, other people should add other answers, but I think this is a pretty good "normalized" way of doing it.
– Sam Leatherdale
Nov 11 at 3:06




1




1




@Mohammad Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise
– DavidG
Nov 11 at 3:06




@Mohammad Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise
– DavidG
Nov 11 at 3:06




1




1




@Mohammad That's just how this site works, we don't like questions that have opinionated answers.
– DavidG
Nov 11 at 3:12




@Mohammad That's just how this site works, we don't like questions that have opinionated answers.
– DavidG
Nov 11 at 3:12




1




1




@Mohammad Nobody is saying your question is bad, just that you're better asking it somewhere else.
– DavidG
Nov 11 at 3:28




@Mohammad Nobody is saying your question is bad, just that you're better asking it somewhere else.
– DavidG
Nov 11 at 3:28



Popular posts from this blog

Florida Star v. B. J. F.

Error while running script in elastic search , gateway timeout

Adding quotations to stringified JSON object values