Is MongoDB object-oriented?

273 views
Skip to first unread message

Jerseyfoo

unread,
Dec 22, 2010, 10:25:18 PM12/22/10
to mongodb-user
I can't seem to find any indication that MongoDB can do this
natively...

db.posts[26].author --> db.users[3]



Andreas Jung

unread,
Dec 23, 2010, 6:21:25 AM12/23/10
to mongod...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

This has nothing to do with object-orientation.


MongoDB is a *document* database. Also the low-level API does not
provide any special OO support. Object-mappers like Mongokit for Python
sitting on top of the language dependent driver can provide an
OO-oriented API.

- -aj
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQGUBAEBAgAGBQJNEzC1AAoJEADcfz7u4AZjCgsLwLZ5uKnMa8QmWyj+5LZj8AmW
3zUS2G3PbJivEJHE7+QOHwzX+co08Fb6unzsB82BoMfClkTrpel8vxQqghCf8VuM
ELusKof5o/vNG7S7c7QLzr8Y8ZowNRwSUP73pGSRwmbXBUwke4NK30SIbnPclqUC
4U+O1ar5N/lclZBe8qxm4VxZartqSh6DUqFscUsu4ZOKepLcRMncE+AcHyy1ZduN
4vS1jXCuGi/xParZgnkCLNDW/H339C1EebG/OC9QaD0OLXIaadKFBE4t2R0Iyrmd
y3KwpG0+TWjADoArFfgWBJ5qj4LKaipYh6QtIn72IbLFtPItJmHGKM688pomGMeW
WJmpE2ecXi8p5A3CsPP/s8bFllQdWWG/palOHS9MJP+IPaRlYDaMJVQGEnD4KS61
eKRqiRxsflY0xrVKpWM/F4apJ5OCnDnPlT1mPtW7tChDVJaDtR56lKvMD70izIeP
AdE5NuG0Js6vch+mnN/bQWaJDPsyozA=
=3bvH
-----END PGP SIGNATURE-----

lists.vcf

Sam Millman

unread,
Dec 23, 2010, 6:55:40 AM12/23/10
to mongod...@googlegroups.com
Depends on the driver. In PHP it is. All OO inheritance within Mongo tends to occur within the drivers themselves and not the DB due to the type of DB this is.


--
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com.
To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.




--
Bow Chicka Bow Wow

Andreas Jung

unread,
Dec 23, 2010, 7:00:52 AM12/23/10
to mongod...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Sam Millman wrote:
> Depends on the driver. In PHP it is. All OO inheritance within Mongo
> tends to occur within the drivers themselves and not the DB due to the
> type of DB this is.

An object-oriented API is different from having an object-storeage or an
object-oriented database - MongoDB is basically a JSON storage.

- -aj
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQGUBAEBAgAGBQJNEzn0AAoJEADcfz7u4AZjwqELv3Lw39TvxhnGBWbTtRAjxA8D
jar/w1VRutrPL/SimoUSCpmC1F77bM/CWhsrTluFtje0xNZKETmNHqZlWI6RaOGR
wtErfAf0HAsZUnau9W6D1MQcUR+rjR4DcLhP1g7OkHPCcxnEvCyoq4mOH8XX4UT9
Fq14MFv4SmSjVRMVb0ChpLs56EMj5m4uGhEsWpXAgJqjiXUOUrNsFeh0oBC+GmG9
cgKo9vOgbJwHf1SKDprzSI7wTiTqt23SJSy/D3GvdlEeIURFcM9+fVr2Z8KAN3Tf
1Q27XkHuo6i4y+x5ceB4U5EvdyoVR/rmJznKJSGcLMVj05T72h+jzINueChIhpUm
sU1yo7q70Er2kDp+GnG498/HSijZ0az96rnGGotCrJl4c7SBdukMTn8rw6R4GDqg
/j9O5AUdr6b94dC2iP77kxWPlhezQ2g6u1k5AnMqoWC400GT44NvOsXJo1BpZPZc
Z1VcR08Ism89ZDy2d2PEgwQlpiWsmIM=
=ma6E
-----END PGP SIGNATURE-----

lists.vcf

Sam Millman

unread,
Dec 23, 2010, 7:08:42 AM12/23/10
to mongod...@googlegroups.com
True but one of the main benefits of JSON (over XML) is that it can store objects in Object form (I do in my REST servers all the time). So it is possible to have a OO storage...in a strange twisted way.

It is also why it is possible for a driver to possibly abstract OO from Mongo....but I don't know enough of the low level API and you know more than me.

