Abstract
We present an algebra for the classical database operators. Contrary to most approaches we use (inner) join and projection as the basic operators. Theta joins result by representing theta as a database table itself and defining theta-join as a join with that table. The same technique works for selection. With this, (point-free) proofs of the standard optimisation laws become very simple and uniform. The approach also applies to proving join/projection laws for preference queries. Extending the earlier approach of [16], we replace disjointness assumptions on the table types by suitable consistency conditions. Selected results have been machine-verified using the
tool.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Similar content being viewed by others
Notes
- 1.
With this we follow the SQL standard. Note, however, that \(P \!\bowtie \!\theta \!\bowtie \!Q\) is defined even if this disjointness condition does not hold. It is not even necessary to require \(A \ne B\), although having \(A = B\) is not interesting.
- 2.
We use this example only for motivation; strictly speaking an interchange law needs to have the same variables on both sides.
- 3.
Equation (7) is valid for concrete relations. For abstract relations, only \(\subseteq \) holds. This phenomenon is called unsharpness in the literature (an early mention is [18], a further elaboration [1]). The situation is similar with Lemma 8.6.4. The paper [15] constructs an RA that does not satisfy sharpness.
References
Berghammer, R., Haeberer, A., Schmidt, G., Veloso, P.: Comparing two different approaches to products in abstract relation algebra. In: Nivat, M., Rattray, C., Rus, T., Scollo, G. (eds.) AMAST 1993, pp. 167–176. Springer, Heidelberg (1993). https://doi.org/10.1007/978-1-4471-3227-1_16
Berghammer, R., von Karger, B.: Relational semantics of functional programs. In: Brink, C., Kahl, W., Schmidt, G. (eds.) Relational Methods in Computer Science. Advances in Computing Science, pp. 115–130. Springer, Heidelberg (1997). https://doi.org/10.1007/978-3-7091-6510-2_8
Dang, H.-H., Höfner, P., Möller, B.: Algebraic separation logic. J. Logic Algebraic Program. 80(6), 221–247 (2011)
Dang, H.-H., Möller, B.: Reverse exchange for concurrency and local reasoning. In: Gibbons, J., Nogueira, P. (eds.) MPC 2012. LNCS, vol. 7342, pp. 177–197. Springer, Heidelberg (2012). https://doi.org/10.1007/978-3-642-31113-0_10
Desharnais, J., Möller, B., Struth, G.: Modal Kleene algebra and applications – a survey. J. Relational Methods Comput. Sci. 1, 93–131 (2004)
Desharnais, J., Möller, B., Struth, G.: Kleene algebra with domain. ACM Trans. Comput. Logic 7, 798–833 (2006)
Haeberer, A., Frias, M., Baum, G., Veloso, P.: Fork algebras. In: Brink, C., Kahl, W., Schmidt, G. (eds.) Relational Methods in Computer Science. Advances in Computing Science, pp. 54–69. Springer, Heidelberg (1997)
Horn, R., Johnson, C.: Topics in Matrix Analysis. Cambridge University Press, Cambridge (1991)
Kahl, W.: CalcCheck: a proof checker for teaching the “logical approach to discrete math”. In: Avigad, J., Mahboubi, A. (eds.) ITP 2018. LNCS, vol. 10895, pp. 324–341. Springer, Cham (2018). https://doi.org/10.1007/978-3-319-94821-8_19
Kahl, W.: CalcCheck—A proof-checker for Gries and Schneider’s Logical Approach to Discrete Math. http://calccheck.mcmaster.ca/
Kanellakis, P.: Elements of relational database theory. In: van Leeuwen, J. (ed.) Handbook of Theoretical Computer Science. Volume B: Formal Models and Semantics, pp. 1073–1156. Elsevier (1990)
Kießling, W.: Preference queries with SV-semantics. In: International Conference on Management of Data (COMAD 2005), pp. 15–26 (2005)
Kießling, W., Endres, M., Wenzel, F.: The preference SQL system – an overview. Bull. Tech. Committee Data Eng. 34(2), 11–18 (2011). http://www.markusendres.de/preferencesql/
Kießling, W., Hafenrichter, B.: Algebraic optimization of relational preference queries. Technical report No. 2003–01. University of Augsburg, Institute of Computer Science, February 2003
Maddux, R.: On the derivation of identities involving projection functions. In: Csirmaz, L., Gabbay, D., de Rijke, M. (eds.) Logic Colloquium ’92. Studies in Logic, Languages, and Information, pp. 143–163. CSLI Publications (1995)
Möller, B., Roocks, P.: An algebra of database preferences. J. Logical Algebraic Methods Program. 84(3), 456–481 (2015)
Schmidt, G., Ströhlein, T.: Relations and Graphs: Discrete Mathematics for Computer Scientists. EATCS Monographs on Theoretical Computer Science. Springer, Heidelberg (1993). https://doi.org/10.1007/978-3-642-77968-8
Zierer, H.: Programmierung mit Funktionsobjekten: Konstruktive Erzeugung semantischer Bereiche und Anwendung auf die partielle Auswertung. Institut für Informatik, Technische Universität München. Report TUM-I8803, February 1988
Acknowledgement
Helpful comments were provided by Patrick Roocks, Andreas Zelend and the anonymous referees.
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
14 Appendix
14 Appendix
For types \(T_P, T_Q\) we use the notion of a direct product of \(D_P\) and \(D_Q\) (e.g. [17]). This is a pair \((\rho _P, \rho _Q)\) of relations with \(\rho _P \subseteq (D_P \times D_Q) \times D_P\) and \(\rho _Q \subseteq (D_P \times D_Q) \times D_Q\) such that
![](http://media.springernature.com/lw292/springer-static/image/chp%3A10.1007%2F978-3-030-43520-2_4/MediaObjects/492804_1_En_4_Equ39_HTML.png)
Using this concept the parallel product can be represented as
![](http://media.springernature.com/lw251/springer-static/image/chp%3A10.1007%2F978-3-030-43520-2_4/MediaObjects/492804_1_En_4_Equ5_HTML.png)
The following properties of direct products are used in the main proofFootnote 3:
![](http://media.springernature.com/lw145/springer-static/image/chp%3A10.1007%2F978-3-030-43520-2_4/MediaObjects/492804_1_En_4_Equ6_HTML.png)
![](http://media.springernature.com/lw427/springer-static/image/chp%3A10.1007%2F978-3-030-43520-2_4/MediaObjects/492804_1_En_4_Equ7_HTML.png)
Proof of Lemma 12.5. The proof consists in showing (see Lemma 10.3.3). We do this by showing the stronger property
, from which the original claim follows by
and isotony of \(\mathbin {;}\).
Since “joinable” is defined with \(\mathbin {\#}\) and the formula to prove uses , we have to make a connection between the two:
![](http://media.springernature.com/lw154/springer-static/image/chp%3A10.1007%2F978-3-030-43520-2_4/MediaObjects/492804_1_En_4_Equ8_HTML.png)
This is analogous to the conversion of a relation to a vector explained in [17], which would give . The inverse transformation is
. Both equations are easily verified. Using restriction (Lemma 2.1.7) and Boolean algebra, the second one can be simplified to
. Then by Definition 12.4 and the definition of diamond (Definition 6.1) P is joinable with Q iff
![](http://media.springernature.com/lw160/springer-static/image/chp%3A10.1007%2F978-3-030-43520-2_4/MediaObjects/492804_1_En_4_Equ9_HTML.png)
Now we calculate as follows.
![figure t](http://media.springernature.com/lw685/springer-static/image/chp%3A10.1007%2F978-3-030-43520-2_4/MediaObjects/492804_1_En_4_Figt_HTML.png)
Rights and permissions
Copyright information
© 2020 Springer Nature Switzerland AG
About this paper
Cite this paper
Desharnais, J., Möller, B. (2020). The \(\theta \)-Join as a Join with \(\theta \). In: Fahrenberg, U., Jipsen, P., Winter, M. (eds) Relational and Algebraic Methods in Computer Science. RAMiCS 2020. Lecture Notes in Computer Science(), vol 12062. Springer, Cham. https://doi.org/10.1007/978-3-030-43520-2_4
Download citation
DOI: https://doi.org/10.1007/978-3-030-43520-2_4
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-030-43519-6
Online ISBN: 978-3-030-43520-2
eBook Packages: Computer ScienceComputer Science (R0)