0

As a side-project and to learn a bit about creating RESTful APIs, I was thinking of writing a flashcard app since none of the existing ones suit my needs. The data would be fairly simple. Word, definition, right or wrong for every time seen, and how well the person knew the answer for each try (maybe scale of 1-5).

My goal would be to create this API so that either a mobile app or a website could use it.

How or how not would a nosql database fit as the backend? Why use something like CouchDB/MongoDB vs, say MYSQL for this specific type of app? This is my limited understanding:

  • nosql tends to be schemaeless, or at least easier to change on the fly
  • nosql is more flexible with the cost of data integrity and the relative unproven technology vs relational DBs.
  • nosql plays nicely with object oriented paradigms
  • CouchDB offers good built in resources for something like a mobile app where data needs to be stored locally when there's no internet connection

In this thread people suggest simply using a SQL db: Would a NoSQL solution be relevant for a real-time mobile game?. I'd like to use this opportunity to learn about nosql, but I also want to use the right tool for the job.

closed as primarily opinion-based by dezso, mustaccio, Tom V, RLF, LowlyDBA Aug 10 '16 at 15:49

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.

1

NoSQL databases are particularly useful when you are not certain what information will exist for a given entry (or document in the case of MongoDB and CouchDB) in the database.

For a flash card app, each card may have the exact same pieces of information (i.e.: word, definition, right/wrong, score). But there may be cases where an individual flash card contains an image or images, multiple choice answers, the case you mentioned:

right or wrong for every time seen

and the list goes on.

Given this variation in possible fields, you could create a JSON document for each flash card, with different pieces of information as needed. For recording the attempts and results, you could add an array field:

"card" : 
{
  "word" : "foo",
  "description" : "bar",
  "attempts" : 
  [
    {
      "timeTried" : "08-01-2016 12:34:56 PM",
      "correct" : true,
    }, 
    ...
  ],
  "score": 4
}

In this case, a relational database would not work, because you would have no way of knowing how many attempts columns to create. If there are other parts of the flash card that are variable or if there is no unique structure for your flash cards, then a NoSQL database is the way to go.

  • 6
    It would be trivial to model the attempts as a many to one relationship in a relational database. Each attempt would be a new row in any schema beyond first normal form. Not a new column. – Martin Smith Aug 9 '16 at 19:42
  • @MartinSmith Good point. I was hoping to help OP design a NoSQL database for his use case, but relational may be the way to go. – Jerod Johnson Aug 9 '16 at 19:45
  • 2
    Well as the OP is using it as a learning project to learn nosql they should just use nosql anyway probably! – Martin Smith Aug 9 '16 at 19:48

Not the answer you're looking for? Browse other questions tagged or ask your own question.