-----END PGP SIGNATURE-----

--
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com.
To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.

Tim Hawkins

unread,
Dec 23, 2010, 8:10:43 AM12/23/10
to mongod...@googlegroups.com
there was some discussion about layering an object factory into the driver, so that it could instance a object with attached methods around the data in the document, but it was decided that was best left outside the driver.

OODBMS system have the same problem, somewhere the methods for an object need to be defined, and that code needs to be bound somewhere, that is generally in the application.  The apps usualy have a factory that makes objects from the stored data, and binds the methods to them. 

Most OODBMS systems also cant store the methods, at best they can provide metadata that would allow a factory to recreate objects. 

Jerseyfoo

unread,
Dec 23, 2010, 11:40:29 AM12/23/10
to mongodb-user
Essentially, MongoDB is just a replacement for SQL. Very
disappointing.

>This has nothing to do with object-orientation.
if a database cannot do that, it's not a object-oriented database.
It's not about what API you use, the data needs to be stored object-
oriented, or the performance will be terrible.

>Most OODBMS systems also cant store the methods
Methods are in the source, do you store your code in the database?
OOP is structured.

db.topics[id].posts[0].author.displayName == db.author[7].displayName

Think about it.

yatesco

unread,
Dec 23, 2010, 1:21:30 PM12/23/10
to mongodb-user
Wow - some big statements you are making there!

Essentially, the only thing that you have asked for that is missing is
the enforcement of relationships - MongoDB being a *document* database
makes no claim in supporting inter-document relationships (although it
will perfectly happily persist embedded documents).

Claiming that MongoDB is just a replacement for SQL is so far off the
mark that it makes me think you haven't really read (or know?) much
about this area. They are two completing different beasts and are not
inter-changeable in anyway whatsoever. Sure, they both do storage and
querying, but if I spent 10 minutes writing a framework which
serialises and loads things from disk, would you claim that is a
replacement for SQL just because it doesn't understand inter-document
relationships?

<rant>
The problem is that relational theory and RDBMS immediately place you
in a restricted area where a very small number of paradigms exist.
You are pretty much forced to restrict your persistence to fit in with
their (very limited) capabilities. The NoSQL movement comes it from
the other end of the spectrum - you can do pretty much whatever you
want, store things however you want (with the caveat that you need to
do some of the heavy lifting) and all of a sudden people are at a loss
because their technology choices are no longer forcing them down a
narrow path - they now have choice and are forced to address that
responsibility. Which is a scary thing indeed!

To be clear - I love SQL and have been using it for years and it sits
along side MongoDB in my current application. Different tools for
different jobs.
</rant>

Hmmmm.

Andreas Jung

unread,
Dec 23, 2010, 1:28:09 PM12/23/10
to mongod...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

yatesco wrote:

>
> <rant>
> The problem is that relational theory and RDBMS immediately place you
> in a restricted area where a very small number of paradigms exist.
> You are pretty much forced to restrict your persistence to fit in with
> their (very limited) capabilities. The NoSQL movement comes it from
> the other end of the spectrum - you can do pretty much whatever you
> want, store things however you want (with the caveat that you need to
> do some of the heavy lifting) and all of a sudden people are at a loss
> because their technology choices are no longer forcing them down a
> narrow path - they now have choice and are forced to address that
> responsibility. Which is a scary thing indeed!
>
> To be clear - I love SQL and have been using it for years and it sits
> along side MongoDB in my current application. Different tools for
> different jobs.
> </rant>

Nothing to be added except that I am under the impression that
a lot of people are using blindly using MongoDB for whatever
reason - without reflecting what they are really doing and without
thinking whether MongoDB is the right tool for a particular task or not.
MongoDB is not universal multiple-purpose devices for all problems...
it's "just" another valuable tool among others in the programmer's toolbox.

My 2 cents,


- -aj
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQGUBAEBAgAGBQJNE5S4AAoJEADcfz7u4AZjzJwLwN48LAp0FAgibB+E2b3t31hS
vM8R/w3j1/iPhyC+Fjx1L7NFKBvQf8df9xlEopaRnglBnd5S/6FcEor4sq//IHTV
1W2pkGQv7wnjkcQRaJy5yALjabjayovz8eJV2PYRjVo+NnepaJUz+jg9ohOPkU2S
Zz68DmyrSddcDCGXopdIXoGrFsoM99Zi8jnSU4bRjgo8HL3zlZnBQNvHSKVPE2j7
Lb257dxndjGxCHOBqmXRUJP1VoYSlLC+5P+v8E9yRwDH7YZzR5Zq6EKOcxc0M+Dp
OyEGH7IsWfNndOqBSSk9U8OP+gX3yR/4P6OW5IImKw0c4bnyxIAI3hIvXO6RwwI5
ScCe+v2cKYJlWWhvtGMkiWyKYAI/TfC6KoEFFux4S6TwpeIq6uYu3e4taJUB3gNg
BvGIO+9IMYNaz3uSGOent2s6pEINNW0KdExlEbS+a5Nh0iz3pEiLKqTbBty2ScPb
gRWgqAFFNFnWm72Bp6fdjHBpzqecf0U=
=hlq5
-----END PGP SIGNATURE-----

