DP-420 Exam QuestionsBrowse all questions from this exam

DP-420 Exam - Question 50


HOTSPOT -

You have a database named telemetry in an Azure Cosmos DB Core (SQL) API account that stores IoT data. The database contains two containers named readings and devices.

Documents in readings have the following structure.

✑ id

✑ deviceid

✑ timestamp

✑ ownerid

✑ measures (array)

- type

- value

- metricid

Documents in devices have the following structure.

✑ id

✑ deviceid

✑ owner

- ownerid

- emailaddress

- name

✑ brand

✑ model

For each of the following statements, select Yes if the statement is true. Otherwise, select No.

NOTE: Each correct selection is worth one point.

Hot Area:

Exam DP-420 Question 50
Show Answer
Correct Answer:
Exam DP-420 Question 50

Box 1: Yes -

Need to join readings and devices.

Box 2: No -

Only readings is required. All required fields are in readings.

Box 3: No -

Only devices is required. All required fields are in devices.

Discussion

7 comments
Sign in to comment
jdsherrington
Aug 17, 2023

Answer is NYN. 1. N: The readings container does not need to be read to return all deviceids associated with a particular emailaddress, so only one query is needed: SELECT * FROM devices d WHERE d.owner.emailaddress = ________ 2. Y: measures is an array, and to filter or project fields from an array, you need to use join to create a cross join with the array. SELECT r.deviceid, r.ownerid, r.timestamp, m.value FROM readings r JOIN m IN r.measures WHERE m.metricid = ________ 3. N: owner is an object, not an array, so you can directly access the properties. deviceid, ownerid, emailaddress and model all exist in the devices container, so the readings container is not needed. SELECT d.deviceid, d.owner.ownerid, d.owner.emailaddress, d.model FROM devices d

SwePha
Nov 13, 2023

Awesome explanation

WimTS
Apr 17, 2025

exact, only it should be d.name.model

grada
Jul 15, 2022

Who ever wrote the suggested responses has no idea of what a JOIN does in a document database... it has nothing to do with joining documents, but is an inner-document join. It's NYN if the first questions means returning only devices, and none of the readings. It's YYN otherwise, because readings are in a separate container, and should be fetched using a second query.

Internal_Koala
Sep 25, 2022

No. Yes. Yes. ==================== First: No SELECT * FROM d WHERE d.emailaddress = "To return (?) for all devices ...". Sounds like the word "metrics" might be missing. If so, the answer is Yes and a second query must be added. =========== SELECT d.deviceid FROM d WHERE d.emailaddress = ? SELECT * FROM m WHERE m.deviceid = @deviceid ==================== Second: Yes SELECT m.deviceid FROM m WHERE m.metricid = ? SELECT d.deviceid, o.ownerid, d.timestamp FROM d JOIN o IN d.owner WHERE d.deviceid = @deviceid ==================== Third: Yes SELECT d.deviceid, o.ownerid, d.emailaddress, d.model FROM d JOIN o IN d.owner

susejzepol
Nov 23, 2022

i think like you.

nope1234567
Dec 18, 2022

I disagree on the second one. All fields to return are in the Readings container, why would you need to join the second container ? FK are sufficients here

kdsingh
May 9, 2022

The correct answer is YYN - Yes: you need 2 requests, because the data is in 2 different containers. - Yes: you need join to get the data from Array - No: No joins required

ognamala
Aug 15, 2022

Why would the second one be yes ? We dont need any data from the array.

Alex22022
Jan 24, 2023

Because you need value and metricid properties from the measures array.

Alex22022
Jan 24, 2023

Because you need value and metricid properties from the measures array.

avocacao
Dec 21, 2022

Y - requires 2 requests to get from 2 containers Y - need join to get 'value' in measures array Y - need join to get 'ownerid' and 'emailaddress' in owner array https://learn.microsoft.com/en-us/azure/cosmos-db/nosql/query/join

Alex22022
Jan 24, 2023

Third - No; Devices container: select c.deviceId, c.owner.ownerId, c.owner.emailaddress, c.model from c

Shiven
Aug 18, 2023

N - Device container has all required info. N - In Reading container we have everything. Y - Need to join 2 containers.

azuredemo2022three
Jun 28, 2023

Answer YYN