Reputation: 135
I am trying to design a hangman game in lucidchart. Just start to thinking about the data. If I decide to store them in database, what kinds of columns do I need?
I can think of columns:
(1) word: To store the actual word; (2) numberOfWrongGuesses: To store the wrong guess number (3) currentWord: The word currently has guessed etc.
One problem is once the user done the game or prepare to start a new game, the database needs to be cleaned up right?
Upvotes: 0
Views: 131
Reputation: 3730
In general: Start with an analysis of what you want the application to do. Only after that, you can decide if you need persistent storage, and if a database would be the best persistent storage for your application.
Note that databases are used for persistent storage. Since you are thinking about wiping the database after each game, this makes me think you do not need a database.
In this case, I think that you might not need any storage at all. Since you mention Javascript, you might be building a game that runs in the browser. Perhaps cookies would be enough to keep track of the score of your user.
Upvotes: 0
Reputation: 10215
If I decide to store them in database, what kinds of columns do I need?
It depends on how you want the game to work, not just gameplay (guessing the current word) but also managing what happens once the current game is finished - did you want to keep score, etc?
I don't know how Lucid chart works (what sort of runtime, API and programming environment it supports; or how users will interact with it, can it maintain state, etc), but you may be able to run the game entirely in-memory and not need a database at all.
Before diving straight into the physical columns, do a logical design on paper or a whiteboard.
One problem is once the user done the game or prepare to start a new game, the database needs to be cleaned up right?
That also depends on how you want the game to work. It also depends how many people will be playing this - if two people play it at once, they'll need their own separate set of data.
Cleaning up the data helps keep the database size smaller over time, but it also means you wouldn't be able to track a players history, or allow you to see things like "hardest 5 letter words of all time" etc.
Upvotes: 1
Reputation: 948
Not necessary, you can create a js file with let object like this:
data.js
const words = [
{ id: 1, name: 'spring' },
{ id: 2, name: 'promise' },
];
after you import this file to your html file.
Upvotes: 0