發表文章

目前顯示的是有「資料庫」標籤的文章

Java(物件導向) 與 SQL 的概念衝突

圖片
Java(物件導向) 與 SQL 的概念衝突 The paradigm mismatch : Java : public class User { String username; String address; Set billingDetails; // Accessor methods (getter/setter), business methods, etc. } public class BillingDetails { String account; String bankname; User user; // Accessor methods (getter/setter), business methods, etc. } SQL : create table USERS ( USERNAME varchar(15) not null primary key, ADDRESS varchar(255) not null ); create table BILLINGDETAILS ( ACCOUNT varchar(15) not null primary key, BANKNAME varchar(255) not null, USERNAME varchar(15) not null, foreign key (USERNAME) references USERS ); 1. The problem of granularity (SQL 無法自訂 data type) The most glaringly obvious problem with the current implementation is that you’ve designed an address as a simple String value. In most systems, it’s necessary to store street, city, state, country, and ZIP code information se...

資料庫 - Indexing 介紹

圖片
DataBase - Indexing Indexing 介紹 Index 可以想成是一種儲存在資料庫(DataBase)裡的資料結構(Data Structure),Index會對映一個或多個欄位上(field or column),並存一個相對應欄位值的指標來指向欄位值<data value, data rid>。 Primary index : 代表被設定index的欄位本身就是表單的Primary Key,由於Primary Key本身就會有一個預設的index(由資料庫自動生成),所以此時的index會直接帶入原本的值。 Secondary index : 為一般的index其值須自行設定。 用途 : 加快搜尋特定資料(ex : where age = 10; where age > 18 and age < 30)的速度。