Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Domain relational calculus
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Examples== Let (A, B, C) mean (Rank, Name, ID) in the Enterprise relation and let (D, E, F) mean (Name, DeptName, ID) in the Department relation All captains of the starship [[USS Enterprise (NCC-1701)|USS Enterprise]]: <math display="block">\left\{ \ {\left\langle A, B, C \right\rangle} \mid {\left\langle A, B, C \right\rangle \in \mathrm{Enterprise} \ \land \ A = \mathrm{'Captain'} } \ \right\}</math> In this example, A, B, C denotes both the result set and a set in the table Enterprise. Names of Enterprise crew members who are in Stellar Cartography: <math display="block">\begin{align} \{ {\left\langle B \right\rangle} & \mid {\exists A, C \ \left\langle A, B, C \right\rangle \in \mathrm{Enterprise} } \\ & \land \ {\exists D, E, F \ \left\langle D, E, F \right\rangle \in \mathrm{Departments} } \\ & \land \ F = C \\ & \land \ E = \mathrm{'Stellar\ Cartography'} \} \\ \end{align}</math> In this example, we're only looking for the name, and that's B. The condition F = C is a requirement that describes the intersection of Enterprise crew members AND members of the Stellar Cartography Department. An alternate representation of the previous example would be: <math display="block">\begin{align} \{ {\left\langle B \right\rangle} & \mid {\exists A, C \ \left\langle A, B, C \right\rangle \in \mathrm{Enterprise} } \\ & \land \ {\exists D \ \left\langle D, \mathrm{'Stellar\ Cartography'}, C \right\rangle \in \mathrm{Departments} } \} \\ \end{align}</math> In this example, the value of the requested F domain is directly placed in the formula and the C domain variable is re-used in the query for the existence of a department, since it already holds a crew member's ID. Both of them written in [[SQL]] will be like:<syntaxhighlight lang="sql"> SELECT B FROM Enterprise JOIN Department ON F = C AND E = 'Stellar Cartography'; </syntaxhighlight>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)