SQL查詢初學者指南讀書筆記(一)關係資料庫和SQL介紹
阿新 • • 發佈:2019-01-28
PART I:Relational Databases and SQL
Chapter2, Ensuring Your Database Structure IsSound.
資料庫設計準則
什麼是關係資料庫
RDBMS (A Relational database management systems)關係資料庫
Tables
Tables are the mainstructures in the database. Each table always represents a
single, specific subject.
Fields
A field is the smallest structure in the database, and it represents a characteristic
of the subject of the table to which it belongs.
Records
A record represents a unique instance of the subject of a table.
Keys
Keys are special fields that play very specific roles with in a table.eg.
- primary key
- foreign key
主鍵的最主要作用是保證資料記錄的唯一性,就是說主鍵約束要保證在一個數據庫表裡的所有的資料記錄都是不同的個體,例如:身份證號碼可以保證一個人在大陸範圍內是一個獨立的個體(弄錯了的不算),即一個身份證號碼不能標識兩個人或兩個身份證號碼標識一個人。所以主鍵是從現有的資料裡分析出來的,不是設計人員隨意加上去的。
Relationships
- one-to-one
- one-to-many
- many-to-many