dwyl / how-to-choose-a-database

How to choose the right dabase
97 stars 11 forks source link

Should we encourage people to learn how to use PostgreSQL? #3

Open nelsonic opened 8 years ago

nelsonic commented 8 years ago

Should we encourage people to learn how to use PostgreSQL? https://en.wikipedia.org/wiki/PostgreSQL

sofer commented 8 years ago

@nelsonic it's great for people to be aware of PostgreSQL and of SQL in general, but there is a case for first encouraging the use of a database (i.e. Redis) that has data structures that look a lot like the data structures in your code, rather than requiring people to learn a DSL, like SQL.

Maybe it's better to introduce PostgreSQL only at the point where people have data structures that would benefit from the use of SQL. It would not hurt to do a lot more thinking about what sort of projects to introduce on the course and what data structures might be needed for them.

On a side note, I love this talk by the creator of Postgres: https://youtu.be/uhDM4fcI2aI

nelsonic commented 7 years ago

I can't decide if this article is "biased" or if its a good example of a team coming "back" to PostgreSQL from MongoDB: http://developer.olery.com/blog/goodbye-mongodb-hello-postgresql/

sofer commented 7 years ago

After a couple of years of trying different things at FAC, the answer to your question is provisionally, "yes". SQL may not always be the right choice, and it is another thing that people have to learn, but it's shocking for people to do a coding camp and not know any SQL at all.

The problem with e.g. your comment, 'getting it right might have been true for the "old" world of static schema, but today, where changes need to be made daily, a flexible schema is more appropriate', is that this can easily be misinterpreted by a beginner as not needing to think about data structures at all. Arguably, even if you use a schema-less db, thinking about the shape of the data is just about the the most important thing you can do at the beginning of a project. Insisting on a schema makes you to do that. Using PostgreSQL or MySQL enforces it.

It's hard to argue with this from the Peterse piece:

Another way of handling this is defining a schema in your models. For example, Mongoid, a popular MongoDB ODM for Ruby, lets you do just that. However, when defining a schema using such tools one should wonder why they aren’t defining the schema in the database itself. Doing so would solve another problem: re-usability. If you only have a single application then defining a schema in the code is not really a big deal. However, when you have dozens of applications this quickly becomes one big mess.

Schemaless storage engines promise to make your life easier by removing the need to worry about a schema. In reality these systems simply make it your own responsibility to ensure data consistency. In certain cases this might work out, but I’m willing to bet that for most this will only backfire.