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