Physical Models and Logical Models in Rails
Physical Models and Logical Models in Rails
Logical Models
in Rails
dan chak ([email protected])
Nov 11, 2008
Less about “Enterprise” in
terms of buzzwords and
integrating with specific
enterprisy things.
Dan Chak
http://enterpriserails.chak.org
Problem:
request
controller
est
es u
u
req
req
External API 11 External API 2. Controller maps
(#1) & Logical
models (#2)
controller
Skinny request to logical
match closely controllers
model objects
21
#3 transition
3. Logical model maps
persistence
Logical Model API Logical / Object
is the heavy Models
lifting 31
Physical
Model
Physical
Model
Database Bridge /
ORM
operations to
41 ORM physical models
Physical
models simple; 4. ORM translates
straight ORM
mapping between Ruby
Database
objects and data
layer
iCalendar Event
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//hacksw/handcal//NONSGML v1.0//EN
BEGIN:VEVENT
DTSTART:19970714T170000Z bold parts can correspond
to db columns, or can store
DTEND:19970715T035959Z entire text in one column.
SUMMARY:Bastille Day Party lots of these represent
entire calendar for
END:VEVENT storage. but is a terrible
representation for
END:VCALENDAR manipulation.
Calendar Physical Model
i_calendar_entries
id
version
dstart
dend
summary
repeat
etc...
Calendar Logical Model
• Better organization
• Clarity. It’s “logical.”
• Better fit for REST interfaces
• Maintainability across changes
• Reliable Caching (See Chapter 20)
These concepts, and more...
Enterprise
Rails
Dan Chak
questions?