4约束与触发器.pptVIP

  1. 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
  2. 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  3. 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
  4. 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
  5. 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们
  6. 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
  7. 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
4约束与触发器

第四章 约束与触发器 Integrity constraints 完整性约束 Triggers触发器 Security安全性 Authorization 用户授权 嵌入式SQL 动态SQL Integrity 完整性 Types of Integrity Entity integrity 实体完整性 Referential integrity参照完整性 User-defined integrity用户定义完整性 Entity integrity实体完整性 Key 键码 Keys are attributes or sets of attributes that uniquely identify an entity within its entity set. For example : student(sno,sname,ssex,sage,sdept) key:sno sc(sno,cno,score) key:(sno,cno) Key attribute 键码属性(主属性) In the relation student: sno is a key attribute. In the relation sc: sno is a key attribute and cno is another key attribute. Notes: key attributes == keys Entity integrity实体完整性 The rule of entity integrity is : If attributes A is the key attributes of a basic relation , it’s value cannot be null. For example: in the relation student: sno cannot be null And in the relation sc:sno cannot be null ,also cno cannot be null . Key constraints键码约束in SQL Keys constraints Key constraints means that two tuples of a relation are forbidden to agree on an attribute declared to be a key.or on all of a set attributes that are together declared to form a key. 键码约束是指禁止关系的两个元组在说明为键码的属性上一致,或者禁止在共同构成键码的属性集的所有属性上一致。 For example : student中的sno不能取相同值。 同理:SC 中不能有相同(sno,cno)的组合。即不能出现同一个学生选修同一门课的两个元组。 Key constraints 键码约束 Declaring Keys two ways: Using the key words PRIMARY KEY Using the key words UNIQUE Enforcing实施 key constraints 使用带关键字UNIQUE的索引语句,在为属性建立索引导的同时将属性说明为键码。 Using the index with key word UNIQUE to declare an attribute to be a key at the same time it creates an index on tat attribute. For example: create unique index stu_no on student(sno); How an SQL system enforce a key constraint? 原则上,每当我们试图改变数据库时必须对约束进行检验。但是必须明确只有更新关系时关系的键码约束才可能发生违背。实际上,关系元组的删除操作不会导致违背,只有插入或修改操作才会。因而只有对关系进行插入或修改时才检验实施键码约束。这对于SQL系统已成为通用惯例。而有效实施键码约束,建立索引是非常重要的。 在单个关系上的完整性约束Integrity Constraints on a Single Relation not null primary key unique check (P), where P is a predicate Not-null

文档评论(0)

zilaiye + 关注
实名认证
文档贡献者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档