Well, you don't have to denormalize if you don't need to... you're fine
with what you did, especially when consuming that order one by one... the
only issue you may have is when displaying a list of orders and having just
these 2 ids will make your app to do more requests... so, in my opinion is
all about how are you going to use these orders...
For example, if you need to display client's and suplier's names in order
list, you could add those fields in order collection something like this:
{
...
clientID: ObjectId("s7d5f075s87627d6f798"),
supplierID: ObjectID("234k0873n34982m932")
cname : "Jane Smith",
sname: "Best Buy"
...
}
But I'd suggest to read more about mongodb and schema design. You can start
here
http://www.mongodb.org/display/DOCS/Schema+Design
On Mon, Nov 5, 2012 at 1:03 PM, Claudio Holanda Jr. <claudi...@gmail.com>wrote:
> Hi, after a goodbye kiss to MySQL and some dig into
> MongoDB non-relational way, i've found some questions and couldn't find any
> direct answer to that.
> The mais question about non-relacional databases is, imagine
> this environment:
> I have three tables:
> *Clients | Suppliers | Orders*
> Each one have it's own info:
> *Clients* have phone, name, etc per row,
> *Suppliers* have adress, fax, etc,
> *Orders *(pay attention, now comes the crux) instead, have both clients
> who is ordering, and the Supplier who owns the product.
> In MySQL i would simply create a column called "clientID" and "supplierID"
> to refer to the respective datas.
> *
> *
> *Now the question is:*
> *
> *
> The table clients and Suppliers already have their infos, to transform
> this database into non-relational, how the schema would be?
> Should i made a refer the collection Order to the collection Suppliers and
> Clients? Like:
> {
> ...
> clientID: ObjectId("s7d5f075s87627d6f798"),
> supplierID: ObjectID("234k0873n34982m932")
> ...
> }
> I really can't think in a different way to make it, sorry about that,
> its difficulty to change the way we see database after many years using
> relational ones...
> --
> You received this message because you are subscribed to the Google
> Groups "mongodb-user" group.
> To post to this group, send email to mongodb-user@googlegroups.com
> To unsubscribe from this group, send email to
> mongodb-user+unsubscribe@googlegroups.com
> See also the IRC channel -- freenode.net#mongodb