Database Reference
In-Depth Information
Document-oriented data
In this chapter
Schema design
Data models for e-commerce
Databases, collections, and documents
This chapter takes a closer look at document-oriented data modeling and at how
data is organized at the database, collection, and document levels in MongoDB. I'll
start with a brief, general discussion of schema design. This is helpful because a
large number of MongoDB users have never designed schemas for databases other
than the traditional
RDBMS
. This exploration of principles sets the stage for the sec-
ond part of the chapter, where we examine the design of an e-commerce schema in
MongoDB. Along the way, you'll see how this schema differs from an equivalent
RDBMS
schema, and you'll learn how the typical relationships between entities, such
as one-to-many and many-to-many, are represented in MongoDB. The e-commerce
schema presented here will also serve as a basis for our discussions of queries, aggre-
gation, and updates in subsequent chapters.
Since documents are the raw materials of MongoDB, I'll devote the final por-
tion of this chapter to the small details and corner cases surrounding documents
and their environs. This implies a more detailed discussion of databases, collec-
tions, and documents than you've seen up to this point. But if you read to the end,
you'll be familiar with most of the obscure features and limitations of document
55