关系数据库是信息的集合,这些信息通过定义的关系组织数据点以便于访问。在关系数据库模型中,数据结构——包括数据表、索引和视图——与物理存储结构保持分离,使数据库管理员能够在不影响逻辑数据结构的情况下编辑物理数据存储。
在企业中,关系数据库用于组织数据并识别关键数据点之间的关系。它们使分类和查找信息变得容易,这有助于组织更有效地做出业务决策并最大限度地降低成本。它们可以很好地处理结构化数据。
Relational Databases是如何工作的?
关系数据库中使用的数据表存储有关相关对象的信息。每行都包含一个具有唯一标识符(称为键)的记录,每列包含数据的属性。每条记录为每个特征分配一个值,使数据点之间的关系易于识别。
关系数据库的标准用户和应用程序接口 ( API ) 是结构化查询语言。SQL 代码语句既用于交互式查询关系数据库中的信息,也用于收集报告数据。必须遵循定义的数据完整性规则,以确保关系数据库准确且可访问。
关系数据库与关系数据库管理系统
虽然关系数据库根据关系数据模型组织数据,但关系数据库管理系统 (RDBMS) 是对底层数据库软件的更具体的参考,使用户能够维护它。这些程序允许用户在系统中创建、更新、插入或删除数据,它们提供:
- 数据结构
- 多用户访问
- 权限控制
- 网络访问
Relational Databases的优势
使用方便
凭借其产品生命周期,关系数据库周围有更多的社区,这部分地延续了它的持续使用。SQL 还可以轻松地从多个表中检索数据集并执行简单的转换,例如过滤和聚合。
减少冗余
关系数据库可以通过两种方式消除冗余。关系模型本身通过称为规范化的过程减少数据冗余。如前所述,客户表应该只记录客户信息的唯一记录,而不是为多个事务复制此信息。
易于备份和灾难恢复 关系数据库是事务性的——它们保证整个系统的状态在任何时候都是一致的。大多数关系数据库都提供简单的导出和导入选项,使备份和恢复变得轻而易举。即使在数据库运行时也可能发生这些导出,从而使故障恢复变得容易。
Relational Databases COMP2400 代写案例
Question 1: SQL and the Relational Mode0l
1. a General Concepts
1. a (i)
Explain the relationship of data independence with the ANSI/SPARC three level archi- tecture.
Answer: Refer to the text book and lecture notes.
1. a (ii)
Which of the following statements are true for a relation?
(1) Each superkey is a candidate key.
(2) Each candidate key is a superkey.
(3) The primary key is a candidate key, but there may be a candidate key that is not a primary key.
1. a (iii)
Given the sets A={Sue, Ali},B={white, black}and C={cat, dog}, what is the
Cartesian product A×B×C?
Answer:
A×B×C={(Sue, white, cat)
(Sue, white, dog)
(Sue, black, cat)
(Sue, black, dog)
(Ali, white, cat)
(Ali, white, dog)
(Ali, black, cat)
(Ali, black, dog)}
1. b Writing SQL
Not relevant to the final examination this year
1. c SQL Evaluation
Not relevant to the final examination this year
1. d Integrity Constraints
1. d (i)
Suppose that the relation SUPERVISE was created as follows:
CREATE TABLE SUPERVISE (
pssn INT REFERENCES PROFESSOR(ssn) ON DELETE NO ACTION,
gid INT REFERENCES GRADUATE(gid) ON DELETE SET NULL,
pid INT REFERENCES PROJECT(pid) ON DELETE CASCADE,
PRIMARY KEY(pssn, gid, pid)
);
Which of the following statements are true, and which are false?
(a) If we delete a tuple from SUPERVISE, any tuples in PROJECT referred to by this tuple are also deleted.
(b) If we delete a tuple from GRADUATE, some tuples of SUPERVISE may have their
values of attribute gid set to NULL.
(c) If we try to insert a tuple into PROFESSOR, with an ssn that does not exist in SUPERVISE, the operation is rejected. (d) If we try to insert a tuple into SUPERVISE, with a gid that does not exist in GRAD-UATE, the operation is rejected.

1. d (ii)
Consider the relation BOOK in Figure 1, which has the primary key {bid}and the
foreign key [aid]⊆AUTHOR[aid].
BOOK
bid title language date aid
1 The Plague French 1947 4
2 The Cat in the Hat English 1957 2
3 The Hobbit English 1937 1
4 The Lord of the Rings English 1954 1
AUTHOR
aid name
1 J.R.R.Tolklen
2 Dr. Seuss
3 S.E.Hinton
4 Albert Camus
Figure 1: Relation BOOK and AUTHOR
•Write down an SQL statement to modify an existing tuple in AUTHOR which
would yield a key integrity violation. The modification should not violate any
other integrity constraints.
Answer:
UPDATE AUTHOR
SET aid = 2
WHERE name = “S.E.Hinton”;
•Write down an SQL statement to insert a tuple into BOOK which would yield an
entity integrity violation. The insertion should not violate the existing foreign
key constraint.
Answer:
INSERT INTO BOOK
VALUES (NULL, “Fire”, English, 1980, 1);