Chapter 4: Advanced CRUD Operations Lab 2: Logic Operators

(Founded in 2004) AND (social OR web) OR (founded in October) AND (social OR web) is not the same as
(Founded in 2004 OR founded in October) AND (social OR web). The wording eludes to the answer should be 157 not 149? Please explain…

Why would it not be the same? Please provide a case where it is not.

According to the distribution law, https://www.mathreference.org/index/page/id/320/lg/en, of (A or B) and C is equivalent to (A and C) or (B and C).

let A == year == Founded:2004
let B == month == Founded:October
let C == (social OR web)
then
(Founded in 2004 OR Founded in October) AND (social OR web)
is
(A or B) and C
so by distribution law we get
(A and C) or (B and C)
which is
(year and C) or (month and C)

What I suspect, is that you tried both (which is good), but some misplaced braces or brackets does not give you the logic you thought it would. To find the root cause of your confusion, it would be good to share the 2 queries you tried.

And look at https://docs.mongodb.com/manual/reference/operator/query/in/

2 Likes

Misplaced brackets!!! Led me to believe the logic was not sound. Thanks for the explanation, Steeve!