3 ms·
Structures are useful - I'm actually a lot more comfortable putting things in MongoDB when I know they're coming from a strongly typed language than if they're
by lmm 14y ago
Structures are useful - I'm actually a lot more comfortable putting things in MongoDB when I know they're coming from a strongly typed language than if they're coming from Javascript, because that way I know they've gone through a rigid "schema" at some point. But I don't think SQL's very limited datatypes are the best way to express the constraints on a typical business object. What I'd really like is a database that stored object instances, in a language that made a type-level distinction between serializable/value objects and non-serializable objects (one of those projects I keep meaning to do is the design of such a language). ZODB tried to do this in python, but it'd be far more useful in something strongly typed - I've heard Google have had some success with storing protobuf objects directly in a database? The protobuf schema is rigid enough to provide the kind of guarantees you get with SQL, but a lot easier to map domain objects onto.
Which really sums up the advantage of MongoDB to me - JSON is a more natural fit for domain objects than SQL tables.
- anthonyb 14y ago"very limited datatypes"? You haven't used Postgres very much, have you? http://www.postgresql.org/docs/9.2/static/datatype.html http://www.postgresql.org/docs/9.2/static/datatype.html And those are just the built-in ones, not counting PostGIS and other ones that you can define: http://www.postgresql.org/docs/9.1/static/extend-type-system.html http://www.postgresql.org/docs/9.1/static/extend-type-system...
- lmm 14y agoThey're very limited compared to what you'd get in a real programming language. The fact that the language needs to define types for so many things is actually a demonstration of this - the reason postgres has built-in types for things like IP addresses or line segments is because it's too hard for users to implement such things themselves and very little notion of library code.
- anthonyb 14y agoAgain, you haven't used Postgres very much if you think that. IP addresses are in there because they are generally useful, not because they're hard to implement. Go have a look at the complex number implementation here: http://www.postgresql.org/docs/9.1/static/xtypes.html http://www.postgresql.org/docs/9.1/static/xtypes.html then come back and tell me that Postgres is "not a real programming language" (whatever that means these days).