lists.vcf

Sam Millman

unread,
Dec 23, 2010, 4:17:16 PM12/23/10
to mongod...@googlegroups.com
"Claiming that MongoDB is just a replacement for SQL is so far off the
mark that it makes me think you haven't really read (or know?) much
about this area."

I've actually found it as a more than satisfactory replacement. As Andreas states it is all in the use case though I understand what you mean :P.


"Essentially, MongoDB is just a replacement for SQL.  Very
disappointing."

Well then you obviously dunno nosql. Should have looked up the term in wikipedia first.


"if a database cannot do that, it's not a object-oriented database.
It's not about what API you use, the data needs to be stored object-
oriented, or the performance will be terrible."

From what I know mongo does a heck of a lot from the API (and JSON can store objects just like I said). If it can map/reduce massive collections with ease and faster than a small join in SQL I'm pretty sure OO would be a walk in the park for it.


"db.topics[id].posts[0].author.displayName == db.author[7].displayName"

With positional operators and a map reduce I think I could do a query based around that....since that is just accessing arrays...think of docments as arrays and subdocuments as arrays in arrays...I'm not actually certain of what your trying to do now. Yes in SQL something like that would require an OO inteface but Mongo works differently and that query would be inert because thats not how you layout your nosql schema.


--
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com.
To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.

Ethan Gunderson

unread,
Dec 24, 2010, 10:48:28 AM12/24/10
to mongod...@googlegroups.com
You know what's funny? You could replace MongoDB with MySQL or Postgres, and that paragraph would still be true :)

Most developers have a nasty habit of defaulting to a certain technology stack, and applying it to all problems without any real analysis of their problem space. This problem does not solely exist in the Mongo community.

/rant

-Ethan

Andreas Jung

unread,
Dec 24, 2010, 11:01:13 AM12/24/10
to mongod...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ethan Gunderson wrote:
> You know what's funny? You could replace MongoDB with MySQL or Postgres,
> and that paragraph would still be true :)
>
> Most developers have a nasty habit of defaulting to a certain technology
> stack, and applying it to all problems without any real analysis of
> their problem space. This problem does not solely exist in the Mongo
> community.

Absolutely true - I can only agree.

As former Zope release manager and core developer I am using the ZODB (a
true object database/storage) for more than ten years.

During that time a lot of other developers considered the ZODB as "the
tool" for all-and-everything. The basic problem here is that a bunch
of "developers" don't have enough background and insight in basic
foundations of programming and computer science.

Andreas


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQGUBAEBAgAGBQJNFMPIAAoJEADcfz7u4AZjXKwLv03axrBeJXKROzK6zYZuIS9E
HQSobxUpI00ILDsbP0ecA2fPhGaew9t2mX80vrl4zbdytMaOCMyExumORQ3MLcyl
LTE48QaGip9oejEu8lQxhyjfnZba662SO5akB6ofxs59zu1j0wWcbY+peA2C3hI5
IBU+xHaZs94WJ1b57spDH8PFHgFA1Xrc9eV+YV7HqpRoiRALYTjWCxoU1b0sjoRa
g/8was9YyyDfyrX+1s6eY+D1HG5eKXEivLfaZIJOwwvB4LYQPbl+9fFVNDi4P0CX
v2PyO5aNCIMR6ihtGm+IoIkbAfYok7IGv2GscSfRn6ytyXYFVDQCc7z/cxRaCZH+
8b++t3Jz5pd/1cBzBq57DeOWLo6tO17gWRpcwxA4R8ZLFPkGK19GVAMig8DxSV2W
OuWhppCyps6Bf3EmQs/jt+YOVg0UxYRrHETg1MS0y6X3rBFO8tE6AXtjSp5uWTsF
R3JNT746nanZePDHI/QRd1dHYB9fZwQ=
=VAVR
-----END PGP SIGNATURE-----

lists.vcf
Reply all
Reply to author
Forward
0 new messages