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