I have been learning about SQL and at times it feels like set theory. A statement like SELECT * FROM myTable
is like a set $\{ x: x \in \text{myTable} \}$.
A table could be defined as any subset of the Cartesian product. We could define a table called zipcodes
with a schema city STRING(30), state CHAR(2), zip INTEGER(5)
then in set theory we could define the zipcodes stable as:
$$ zicodes \subseteq \text{cities} \times \text{states} \times \text{zips} \simeq \{a, \dots, Z\}^{30} \times \{a, \dots, Z\} \times \{1, \dots, 10^5\}$$
So any table is a subset of a cartesian product.
My theory has limitations, since you can't store all of $\mathbb{R}$ as a SQL database (e.g. by cantor diagonalization) since $|\mathbb{R}| > |\mathbb{Z}|$ in cardinality.
In any case, do any theories of SQL exist that compare it to set theory?