# What do the commas separating atomic events in a Relational Calculus formula means?

For instance, take the example of this book here on page 30. About the formula $$Q(x,x') = R(x), S(x,y), S(x',y), R(x')$$ described there, what do the commas mean? Is it the same as an "and" operation? Or a natural join maybe?

• It's hard to tell without more context. This is not standard notation so it means what whatever you're reading defined it to mean. If the notation is inspired by Prolog/Datalog, then it is conjunction but then more is going on than that in the above expression. – Derek Elkins May 14 '17 at 23:39
• It might be a Datalog notation but I am not sure. I took it from the book "Probabilistic Databases" from Dan Suciu and Morgan Clayman, link here, on page 30. – Anderson Chaves May 16 '17 at 14:57
• Please edit the question to include all relevant information (including the book citation). Don't just put information in the comments -- we want questions to be self-contained, so people don't have to read the comments to understand the question; and comments can disappear at any time. Thank you! – D.W. May 16 '17 at 22:29
• All right. Done. – Anderson Chaves May 17 '17 at 6:18

The notation is defined on page 17 and 18. The authors define a couple notations and state that they will "freely switch back and forth" between them. This example doesn't seem super-consistent, I'd expect $Q(x,x'):\!\!-\,R(x),S(x,y),S(x',y),R(x')$ rather than an equals sign, but presumably it means $Q(x,x') = \exists y.R(x)\land S(x,y) \land S(x',y)\land R(x')$.

It doesn't really make sense to talk about natural joins in this context, as those rely on named attributes/columns. But yes, this query includes (equi-)joins. To be clear, the comma stands for conjunction. Any joining is implicit in duplicate uses of a variable. In particular, if all variables were used only once in the right hand side, then there would be no equi-joins, even implicitly. In SQL, the query would look something like:

CREATE VIEW Q
AS
SELECT DISTINCT S1.Field1, S2.Field1 AS Field2
FROM S AS S1
INNER JOIN S AS S2 ON S1.Field2 = S2.Field2
WHERE S1.Field1 IN (SELECT Field1 FROM R)
AND S2.Field1 IN (SELECT Field1 FROM R)


or to be more systematic,

CREATE VIEW Q
AS
SELECT DISTINCT S1.Field1, S2.Field1 AS Field2
FROM S AS S1
INNER JOIN S AS S2 ON S1.Field2 = S2.Field2
INNER JOIN R AS R1 ON R1.Field1 = S1.Field1
INNER JOIN R AS R2 ON R2.Field1 = S2.Field1


or going a different direction,

CREATE VIEW Q
AS
SELECT DISTINCT S1.Field1, S2.Field1 AS Field2
FROM S AS S1, S AS S2, R AS R1, R AS R2
WHERE R1.Field1 = S1.Field1
AND S1.Field2 = S2.Field2
AND S2.Field1 = R2.Field1