With NoSQL you can grab the data for the user's day and then use it in your application. If we want to display all the data for a single day, it's pretty much the same. There's a lot of ways to handle this, but suffice it to say this: it's a bit more complicated than saving the data in a NoSQL database. If you're using SQL to store this data, you might want to save each table's data as it's entered in your data entry form (and not wait until all the data is entered.) Or you might want to create a database function that takes all the JSON data, parses it, and writes it to all the related tables in a single transaction. If we don't have data for a specific table (say no exercise was recorded today) then we can skip that table. We'd want to do 4 separate inserts here, one for each table. With SQL, we have some structure we have to work within, and in this case it looks like 4 separate tables: food, water, exercise, and notes. In a NoSQL database, this can be a pretty easy process, as we can just create a record (document) for a specific user for a specific date and throw document into a collection and we're done. Once we've gathered all the data for a day, we need to store it in our database. So, I get a JSON object for each day that looks like this: In my app, I gather all the data for a single day on one page, to make it easier for my users. On any given day I may have zero or more entries for food, water, and exercise, and I may have zero or one entry for weight & notes. It's organized simply and easily, but the number of records varies from day to day. That's a lot of different data that needs to be gathered, stored, retrieved, and later analyzed. I feel better, but sure miss all that greasy food. I also track the number of cups of water I drink and when I drink them: Dayįor each day I also track my current weight along with any notes for the day: Day Let's look at an example:Įach day I track the food I eat, along with the number of calories in each item: Day A SQL solution makes it easier to gather data and draw conclusions down the line. But later when you need to access that data to answer some basic business questions, it's much more difficult. You can just take a JSON data object from your front-end code and throw it in the database and be done with it. Typically it's easier to get started with NoSQL data structures, especially when the data is complex or hierarchical. There are tradeoffs with both SQL and NoSQL solutions. Make the wrong choice and you could be headed for nightmares (and maybe even some major re-writes) before your app ever makes it out the door. Choose correctly and structure your data well, and you may sail smoothly into production and watch your app take off. Should you store your data in a standard, time-tested SQL database, or go with one of the newer NoSQL document-based databases? This seemingly simple decision can literally make or break your project down the line. Postgres Plus is a closed source fork of PostgreSQL, so the same applies to it.It's a tough decision for any developer starting a new project. Still, SQL is the only way to interact with a PostgreSQL database, so you couldn't call it a NoSQL database and keep a straight face unless you were in marketing. Now you can say that PostgreSQL supports a certain feature commonly found in NoSQL databases. Now PostgreSQL, like many other RDBMS, has added support for JSON data, which is the most popular format for semi-structured data commonly stored in NoSQL systems. Perhaps the name was also chosen because SQL, being verbose and often hard to understand, evokes negative reactions in many programmers. Since SQL is the language normally used to interact with an RDBMS, the term “NoSQL” is used as a name for all these systems. “NoSQL” is a buzzword describing a diverse collection of database systems that focus on “semi-structured” data (that do not fit well into a tabular representation), sharding and high concurrency at the expense of transactional integrity and consistency, the latter being among the basic tenets of relational database management systems (RDBMS). You have been confused my marketing and buzzwords.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |