Database Reference
In-Depth Information
come from the process identifier of the ObjectId-generating process. These first nine bytes
of an ObjectId guarantee its uniqueness within a single second. The last three bytes are an
incrementing counter that is responsible for uniqueness within a second in a single process.
This allows for up to 16,777,216 unique ObjectIds to be generated per process per second!
Here are some sample ObjectIds:
ObjectId(“5280bd3711b3c2b87b4f555d”)
ObjectId(“5280bd3711b3c2b87b4f555e”)
ObjectId(“5280bd3711b3c2b87b4f555f”)
FOREIGN KEY
The entity on the “one” side of the relationship is called the parent entity, and the entity on
the “many” side of the relationship is called the child entity. When we create a relationship
from a parent entity to a child entity, the primary key of the parent is copied as a foreign
key to the child.
A foreign key is one or more attributes that provide a link to another entity. A foreign key
allows a relational database management system to navigate from one table to another. For
example, if we need to know the customer who owns an account, we would want to include
the Customer ID in the Account entity. The Customer ID in Account is the primary key
for Customer .
Using this foreign key back to Customer enables the database management system to nav-
igate from a particular account or accounts to the customer or customers that own each ac-
count. Likewise, the database can navigate from a particular customer or customers to find
all of their accounts. Our data modeling tools automatically create a foreign key when a
relationship is defined between two entities.
In our Student / Class model, there are two foreign keys in Attendance . The Student Num-
ber foreign key points back to a particular student in the Student entity, and the Class ID
foreign key points back to a particular Class in the Class entity:
Student Number Class ID Attendance Date
Search WWH ::




Custom Search