by dotborg · 13y ago · 0 comments
What's the point of having schema in database then?
2. I think the main point of the post was that you can run ad-hoc SQL queries no matter how much you've denormalized. You can't necessarily do that with a NoSQL database.
Code generation is a powerful DRY tool, not something it suggests avoiding!
I say that independent from the question of whether you should be using an ORM at all. If you are going to use it, either your ORM should come out of the DB or be responsible for creating the DB, either is fine, as long as you're not saying the same thing twice.
It's actually "Every piece of knowledge must have a single, unambiguous, authoritative representation within a system."
(this advances your point even further)
No, but I do. What if I want to analyze my data in some way I hadn't expected? SQL lets me do that with a single query.
look at web server logs, they have no schema, each line is not related with others, yet we are able to analyze logs
Your ORM likely represents the last iteration of that schema and then you have code to handle all the past iterations.
So the point of having a schema in the database is avoiding that kind of hell.
> in schema-less DBMS you really have as many schemas as
> changes you've made.
Unless you migrate data with each change, which is actually easier when you don't have a static schema. The choice to do "lazy migrations" is the unusual, not typical case, as it has all of the implications that you've mentioned. Bottom line: Data normalization doesn't suddenly go out the window just because it's MongoDB.My only personal opinion is that data is much more important than code. I want to guarantee that my data is in the right structure, with the right types, and right relationships. If I have that, everything else is easy.
> Usually if you have a static schema you also have SQL,
> which makes migrations a lot easier.
I'm not sure I follow. MongoDB doesn't have a static schema so there's less work to do when migrating data. No temp tables, no DDL, no disabling of triggers, etc. So my definition of "easy" in this case was "fewer things to do", not "requires less expertise." > I want to guarantee that my data is in the right
> structure, with the right types, and right relationships.
We know that having the right types, structure, and relationships are valuable, but since there is no context here, we can't know whether they're more or less valuable than other factors. (Note we've already assumed that the data is easily modeled in a relational structure AND in a document structure... If we're wrong about that this whole conversation may be moot.)