Database Reference
In-Depth Information
•
Format
. A format domain restricts the length and type of the data element such as
a Character(15) format domain limiting the possible values of a data element to at
most 15 characters. A date format limits the values of a data element to valid dates,
and an integer format limits the values to any possible integer.
•
List
. A list domain is more restrictive than a format domain and limits the values
to a specified defined set such as
male
or
female
or
(A,B,C,D)
.
•
Range
. A range domain restricts the data element values to any value between two
other values such as a start and end dates.
MONGODB DATATYPE = RDBMS DATATYPE (FORMAT DOMAIN AT PHYSICAL LEVEL)
A format domain is called a datatype in an RDBMS and also in MongoDB. In MongoDB,
there are only datatype domains (no list or range domains). Here are the main datatype do-
mains:
Format
Description
Example
Only the values
1
(also known as
True
) or
0
(also
known as
False
)
{ studentAlumniIndic-
ator : Boolean }
Boolean
MongoDB does not distinguish all of the different
number varieties present in a RDBMS. The MongoDB
shell defaults to 64-bit floating point numbers.
{ meaningOfLife :
42.153 } or { meanin-
gOfLife : 42 }
Number
{ meaningOfLife :
"forty two" }
String
Any string of UTF-8 characters.
{ orderEntryDate :
new Date( ) }
Date
Dates are captured as milliseconds since the epoch.
Arrays can be ordered (such as for queues or lists) or
unordered (such as for sets). Also, arrays can contain
{ author : [ “Bill
Jones”, “Tom Hanks”,
Array