資料庫索引、外鍵和DAO實作
Jimmy
B tree�
平衡二元搜尋樹
B tree
4KB
資料放在硬碟裡會導致I/O問題
在一個節點內,多塞些東西,為了減少 i/o 讀取次數
B+ tree ( InnoDB )�
索引 (index)
單列索引 & 多列索引
select * from student
where first_name = 'Paul'
and last_name = 'George'
and age = 18
ALTER TABLE student ADD INDEX fname_lname_age (first_name,last_name,age)
最左字首 Leftmost Prefixing
外鍵
customer => PK: id
order=> FK: customer_id ( 確保有這個 customer 才可以新增這筆訂單 )
可以利用�show create table <tablename>�看到現在外鍵的狀態
DAO (Data Access Object)
/dao/products.js