Hacker News new | past | comments | ask | show | jobs | submit login

It's even better: with an explicit schema you can trivially do data migrations!

With something without a schema, data migrations are almost impossible to do correctly.




I think trivially is over simplifying it, but certainly migrations are much easier with a schema.


Data migrations are rarely just about adding or removing a few columns. It also involves data manipulation. Schema doesn't help you with this. So at some point you have to write data migration code. In which case (and if you are using an ORM) why not do the schema change at the same time.

And sorry but it is complete nonsense to suggest that data migrations are almost impossible on schema less systems. I've done countless myself and people are doing it every day.


Relational models are well-described and can be changed transactionally, both in structure and content, using a well-known and ubiquitous language to describe the migration. It doesn't get any easier than that.


> Relational models are well-described and can be changed transactionally, *

*: transactionally, for certain flavours of relational databases.


> Data migrations are rarely just about adding or removing a few columns.

This has not been my experience. Sure, you occasionally need code to do a migration. But at least 90% of the time, you are adding to or refactoring your existing data model. In which case, pure SQL is entirely sufficient, unless you've been doing untoward things with your schema.


Having a schema most certainly does help, since you can know with certainty what shape a specific record has before retrieving it.

If you have an ORM for your schema-less database, you get roughly the same thing, but with weaker guarantees.

Correct data migration requires knowledge of the schema of the data.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: