Database Reference
In-Depth Information
SM385932
1
5/10/2013
EM584926
1
5/10/2013
EM584926
2
6/10/2013
MM481526
2
6/10/2013
MM573483
2
6/10/2013
LR731511
3
7/10/2013
By looking at these values and recalling the students referenced by the Student Number
and classes reference by Class ID , we learn that Steve Martin and Eddie Murphy both at-
tended the Data Modeling Fundamentals class on 5/10/2013 . Eddie Murphy also attended
the Advanced Data Modeling Class with Mickey and Minnie Mouse on 6/10/2013 . Lone
Ranger took Tennis Basics (by himself, as usual) on 7/10/2013 .
MongoDB Reference = RDBMS Foreign Key
The concept of a foreign key in relational databases is similar to the concept of a reference
in MongoDB. Both a foreign key and a reference provide a way to navigate to another
structure. The difference, though, is that the relational database automatically ensures each
foreign key value also exists as a value in the originating primary key. That is, if there is a
Product ID foreign key in Order Line originating from Product , every Product ID value
in Order Line must also exist in Product . This check of valid values from foreign keys
back to their primary keys is called “referential integrity” (or RI for short). In MongoDB,
the reference is simply a way to navigate to another structure (without the RI).
For example, recall our data model:
Search WWH ::




Custom Search