版权声明:本文为博主原创文章,转载请标明出处 https://blog.csdn.net/C2681595858/article/details/80946264
3.1 introduction to a relation model
- 关系模式是对表的每个列的描述
- 关系实例是一个表。
- 关系名,字段,域
- 大多数数据库默认可以用一个列的次序号来代表这个列。
- each relation is defined to be a set of unique tuples or rows.
- An alternative convention is to list fields in a specific order refer to a fields by its position.
- relation instances means relation instances that satisfied the domain constraints in the relation scheme.
- degree( arity ):the number of fields.
- cardianlity: the number of rows.
- insert command: when its order is correct we can omit the field name after the into clause.
- delete will delete all the tuples with name equal to smith.
delete
from student
where sname = "smith"
- SQL提供了一些方法来处理外码约束问题:
- 如果删除student中一条记录应该怎么做:
- 删除Enrolled中所有相关的记录。
- 如果有Enrolled中的记录指向要删除的student记录,那么不允许删除。
- 将Enrolled改为默认
- 将Enrolled改为null。
- 约束推迟,如果插入一个元组马上执行约束,那么可能会导致两个表的插入都失败,这是就需要设定约束推迟(deferred).
- 由于视图是通过基本表计算出来的,所以向其插入一条记录,就会改变基本表中的数据。