Live data from Hacker News

SQL vs. NoSQL Databases: What’s the Difference?

upwork.com

21–30 of 60 posts

Re: SQL vs. NoSQL Databases: What’s the Difference?

#21
I'm always saddened when I don't see MultiValue[0] databases in the list, but the reality is that there's almost nothing that's open source in this space.

My first real job was doing development on a custom application built entirely in UniVerse[1]. It was a really interesting way to work and mirrors a lot of what the Open Source NoSQL databases do, though it does it differently. Instead of storing the schema with the records (e.g., a JSON document), a record was simply a list of data elements (fields), each field could have multiple values (or not), each value could have multiple subvalues (or not), and there was a lower level that you could go to in order to store multi-line text data.

There was a dictionary attached to each file that primarily drove the query tool. You could also build calculated fields (I-descriptors) to do primitive joins, among other things. If you had a file containing invoices, you might have two fields to list the item number and quantity (these would be repeated for as many items as are on the invoice). You could then use an I-descriptor to follow item number over to the items file and pull the description, price, etc.

The entirety of the application ran within UniVerse. When users logged in to the unix server, their shell would run a script that would set up the environment and fire up UniVerse. The UniVerse LOGIN paragraph would then show a menu system and allow them to do their thing. Everything was written as either a paragraph, roughly equivalent to a shell script that ran UniVerse commands, or a BASIC program. The dialect of BASIC natively understood dynamic arrays, which were a 1:1 match to the structure of the records on disk.

UniVerse also had a built-in way to execute SQL queries against the multivalued data. In the invoice example above, the item number and quantity would be associated in the dictionary. These would then be exposed as another table by the SQL engine. You could go "SELECT A.INVOICENO, B.ITEMID, C.DESCRIPTION, B.QTY FROM INVOICES A, INVOICES_ITEMS B, ITEMS C WHERE A.@ID = B.@ID and B.ITEMID = C.ITEMID" and it would know that INVOICES_ITEMS is really part of the data in INVOICES.

It was a really cool system and I wish there was something like it in the Open Source world. Sadly, development on MaVerick[2] seems to have stalled.

[0] https://en.wikipedia.org/wiki/MultiValue

[1] http://www.rocketsoftware.com/products/rocket-universe

[2] http://www.maverick-dbms.org/

Re: SQL vs. NoSQL Databases: What’s the Difference?

#22
The article read like it is written by someone who has never understood how to use a SQL database.

To quote Mr Torvalds himself:

"Bad programmers worry about the code. Good programmers worry about data structures and their relationships."

Something that i struggled with before i learned how to use a SQL/relational database was to actualy use the database relations in my code. I first specified the relations in the database then i basicly redid them in the code.

The way i tend to program these days is to have basically all my relations restrictions and relational rules in the database. Whenever i want to change something you just alter stuff in the database GUI. Most of the application code will just follow along.

Re: SQL vs. NoSQL Databases: What’s the Difference?

#23
post #18

Bah. People keep confusing the syntax with the data model. SQL is simply a notation to express theorems in relational set theory. It's pretty much the only pure-functional, side-effect-free programming language that's actually gone mainstream [0]. If you look carefully at the APIs of the "No SQL" databases, you'll find them introducing relational set theoretic features. To paraphrase Paul Graham's unbearably smug com…

> side-effect-free

How is SQL side-effect-free if it has INSERT, UPDATE, DELETE?

Re: SQL vs. NoSQL Databases: What’s the Difference?

#24

The article read like it is written by someone who has never understood how to use a SQL database. To quote Mr Torvalds himself: "Bad programmers worry about the code. Good programmers worry about data structures and their relationships." Something that i struggled with before i learned how to use a SQL/relational database was to actualy use the database relations in my code. I first specified the relations in the da…

I mean, it was written by a writer, not a developer/software engineer...

Re: SQL vs. NoSQL Databases: What’s the Difference?

#25
post #20
post #3

I have issues with his "Reasons to use NoSQL" * Making the most of cloud computing and storage There are plenty of "cloud" hosting options for SQL databases, enough that a simple google search should make my point for me. * Rapid development This is a really common reason that I have heard for wanting to use NoSQL databases. It is flat out wrong. While NoSQL databases may not force you into a schema for your database…

