資料庫常出現null值,但大致來說,其可能有下列三種可能性:
1. Unknown value - 例如某位員工的生日無從得知,所以就用null
2. Unavailable or withheld value - 例如某位員工只有家用電話號碼而無公司用電話號碼
3. Not applicable attribute - 例如某位學生沒有大學學歷,故沒有主修科目的資料
資料庫常出現null值,但大致來說,其可能有下列三種可能性:
1. Unknown value - 例如某位員工的生日無從得知,所以就用null
2. Unavailable or withheld value - 例如某位員工只有家用電話號碼而無公司用電話號碼
3. Not applicable attribute - 例如某位學生沒有大學學歷,故沒有主修科目的資料
三種刪除資料的限制的處理方式
1. Restric ; 無法刪除
2.Cascade; 當刪除資料時,一併行除其相關連的資料
3.Set null or set default; 當刪除資料時,將期關連的資料設為null或設為預設值
常用的SQL指令如下:
SELECT <attribute and function list>
FROM <table list>
[WHERE <condition>]
[GROUP BY <grouping attribute>]
[HAVING <group condition>]
[ORDOR BY <attribute>]
Aggreagte Function in SQL
COUNT(*), COUNT (DISTINCT *), AVG(*), SUM(*), MAX(*), MIN(*)
EXISTS, NOT EXISTS Funciton in SQL
SELECT
FROM
WHERE EXISTS (........有值=True)
SELECT
FROM
WHERE NOT EXISTS (.........無值=Ture)
常見的資料庫限制(Database Constraint)大致上可分為三類:
1.Inherent model-based constaints 或 Implicit constraints
2.Schema-based constaints 或Explicit constraints
3.Application-based 或Semantic constaints或Business rule
在資料庫系統的定義中:
Tuple代表資料中的行;
Attribute代表每個欄位的屬性
Table代表各欄位的關係
Atomic 指的是不能再切割的值
Domain指的是所允許格式的範圍
Relation schema就是meta-data指的是一組Attribute清單
Conceptual design: that can be represented and manipulated using some computerized tools so that it can be easily maintained, modified, and transformed into a data baesd implementation. Such as: ER model (Entity-Relationship model)
Logical design:that can be expressed in a data model implemented in a commerical DBMS. Such as: Relational Data Model
Physical design: during which further specifications are provided for storing and accessing the database
Source: Database Systems by Rmaes Elmasri
下表可以看出其在不同特性上的差異: