数据库 sql和关系代数

疑惑:在数据库理论学习中,会学到关系代数(Relational Algebra),为什么要学它? 它和sql语言有什么关系?

看完参考资料后,我的总结:

1. What is Relational Algebra?

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.)


2. Why? 

  • The inner, lower-level operations of a relational DBMS are, or are similar to, relational algebra operations. We need to know about relational algebra to understand query execution and optimization in a relational DBMS.

3. RA vs. SQL

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

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值