Another point on rapid development: SQL databases have some amazing libraries and tooling. I've been working a lot with SQLAlchemy in Python lately and have been blown away by it. > While NoSQL databases may not force you into a schema for your database, you will pay a toll for this mutability in your application layer. A while ago I read a really good point on this: There's always a schema. NoSQL / "schemaless" data…

NoSQL databases have as many schemas as there have been changes to the model. Everytime you make a change, and are keeping old data, you have another schema. Your code then has to be aware of every schema that has ever existed. Over time this becomes more and more painful and error-prone.

In a relational database, you have one schema and you have to convert/update your data to match that schema whenever it changes.

I've done one big project many years ago that used NoSQL storage of heterogeneous "document" types -- a perfectly reasonable use-case for the technology -- and I wouldn't do it again. Although at the time it seemed crazy to create different tables to hold this data it would have made that code so much simpler now.

Re: SQL vs. NoSQL Databases: What’s the Difference?

#26
post #3

I have issues with his "Reasons to use NoSQL" * Making the most of cloud computing and storage There are plenty of "cloud" hosting options for SQL databases, enough that a simple google search should make my point for me. * Rapid development This is a really common reason that I have heard for wanting to use NoSQL databases. It is flat out wrong. While NoSQL databases may not force you into a schema for your database…

SQL migrations may seem tedious, but the process of planning your data model and having rigid definitions for your data types saves you huge amounts of time in the long run.

Your reasoning seems too black and white, most the of the time, you can't know your data model ahead of time, that's why prototypes are so useful, so just using your language data structures or some less rigid datastore lets you get quicker to your data model.

Re: SQL vs. NoSQL Databases: What’s the Difference?

#27

The article read like it is written by someone who has never understood how to use a SQL database. To quote Mr Torvalds himself: "Bad programmers worry about the code. Good programmers worry about data structures and their relationships." Something that i struggled with before i learned how to use a SQL/relational database was to actualy use the database relations in my code. I first specified the relations in the da…

In my experience, if you have the relational database model fully defined and correct then the rest of the application is pretty much designed. All the screens and elements you need are obvious.

Re: SQL vs. NoSQL Databases: What’s the Difference?

#28
post #18

Bah. People keep confusing the syntax with the data model. SQL is simply a notation to express theorems in relational set theory. It's pretty much the only pure-functional, side-effect-free programming language that's actually gone mainstream [0]. If you look carefully at the APIs of the "No SQL" databases, you'll find them introducing relational set theoretic features. To paraphrase Paul Graham's unbearably smug com…

Along those same lines, you can - in principle - have a relational database that doesn't use SQL (although there aren't many in practice), and plenty of "NoSQL" databases use SQL (or a VERY SQL-like language). You can layer SQL on top of a lot of different data models, although the mapping will be cleaner in some cases than others.

Re: SQL vs. NoSQL Databases: What’s the Difference?

#30
post #3

I have issues with his "Reasons to use NoSQL" * Making the most of cloud computing and storage There are plenty of "cloud" hosting options for SQL databases, enough that a simple google search should make my point for me. * Rapid development This is a really common reason that I have heard for wanting to use NoSQL databases. It is flat out wrong. While NoSQL databases may not force you into a schema for your database…

SQL migrations may seem tedious, but the process of planning your data model and having rigid definitions for your data types saves you huge amounts of time in the long run. Your reasoning seems too black and white, most the of the time, you can't know your data model ahead of time, that's why prototypes are so useful, so just using your language data structures or some less rigid datastore lets you get quicker to yo…

Having rigid definitions for data types doesn't necessarily mean the datastore is rigid. It just means that you know what type of data goes in each column. Like it or not, if you change your schema that change has to be handled somewhere - either you update the old data to the new schema (do this), or you handle old versions of the schema in the application (fundamentally non-scalable IMO). It doesn't matter whether they're values in a JSON object or columns in a relational DB.

Flyway is a fantastic tool for making changes to relational schemas. Your code is versioned, and you can just keep the schema migration scripts right next to it. If you need to upgrade an old schema, it just walks through the migration scripts until it's up-to-date.

If there is some portion of your model that really, truly, honestly consists of unstructured data, you can just put that in a JSON column.

Post reply on HN