19. Type
handling
• 了解 Framework
如何處理變數
– DB
Column
Type
or
Input
Data
Type
?
– bindParam
with
custom
query
• SELECT
a.user
as
aa
,
a.passwd
as
bb
WHERE
aa
=
?
AND
bb
=
?
• Resqul
Services
• XML
• JSON
27. Big
Data
• 你的
Big
Data
– 百萬筆級
• 別人的 Small
Data
– VIVIPOS
單一客戶
-‐
(ec2
large
+
500G
EBS)
• 1000
transactons/day
• 1500
clients
• 4
*365
years
=
2,190,000,000
(21億筆)
• 我的 Big
Data,
金融業的 Small
Data
– 一天幾百萬上下
28. PostgreSQL
特殊功能
• Partton
Table
• Partal
Index
• DBLink
– Connect
Remote
DB
Server
as
View
• Data
Wrappers
– MySQL
/
Oracle
/
Redis
/
Mongo
hKp://wiki.postgresql.org/wiki/Foreign_data_wrappers
30. Updatable
View
• View
是唯讀的
– Model
Mapping
to
View 也是唯讀的.
• MySQL
5.5
後支援
• PostgreSQL
– USE
RULE
CREATE
RULE
user_login_update
AS
ON
UPDATE
TO
user_login
DO
INSTEAD
UPDATE
users
SET
password
=
new.password
WHERE
users.account
=
new.account;
31. Database
View
• Simplify
Model
associatons
– User
• belongsTo
Compony
– Compony
• hasMany
User
• belongsTo
Region
– Region
• hasMany
Machine
• Get
User
Machines
Lists
?
– N+1
Query
?
– Prepare
in
Controller
?
32. Database
View
• 建立 user_machines
VIEW
• Mapping
UserMachine
to
‘user_machines’
VIEW
CREATE
View
user_machines
AS
(
SELECT
u.id
as
user_id,
m.*
FROM
users
u
INNER
JOIN
user_componies
….
INNER
JOIN
compony_regions
….
LEFT
JOIN
region_machines
……
)