3 ms·
> MongoDB is schema-free, allowing you to create documents without having to first create the structure for that document. At the same time, it still has many o
by koolba 9y ago
> MongoDB is schema-free, allowing you to create documents without having to first create the structure for that document. At the same time, it still has many of the features of a relational database, including strong consistency and an expressive query language.
The author clearly has a different definition of "strong consistency" than most. I don't see how any claims of consistency (in a data usage, not CAP sense) can be made of a database that can't properly store a number as a number or even guarantee that it's a number at all.
Also, does anyone actually like the Mongo query language? It was cute when I first saw it but I pity anyone trying to do anything complicated by manually writing those JSON strings.
- metheus 9y ago> a database that can't properly store a number as a number or even guarantee that it's a number at all. What do you mean?
- koolba 9y agoI meant it doesn't have a decimal type but looks like as v3.4 it does: https://docs.mongodb.com/manual/tutorial/model-monetary-data/#numeric-decimal https://docs.mongodb.com/manual/tutorial/model-monetary-data...
- metheus 9y agoOk, but even prior to 3.4, in what sense did you mean it couldn't guarantee something was a number at all?
- koolba 9y agoNot having an enforced scheme means that there is no guarantee a given key exists or that if it does exist, the data type matches what you'd expect it to be. One errant piece of code could insert a bad record that could break some other of piece of code.
- metheus 9y agoSince version 3.2 you've been able to enforce data types with validation.
- threeseed 9y agoMongoDB absolutely stores numbers as numbers. Always has. And yes in a schemaless database you are required to manage the schema in your application layer as opposed to within the database. If we wanted a database with a rigid schema we would just use a SQL database.
- zepolen 9y agoHe said can it guarantee that the field "length" will always be a number and not..eg a string, or a list, or an object.
- threeseed 9y agoWhy would it guarantee that ? It's a schema less database. It's not supposed to do that. And my point is that if you query a single document and the field is a number then it will be returned as a number i.e. it physically stores and understands numbers.
- zepolen 9y agoElasticsearch is schemaless as well, however it can guarantee that a field is a number once used.
- threeseed 9y agoElasticsearch is not schemaless. It typically requires you to define a mapping (schema) upfront. You can set it to automatically infer the mapping based on the available data but this does not make it truly schemaless. MongoDB allows a free form schema for every document. You're again comparing apples and oranges.
- metheus 9y agoJust to be clear, a better term would be "dynamic schema". You can ask for data type validation since 3.2.
- manigandham 9y ago