@@ -12,7 +12,7 @@ Database References
12
12
.. contents:: On this page
13
13
:local:
14
14
:backlinks: none
15
- :depth: 1
15
+ :depth: 2
16
16
:class: singlecol
17
17
18
18
For many use cases in MongoDB, the denormalized data model where
@@ -32,6 +32,11 @@ or databases.
32
32
This page outlines alternative procedures that predate the
33
33
:pipeline:`$lookup` and :pipeline:`$graphLookup` pipeline stages.
34
34
35
+ You can create a database reference for deployments hosted in the
36
+ following environments:
37
+
38
+ .. include:: /includes/fact-environments.rst
39
+
35
40
MongoDB applications use one of two methods to relate documents:
36
41
37
42
- :ref:`Manual references <document-references>` save the
@@ -72,8 +77,75 @@ A manual reference is the practice of including one
72
77
application can then issue a second query to resolve the referenced
73
78
fields as needed.
74
79
75
- Process
76
- ~~~~~~~
80
+ Create a Manual Reference in the {+atlas+} UI
81
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
82
+
83
+ To create a manual reference in the {+atlas+} UI, follow these steps:
84
+
85
+ .. procedure::
86
+ :style: normal
87
+
88
+ .. step:: Navigate to the collection.
89
+
90
+ a. In the {+atlas+} UI, click :guilabel:`Database` in the sidebar.
91
+ #. For the database deployment where you want to add a database
92
+ reference, click :guilabel:`Browse Collections`.
93
+ #. In the left navigation pane, select the database.
94
+ #. In the left navigation pane, select the collection. This
95
+ example references a ``places`` collection.
96
+
97
+ .. step:: Add a document.
98
+
99
+ a. Click :guilabel:`Insert Document`.
100
+ #. Click the JSON view icon (:guilabel:`{{}}`).
101
+ #. Paste the following data into the document:
102
+
103
+ .. code-block::
104
+
105
+ {
106
+ "_id": {
107
+ "$oid": "651aea5870299b120736f442"
108
+ },
109
+ "name": "Broadway Center",
110
+ "url": "bc.example.net"
111
+ }
112
+
113
+ #. Click :guilabel:`Insert`.
114
+
115
+ .. step:: Add a document in the ``people`` collection that references the entry in ``places``.
116
+
117
+ a. In the left navigation pane, select a different
118
+ collection. This example references a ``people`` collection.
119
+ #. Click :guilabel:`Insert Document`.
120
+ #. Click the JSON view icon (:guilabel:`{{}}`).
121
+ #. Paste the following data into the document:
122
+
123
+ .. code-block::
124
+
125
+ {
126
+ "_id": {
127
+ "$oid": "651aebeb70299b120736f443"
128
+ },
129
+ "name": "Erin",
130
+ "places_id": "651aea5870299b120736f442"
131
+ "url": "bc.example.net/Erin"
132
+ }
133
+
134
+ #. Click :guilabel:`Insert`.
135
+
136
+ When a query returns the document from the ``people``
137
+ collection you can, if needed, filter the query results from
138
+ the ``places`` collection for the document referenced by the
139
+ ``places_id`` field.
140
+
141
+ To learn more about running queries in {+atlas+},
142
+ see :atlas:`View, Filter, and Sort Documents
143
+ </atlas-ui/documents/#view--filter--and-sort-documents>` in
144
+ the {+atlas+} documentation.
145
+
146
+
147
+ Create a Manual Reference in the Terminal
148
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
77
149
78
150
Consider the following operation to insert two documents, using the
79
151
``_id`` field of the first document as a reference in the second
0 commit comments