疑惑:在数据库理论学习中,会学到关系代数(Relational Algebra),为什么要学它? 它和sql语言有什么关系?
看完参考资料后,我的总结:
From wiki:
Relational algebra, first created by Edgar F. Codd while at IBM, is a family of algebras with a well-founded semantics used for modelling the data stored in relational databases, and defining queries on it.
The main application of relational algebra is providing a theoretical foundation for relational databases, particularly query languages for such databases, chief among which is SQL.
From [2]
RA is similar to normal algebra (as in 2+3*x-y), except we use relations as values instead of numbers, and the operations and operators are different.
RA is not used as a query language in actual DBMSs. (SQL instead.)
1. duplicates
Relations are seen as sets of tuples, which means that no duplicates are allowed. SQL behaves differently in some cases. Remember the SQL keyword distinct.
2. procedural? declarative
SQL is declarative, which means that you tell the DBMS what you want, but not how it is to be calculated.
A C++ or Java program is procedural, which means that you have to state, step by step, exactly how the result should be calculated.
Relational algebra is (more) procedural than SQL. (Actually, relational algebra is mathematical expressions.)
1. https://en.wikipedia.org/wiki/Relational_algebra
2. http://www.databasteknik.se/webbkursen/relalg-lecture/index.html
3.https://www.quora.com/What-is-the-difference-or-connection-between-SQL-and-Relational-Algebra
5.http://www.nyu.edu/classes/jcf/CSCI-GA.2433-001/slides/session5/RelationalAlgebra-RelationalCalculus-SQL.pdf
6. http://www.cs.cornell.edu/projects/btr/bioinformaticsschool/slides/gehrke.pdf