Database Reference
In-Depth Information
A RDBMS record is comparable to a MongoDB document. A MongoDB document is a
perfect name for what it is - a document. Think of all of the documents you come into
contact with during a typical day: invoices, packing slips, menus, blog postings, receipts,
etc. All of these are documents in the same sense as a MongoDB document. They are all
a set of somewhat related data often viewed together. Documents are composed of fields,
which will be discussed shortly. For example, here is a MongoDB document based upon
our Order example (Order is one document containing three lines):
Order:
{ orderNumber : “4839-02”,
orderShortDescription : “Professor review copies of several titles”,
orderScheduledDeliveryDate : ISODate(“2014-05-15”),
orderActualDeliveryDate : ISODate(“2014-05-17”),
orderWeight : 8.5,
orderTotalAmount : 19.85,
orderTypeCode : “02”,
orderTypeDescription : “Universities Sales”,
orderStatusCode : “D”,
orderStatusDescription : “Delivered”,
orderLine :
[ { productID : “9781935504375”,
orderLineQuantity : 1
},
{ productID : “9781935504511”,
orderLineQuantity : 3
},
{ productID : “9781935504535”,
orderLineQuantity : 2
} ] }
In this example the Order document contains one order with three order lines. A document
begins and ends with the squiggly braces { }, and the fields within the document are sep-
arated by commas. The square brackets [ ] contain arrays. Arrays can contain individual
values or sub-documents, themselves surrounded by squiggly braces. Storing dates such as
orderScheduledDeliveryDate in ISO format allows you to use standard date functional-
ity such as performing range queries, sorting dates, and even determining the day of the
week. [3] Notice that in OrderLine , there is a reference back to the three products. More on
references shortly!
Search WWH ::




Custom Search