SlideShare ist ein Scribd-Unternehmen logo
1 von 53
Downloaden Sie, um offline zu lesen
MITO,
A SUCCESSOR OF INTEGRAL
LISP MEETUP #43 Aug 30, 2016
I’m Eitaro Fukamachi
@nitro_idiot fukamachi
Do you use
RDBMS?
Do you know
O/R Mapper?
RDBMS
Record
Record
Record
Table
Table
Table
RDBMS
Record
Record
Record
Table
Table
Table
CLOS class
CLOS class
CLOS class
RDBMS
Record
Record
Record
Table
Table
Table
CLOS class
CLOS class
CLOS class
make-instance
RDBMS
Record
Record
Record
Table
Table
Table
CLOS class
CLOS class
CLOS class
CLOS
Object
CLOS
Object
CLOS
Object
make-instance
CLOS class
CLOS class
CLOS class
CLOS
Object
CLOS
Object
CLOS
Object
make-instance
CLOS class
CLOS class
CLOS class
CLOS
Object
CLOS
Object
CLOS
Object
make-instance
▸ Abstracts RDBMS including SQL
▸ Maps RDB tables to CLOS classes
▸ Maps RDB records to CLOS objects
▸ Can add methods
▸ Accelerates development
Do you know O/R Mapper?
ORM Examples
▸ CLSQL
▸ Postmodern
Do you know O/R Mapper?
ORM Examples
▸ CLSQL
▸ Postmodern
▸ Integral
Do you know O/R Mapper?
ORM Examples
▸ CLSQL
▸ Postmodern
▸ Integral
A talk about “Integral”
2 years ago
Do you know O/R Mapper?
ORM Examples
▸ CLSQL
▸ Postmodern
▸ Integral
▸ Crane
A talk about “Integral”
2 years ago
Do you know O/R Mapper?
ORM Examples
▸ CLSQL
▸ Postmodern
▸ Integral (Not recommended)
▸ Crane
▸ Mito
A talk about “Integral”
2 years ago
NEW!
What’s new
in Mito?
What’s new in Mito?
Mito, a successor of Integral
▸ Supports PostgreSQL, as well as MySQL & SQLite3
▸ Implicit columns (auto-pk & record-timestamps)
▸ Reference between DB table classes
▸ Eager loading
▸ Inheritance of DB table classes
▸ Migrations
▸ Schema versioning
Implicit columns,
auto-pk &
record-timestamps
(defclass user ()
((name :col-type (:varchar 64)
:initarg :name
:accessor user-name)
(email :col-type (or (:varchar 128) :null)
:initarg :email
:accessor user-email))
(:metaclass mito:dao-table-class))
CREATE TABLE user (
id BIGSERIAL NOT NULL PRIMARY KEY,
name VARCHAR(64) NOT NULL,
email VARCHAR(128),
created_at TIME,
updated_at TIME
)
(defclass user ()
((name :col-type (:varchar 64)
:initarg :name
:accessor user-name)
(email :col-type (or (:varchar 128) :null)
:initarg :email
:accessor user-email))
(:metaclass mito:dao-table-class))
CREATE TABLE user (
id BIGSERIAL NOT NULL PRIMARY KEY,
name VARCHAR(64) NOT NULL,
email VARCHAR(128),
created_at TIME,
updated_at TIME
)
(defclass user ()
((name :col-type (:varchar 64)
:initarg :name
:accessor user-name)
(email :col-type (or (:varchar 128) :null)
:initarg :email
:accessor user-email))
(:metaclass mito:dao-table-class))
CREATE TABLE user (
id BIGSERIAL NOT NULL PRIMARY KEY,
name VARCHAR(64) NOT NULL,
email VARCHAR(128),
created_at TIME,
updated_at TIME
)
(defclass user ()
((name :col-type (:varchar 64)
:initarg :name
:accessor user-name)
(email :col-type (or (:varchar 128) :null)
:initarg :email
:accessor user-email))
(:metaclass mito:dao-table-class))
CREATE TABLE user (
id BIGSERIAL NOT NULL PRIMARY KEY,
name VARCHAR(64) NOT NULL,
email VARCHAR(128),
created_at TIME,
updated_at TIME
)
(defclass user ()
((name :col-type (:varchar 64)
:initarg :name
:accessor user-name)
(email :col-type (or (:varchar 128) :null)
:initarg :email
:accessor user-email))
(:metaclass mito:dao-table-class))
CREATE TABLE user (
id BIGSERIAL NOT NULL PRIMARY KEY,
name VARCHAR(64) NOT NULL,
email VARCHAR(128),
created_at TIME,
updated_at TIME
)
(defclass user ()
((name :col-type (:varchar 64)
:initarg :name
:accessor user-name)
(email :col-type (or (:varchar 128) :null)
:initarg :email
:accessor user-email))
(:metaclass mito:dao-table-class))
auto-pk
record-timestamps
Reference
between DB table classes
Reference between DB table classes
(defclass user () …
(:metaclass mito:dao-table-class))
(defclass tweet ()
((status :col-type :text
:initarg :status
:accessor tweet-status)
(user-id :col-type (:bigint () :unsigned)
:initarg :user-id
:accessor tweet-user-id))
(:metaclass mito:dao-table-class))
Reference between DB table classes
(defclass user () …
(:metaclass mito:dao-table-class))
(defclass tweet ()
((status :col-type :text
:initarg :status
:accessor tweet-status)
(user-id :col-type (:bigint () :unsigned)
:initarg :user-id
:accessor tweet-user-id))
(:metaclass mito:dao-table-class))
Reference between DB table classes
(defclass user () …
(:metaclass mito:dao-table-class))
(defun tweet-user (tweet)
(mito:find-dao ‘user
:id (tweet-user-id tweet)))
(defclass tweet ()
((status :col-type :text
:initarg :status
:accessor tweet-status)
(user-id :col-type (:bigint () :unsigned)
:initarg :user-id
:accessor tweet-user-id))
(:metaclass mito:dao-table-class))
Reference between DB table classes
(defclass user () …
(:metaclass mito:dao-table-class))
(defun tweet-user (tweet)
(mito:find-dao ‘user
:id (tweet-user-id tweet)))
These kind of accessors are quite common.
Reference between DB table classes
(defclass user () …
(:metaclass mito:dao-table-class))
(defclass tweet ()
((status :col-type :text
:initarg :status
:accessor tweet-status)
(user :col-type user
:initarg :user
:accessor tweet-user))
(:metaclass mito:dao-table-class))
It may cause a
performance issue:
N+1 query.
Eager loading
helps.
Reference between DB table classes
(defclass user () …
(:metaclass mito:dao-table-class))
(defclass tweet ()
((status :col-type :text
:initarg :status
:accessor tweet-status)
(user :col-type user
:initarg :user
:accessor tweet-user))
(:metaclass mito:dao-table-class))
;; Tweets contain “Japan”
(select-dao 'tweet
(where (:like :status “%Japan%")))
;; Getting names of tweeted users.
(mapcar (lambda (tweet)
(user-name (tweet-user tweet)))
*)
BAD EXAMPLE
Reference between DB table classes
(defclass user () …
(:metaclass mito:dao-table-class))
(defclass tweet ()
((status :col-type :text
:initarg :status
:accessor tweet-status)
(user :col-type user
:initarg :user
:accessor tweet-user))
(:metaclass mito:dao-table-class))
;; Tweets contain “Japan”
(select-dao 'tweet
(where (:like :status “%Japan%")))
;; Getting names of tweeted users.
(mapcar (lambda (tweet)
(user-name (tweet-user tweet)))
*)
SQL execution for each records.
(N times)
BAD EXAMPLE
Reference between DB table classes
(defclass user () …
(:metaclass mito:dao-table-class))
(defclass tweet ()
((status :col-type :text
:initarg :status
:accessor tweet-status)
(user :col-type user
:initarg :user
:accessor tweet-user))
(:metaclass mito:dao-table-class))
;; Tweets contain “Japan”
(select-dao 'tweet
(includes 'user)
(where (:like :status “%Japan%")))
;; No additional SQLs will be executed.
(tweet-user (first *))
GOOD EXAMPLE
Reference between DB table classes
(defclass user () …
(:metaclass mito:dao-table-class))
(defclass tweet ()
((status :col-type :text
:initarg :status
:accessor tweet-status)
(user :col-type user
:initarg :user
:accessor tweet-user))
(:metaclass mito:dao-table-class))
;; Tweets contain “Japan”
(select-dao 'tweet
(includes 'user)
(where (:like :status “%Japan%")))
;; No additional SQLs will be executed.
(tweet-user (first *))
Throw 1 query to retrieve users
beforehand.
GOOD EXAMPLE
Inheritance of
DB table classes
Sometimes
similar DB tables are needed.
Photo by Andrey Shipilov
Inheritance of DB table classes
Ex) SQL Antipatterns: Logical Deletion
slideshare.net/t_wada/ronsakucasual
slideshare.net/SoudaiSone/postgre-sql-54919575
PostgreSQL Antipatterns
Inheritance of DB table classes
Ex) SQL Antipatterns: Logical Deletion
(defclass user ()
((name :col-type (:varchar 64)
:initarg :name
:accessor user-name)
(email :col-type (or (:varchar 128) :null)
:initarg :email
:accessor user-email))
(:metaclass mito:dao-table-class))
(defclass deleted-user (user)
((deleted-at :col-type :datetime
:initarg :deleted-at
:initform (local-time:now)
:accessor user-deleted-at))
(:metaclass mito:dao-table-class))
Inheritance of DB table classes
Ex) SQL Antipatterns: Logical Deletion
(defclass user ()
((name :col-type (:varchar 64)
:initarg :name
:accessor user-name)
(email :col-type (or (:varchar 128) :null)
:initarg :email
:accessor user-email))
(:metaclass mito:dao-table-class))
(defclass deleted-user (user)
((deleted-at :col-type :datetime
:initarg :deleted-at
:initform (local-time:now)
:accessor user-deleted-at))
(:metaclass mito:dao-table-class))
CREATE TABLE deleted_user (
id BIGSERIAL NOT NULL PRIMARY KEY,
name VARCHAR(64) NOT NULL,
email VARCHAR(128),
deleted_at TIME NOT NULL,
created_at TIME,
updated_at TIME
)
Inheritance of DB table classes
Ex) SQL Antipatterns: Logical Deletion
(defclass user ()
((name :col-type (:varchar 64)
:initarg :name
:accessor user-name)
(email :col-type (or (:varchar 128) :null)
:initarg :email
:accessor user-email))
(:metaclass mito:dao-table-class))
(defclass deleted-user (user)
((deleted-at :col-type :datetime
:initarg :deleted-at
:initform (local-time:now)
:accessor user-deleted-at))
(:metaclass mito:dao-table-class))
CREATE TABLE deleted_user (
id BIGSERIAL NOT NULL PRIMARY KEY,
name VARCHAR(64) NOT NULL,
email VARCHAR(128),
deleted_at TIME NOT NULL,
created_at TIME,
updated_at TIME
)
Inheritance of DB table classes
Ex) SQL Antipatterns: Logical Deletion
(defmethod mito:delete-dao :before ((user user))
(mito:create-dao ‘deleted-user
:id (object-id user)
:name (user-name user)
:email (user-email user)
:created-at (object-created-at user)
:updated-at (object-updated-at user)))
Copy “user” records to “deleted_user” before deleting.
Mixin
DB table injection
Photo by Steve Snodgrass
Inheritance of DB table classes - Mixin
Mixin
▸ Injects columns and methods
▸ record-timestamps is an actual example
▸ Adds created_at & updated_at
Inheritance of DB table classes - Mixin
Ex) mito-auth
▸ Managing user passwords is dull
▸ Stores hashed passwords
▸ Authenticates
github.com/fukamachi/mito-auth
Inheritance of DB table classes - Mixin
Ex) mito-auth
(defclass user (has-secure-password)
((name :col-type (:varchar 64)
:initarg :name
:accessor user-name)
(email :col-type (or (:varchar 128) :null)
:initarg :email
:accessor user-email))
(:metaclass mito:dao-table-class))
github.com/fukamachi/mito-auth
Inheritance of DB table classes - Mixin
Ex) mito-auth
(defclass user (has-secure-password)
((name :col-type (:varchar 64)
:initarg :name
:accessor user-name)
(email :col-type (or (:varchar 128) :null)
:initarg :email
:accessor user-email))
(:metaclass mito:dao-table-class))
(mito:create-dao ‘user
:name “fukamachi”
:email “e.arrows@gmail.com”
:password “c0mmon-l1sp”)
github.com/fukamachi/mito-auth
Inheritance of DB table classes - Mixin
Ex) mito-auth
(defclass user (has-secure-password)
((name :col-type (:varchar 64)
:initarg :name
:accessor user-name)
(email :col-type (or (:varchar 128) :null)
:initarg :email
:accessor user-email))
(:metaclass mito:dao-table-class))
(mito:create-dao ‘user
:name “fukamachi”
:email “e.arrows@gmail.com”
:password “c0mmon-l1sp”)
Stores a hashed password and salt, not a plain text.
github.com/fukamachi/mito-auth
What wasn’t mentioned
▸ Migrations
▸ Schema versioning
▸ Inflation/deflation
▸ See https://github.com/fukamachi/mito
Thanks.
EITARO FUKAMACHI
8arrow.org
@nitro_idiot fukamachi
Thanks.
See Also
▸ https://github.com/fukamachi/mito
▸ https://github.com/fukamachi/mito-auth
▸ https://github.com/fukamachi/mito-attachment

Weitere ähnliche Inhalte

Was ist angesagt?

Clojure in real life 17.10.2014
Clojure in real life 17.10.2014Clojure in real life 17.10.2014
Clojure in real life 17.10.2014Metosin Oy
 
DBD::Gofer 200809
DBD::Gofer 200809DBD::Gofer 200809
DBD::Gofer 200809Tim Bunce
 
Clojure: Practical functional approach on JVM
Clojure: Practical functional approach on JVMClojure: Practical functional approach on JVM
Clojure: Practical functional approach on JVMsunng87
 
CPAN 模組二三事
CPAN 模組二三事CPAN 模組二三事
CPAN 模組二三事Lin Yo-An
 
Alfresco the clojure way
Alfresco the clojure wayAlfresco the clojure way
Alfresco the clojure wayCarlo Sciolla
 
Clojurian Conquest
Clojurian ConquestClojurian Conquest
Clojurian ConquestKent Ohashi
 
Building GUI App with Electron and Lisp
Building GUI App with Electron and LispBuilding GUI App with Electron and Lisp
Building GUI App with Electron and Lispfukamachi
 
Painless Data Storage with MongoDB & Go
Painless Data Storage with MongoDB & Go Painless Data Storage with MongoDB & Go
Painless Data Storage with MongoDB & Go Steven Francia
 
RestMQ - HTTP/Redis based Message Queue
RestMQ - HTTP/Redis based Message QueueRestMQ - HTTP/Redis based Message Queue
RestMQ - HTTP/Redis based Message QueueGleicon Moraes
 
Perl Memory Use - LPW2013
Perl Memory Use - LPW2013Perl Memory Use - LPW2013
Perl Memory Use - LPW2013Tim Bunce
 
Interceptors: Into the Core of Pedestal
Interceptors: Into the Core of PedestalInterceptors: Into the Core of Pedestal
Interceptors: Into the Core of PedestalKent Ohashi
 
Mastering java bytecode with ASM - GeeCON 2012
Mastering java bytecode with ASM - GeeCON 2012Mastering java bytecode with ASM - GeeCON 2012
Mastering java bytecode with ASM - GeeCON 2012Anton Arhipov
 
Exploring Clojurescript
Exploring ClojurescriptExploring Clojurescript
Exploring ClojurescriptLuke Donnet
 
No REST for the Wicked: REST and Catalyst
No REST for the Wicked: REST and CatalystNo REST for the Wicked: REST and Catalyst
No REST for the Wicked: REST and CatalystJay Shirley
 
Practical Testing of Ruby Core
Practical Testing of Ruby CorePractical Testing of Ruby Core
Practical Testing of Ruby CoreHiroshi SHIBATA
 
Oral presentation v2
Oral presentation v2Oral presentation v2
Oral presentation v2Yeqi He
 

Was ist angesagt? (19)

Clojure in real life 17.10.2014
Clojure in real life 17.10.2014Clojure in real life 17.10.2014
Clojure in real life 17.10.2014
 
DBD::Gofer 200809
DBD::Gofer 200809DBD::Gofer 200809
DBD::Gofer 200809
 
Clojure: Practical functional approach on JVM
Clojure: Practical functional approach on JVMClojure: Practical functional approach on JVM
Clojure: Practical functional approach on JVM
 
CPAN 模組二三事
CPAN 模組二三事CPAN 模組二三事
CPAN 模組二三事
 
Alfresco the clojure way
Alfresco the clojure wayAlfresco the clojure way
Alfresco the clojure way
 
Clojurian Conquest
Clojurian ConquestClojurian Conquest
Clojurian Conquest
 
Building GUI App with Electron and Lisp
Building GUI App with Electron and LispBuilding GUI App with Electron and Lisp
Building GUI App with Electron and Lisp
 
Painless Data Storage with MongoDB & Go
Painless Data Storage with MongoDB & Go Painless Data Storage with MongoDB & Go
Painless Data Storage with MongoDB & Go
 
RestMQ - HTTP/Redis based Message Queue
RestMQ - HTTP/Redis based Message QueueRestMQ - HTTP/Redis based Message Queue
RestMQ - HTTP/Redis based Message Queue
 
Perl Memory Use - LPW2013
Perl Memory Use - LPW2013Perl Memory Use - LPW2013
Perl Memory Use - LPW2013
 
Interceptors: Into the Core of Pedestal
Interceptors: Into the Core of PedestalInterceptors: Into the Core of Pedestal
Interceptors: Into the Core of Pedestal
 
Mastering java bytecode with ASM - GeeCON 2012
Mastering java bytecode with ASM - GeeCON 2012Mastering java bytecode with ASM - GeeCON 2012
Mastering java bytecode with ASM - GeeCON 2012
 
ORMs in Golang
ORMs in GolangORMs in Golang
ORMs in Golang
 
Exploring Clojurescript
Exploring ClojurescriptExploring Clojurescript
Exploring Clojurescript
 
No REST for the Wicked: REST and Catalyst
No REST for the Wicked: REST and CatalystNo REST for the Wicked: REST and Catalyst
No REST for the Wicked: REST and Catalyst
 
Practical Testing of Ruby Core
Practical Testing of Ruby CorePractical Testing of Ruby Core
Practical Testing of Ruby Core
 
High Performance tDiary
High Performance tDiaryHigh Performance tDiary
High Performance tDiary
 
Tuning Solr for Logs
Tuning Solr for LogsTuning Solr for Logs
Tuning Solr for Logs
 
Oral presentation v2
Oral presentation v2Oral presentation v2
Oral presentation v2
 

Andere mochten auch

Dexador Rises
Dexador RisesDexador Rises
Dexador Risesfukamachi
 
Woo: Writing a fast web server
Woo: Writing a fast web serverWoo: Writing a fast web server
Woo: Writing a fast web serverfukamachi
 
Woo: Writing a fast web server @ ELS2015
Woo: Writing a fast web server @ ELS2015Woo: Writing a fast web server @ ELS2015
Woo: Writing a fast web server @ ELS2015fukamachi
 
Clack: glue for web apps
Clack: glue for web appsClack: glue for web apps
Clack: glue for web appsfukamachi
 
Writing a fast HTTP parser
Writing a fast HTTP parserWriting a fast HTTP parser
Writing a fast HTTP parserfukamachi
 
Integral - New O/R Mapper for Common Lisp
Integral - New O/R Mapper for Common LispIntegral - New O/R Mapper for Common Lisp
Integral - New O/R Mapper for Common Lispfukamachi
 
Redesigning Common Lisp
Redesigning Common LispRedesigning Common Lisp
Redesigning Common Lispfukamachi
 
自分をClojure化する方法
自分をClojure化する方法自分をClojure化する方法
自分をClojure化する方法fukamachi
 
JavaからClojure、そして夢の世界へ
JavaからClojure、そして夢の世界へJavaからClojure、そして夢の世界へ
JavaからClojure、そして夢の世界へfukamachi
 
第四回関西Emacs「ari.el」
第四回関西Emacs「ari.el」第四回関西Emacs「ari.el」
第四回関西Emacs「ari.el」fukamachi
 
Clack & Caveman
Clack & CavemanClack & Caveman
Clack & Cavemanfukamachi
 
Lisperの見る世界
Lisperの見る世界Lisperの見る世界
Lisperの見る世界fukamachi
 
Lispで仕事をするために
Lispで仕事をするためにLispで仕事をするために
Lispで仕事をするためにfukamachi
 
オウンドメディアのコンテンツ事例集40選(サムライト)
オウンドメディアのコンテンツ事例集40選(サムライト)オウンドメディアのコンテンツ事例集40選(サムライト)
オウンドメディアのコンテンツ事例集40選(サムライト)サムライト株式会社
 

Andere mochten auch (18)

SBLint
SBLintSBLint
SBLint
 
Dexador Rises
Dexador RisesDexador Rises
Dexador Rises
 
Woo: Writing a fast web server
Woo: Writing a fast web serverWoo: Writing a fast web server
Woo: Writing a fast web server
 
Woo: Writing a fast web server @ ELS2015
Woo: Writing a fast web server @ ELS2015Woo: Writing a fast web server @ ELS2015
Woo: Writing a fast web server @ ELS2015
 
Clack: glue for web apps
Clack: glue for web appsClack: glue for web apps
Clack: glue for web apps
 
Shelly
ShellyShelly
Shelly
 
Lisp Poetry
Lisp PoetryLisp Poetry
Lisp Poetry
 
About Clack
About ClackAbout Clack
About Clack
 
Writing a fast HTTP parser
Writing a fast HTTP parserWriting a fast HTTP parser
Writing a fast HTTP parser
 
Integral - New O/R Mapper for Common Lisp
Integral - New O/R Mapper for Common LispIntegral - New O/R Mapper for Common Lisp
Integral - New O/R Mapper for Common Lisp
 
Redesigning Common Lisp
Redesigning Common LispRedesigning Common Lisp
Redesigning Common Lisp
 
自分をClojure化する方法
自分をClojure化する方法自分をClojure化する方法
自分をClojure化する方法
 
JavaからClojure、そして夢の世界へ
JavaからClojure、そして夢の世界へJavaからClojure、そして夢の世界へ
JavaからClojure、そして夢の世界へ
 
第四回関西Emacs「ari.el」
第四回関西Emacs「ari.el」第四回関西Emacs「ari.el」
第四回関西Emacs「ari.el」
 
Clack & Caveman
Clack & CavemanClack & Caveman
Clack & Caveman
 
Lisperの見る世界
Lisperの見る世界Lisperの見る世界
Lisperの見る世界
 
Lispで仕事をするために
Lispで仕事をするためにLispで仕事をするために
Lispで仕事をするために
 
オウンドメディアのコンテンツ事例集40選(サムライト)
オウンドメディアのコンテンツ事例集40選(サムライト)オウンドメディアのコンテンツ事例集40選(サムライト)
オウンドメディアのコンテンツ事例集40選(サムライト)
 

Ähnlich wie Mito, a successor of Integral

Where's My SQL? Designing Databases with ActiveRecord Migrations
Where's My SQL? Designing Databases with ActiveRecord MigrationsWhere's My SQL? Designing Databases with ActiveRecord Migrations
Where's My SQL? Designing Databases with ActiveRecord MigrationsEleanor McHugh
 
Apache Spark for Library Developers with William Benton and Erik Erlandson
 Apache Spark for Library Developers with William Benton and Erik Erlandson Apache Spark for Library Developers with William Benton and Erik Erlandson
Apache Spark for Library Developers with William Benton and Erik ErlandsonDatabricks
 
Introduction to Cassandra
Introduction to CassandraIntroduction to Cassandra
Introduction to CassandraHanborq Inc.
 
Cassandra and Rails at LA NoSQL Meetup
Cassandra and Rails at LA NoSQL MeetupCassandra and Rails at LA NoSQL Meetup
Cassandra and Rails at LA NoSQL MeetupMichael Wynholds
 
mypipe: Buffering and consuming MySQL changes via Kafka
mypipe: Buffering and consuming MySQL changes via Kafkamypipe: Buffering and consuming MySQL changes via Kafka
mypipe: Buffering and consuming MySQL changes via KafkaHisham Mardam-Bey
 
Ruby is Awesome
Ruby is AwesomeRuby is Awesome
Ruby is AwesomeAstrails
 
Php Map Script Class Reference
Php Map Script Class ReferencePhp Map Script Class Reference
Php Map Script Class ReferenceJoel Mamani Lopez
 
Apache Cassandra. Inception - all you need to know by Mikhail Dubkov
Apache Cassandra. Inception - all you need to know by Mikhail DubkovApache Cassandra. Inception - all you need to know by Mikhail Dubkov
Apache Cassandra. Inception - all you need to know by Mikhail DubkovJavaDayUA
 
Big Data Day LA 2015 - Compiling DSLs for Diverse Execution Environments by Z...
Big Data Day LA 2015 - Compiling DSLs for Diverse Execution Environments by Z...Big Data Day LA 2015 - Compiling DSLs for Diverse Execution Environments by Z...
Big Data Day LA 2015 - Compiling DSLs for Diverse Execution Environments by Z...Data Con LA
 
Cassandra Summit 2013 Keynote
Cassandra Summit 2013 KeynoteCassandra Summit 2013 Keynote
Cassandra Summit 2013 Keynotejbellis
 
ETL With Cassandra Streaming Bulk Loading
ETL With Cassandra Streaming Bulk LoadingETL With Cassandra Streaming Bulk Loading
ETL With Cassandra Streaming Bulk Loadingalex_araujo
 
Big Data Analytics with Scala at SCALA.IO 2013
Big Data Analytics with Scala at SCALA.IO 2013Big Data Analytics with Scala at SCALA.IO 2013
Big Data Analytics with Scala at SCALA.IO 2013Samir Bessalah
 
NOSQL and Cassandra
NOSQL and CassandraNOSQL and Cassandra
NOSQL and Cassandrarantav
 
Golang slidesaudrey
Golang slidesaudreyGolang slidesaudrey
Golang slidesaudreyAudrey Lim
 
Managing terabytes: When Postgres gets big
Managing terabytes: When Postgres gets bigManaging terabytes: When Postgres gets big
Managing terabytes: When Postgres gets bigSelena Deckelmann
 
Managing terabytes: When PostgreSQL gets big
Managing terabytes: When PostgreSQL gets bigManaging terabytes: When PostgreSQL gets big
Managing terabytes: When PostgreSQL gets bigSelena Deckelmann
 

Ähnlich wie Mito, a successor of Integral (20)

Lobos Introduction
Lobos IntroductionLobos Introduction
Lobos Introduction
 
Where's My SQL? Designing Databases with ActiveRecord Migrations
Where's My SQL? Designing Databases with ActiveRecord MigrationsWhere's My SQL? Designing Databases with ActiveRecord Migrations
Where's My SQL? Designing Databases with ActiveRecord Migrations
 
Apache Spark for Library Developers with William Benton and Erik Erlandson
 Apache Spark for Library Developers with William Benton and Erik Erlandson Apache Spark for Library Developers with William Benton and Erik Erlandson
Apache Spark for Library Developers with William Benton and Erik Erlandson
 
Introduction to Cassandra
Introduction to CassandraIntroduction to Cassandra
Introduction to Cassandra
 
Cassandra and Rails at LA NoSQL Meetup
Cassandra and Rails at LA NoSQL MeetupCassandra and Rails at LA NoSQL Meetup
Cassandra and Rails at LA NoSQL Meetup
 
mypipe: Buffering and consuming MySQL changes via Kafka
mypipe: Buffering and consuming MySQL changes via Kafkamypipe: Buffering and consuming MySQL changes via Kafka
mypipe: Buffering and consuming MySQL changes via Kafka
 
Ruby is Awesome
Ruby is AwesomeRuby is Awesome
Ruby is Awesome
 
Php Map Script Class Reference
Php Map Script Class ReferencePhp Map Script Class Reference
Php Map Script Class Reference
 
Apache Cassandra. Inception - all you need to know by Mikhail Dubkov
Apache Cassandra. Inception - all you need to know by Mikhail DubkovApache Cassandra. Inception - all you need to know by Mikhail Dubkov
Apache Cassandra. Inception - all you need to know by Mikhail Dubkov
 
Scala active record
Scala active recordScala active record
Scala active record
 
Big Data Day LA 2015 - Compiling DSLs for Diverse Execution Environments by Z...
Big Data Day LA 2015 - Compiling DSLs for Diverse Execution Environments by Z...Big Data Day LA 2015 - Compiling DSLs for Diverse Execution Environments by Z...
Big Data Day LA 2015 - Compiling DSLs for Diverse Execution Environments by Z...
 
Cassandra Summit 2013 Keynote
Cassandra Summit 2013 KeynoteCassandra Summit 2013 Keynote
Cassandra Summit 2013 Keynote
 
ETL With Cassandra Streaming Bulk Loading
ETL With Cassandra Streaming Bulk LoadingETL With Cassandra Streaming Bulk Loading
ETL With Cassandra Streaming Bulk Loading
 
Big Data Analytics with Scala at SCALA.IO 2013
Big Data Analytics with Scala at SCALA.IO 2013Big Data Analytics with Scala at SCALA.IO 2013
Big Data Analytics with Scala at SCALA.IO 2013
 
A Taste of Dotty
A Taste of DottyA Taste of Dotty
A Taste of Dotty
 
NOSQL and Cassandra
NOSQL and CassandraNOSQL and Cassandra
NOSQL and Cassandra
 
Golang slidesaudrey
Golang slidesaudreyGolang slidesaudrey
Golang slidesaudrey
 
Managing terabytes: When Postgres gets big
Managing terabytes: When Postgres gets bigManaging terabytes: When Postgres gets big
Managing terabytes: When Postgres gets big
 
Meta Object Protocols
Meta Object ProtocolsMeta Object Protocols
Meta Object Protocols
 
Managing terabytes: When PostgreSQL gets big
Managing terabytes: When PostgreSQL gets bigManaging terabytes: When PostgreSQL gets big
Managing terabytes: When PostgreSQL gets big
 

Kürzlich hochgeladen

Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 

Kürzlich hochgeladen (20)

DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 

Mito, a successor of Integral

  • 1. MITO, A SUCCESSOR OF INTEGRAL LISP MEETUP #43 Aug 30, 2016
  • 4. Do you know O/R Mapper?
  • 8. RDBMS Record Record Record Table Table Table CLOS class CLOS class CLOS class CLOS Object CLOS Object CLOS Object make-instance
  • 9. CLOS class CLOS class CLOS class CLOS Object CLOS Object CLOS Object make-instance
  • 10. CLOS class CLOS class CLOS class CLOS Object CLOS Object CLOS Object make-instance ▸ Abstracts RDBMS including SQL ▸ Maps RDB tables to CLOS classes ▸ Maps RDB records to CLOS objects ▸ Can add methods ▸ Accelerates development
  • 11. Do you know O/R Mapper? ORM Examples ▸ CLSQL ▸ Postmodern
  • 12. Do you know O/R Mapper? ORM Examples ▸ CLSQL ▸ Postmodern ▸ Integral
  • 13. Do you know O/R Mapper? ORM Examples ▸ CLSQL ▸ Postmodern ▸ Integral A talk about “Integral” 2 years ago
  • 14. Do you know O/R Mapper? ORM Examples ▸ CLSQL ▸ Postmodern ▸ Integral ▸ Crane A talk about “Integral” 2 years ago
  • 15. Do you know O/R Mapper? ORM Examples ▸ CLSQL ▸ Postmodern ▸ Integral (Not recommended) ▸ Crane ▸ Mito A talk about “Integral” 2 years ago NEW!
  • 17. What’s new in Mito? Mito, a successor of Integral ▸ Supports PostgreSQL, as well as MySQL & SQLite3 ▸ Implicit columns (auto-pk & record-timestamps) ▸ Reference between DB table classes ▸ Eager loading ▸ Inheritance of DB table classes ▸ Migrations ▸ Schema versioning
  • 19. (defclass user () ((name :col-type (:varchar 64) :initarg :name :accessor user-name) (email :col-type (or (:varchar 128) :null) :initarg :email :accessor user-email)) (:metaclass mito:dao-table-class))
  • 20. CREATE TABLE user ( id BIGSERIAL NOT NULL PRIMARY KEY, name VARCHAR(64) NOT NULL, email VARCHAR(128), created_at TIME, updated_at TIME ) (defclass user () ((name :col-type (:varchar 64) :initarg :name :accessor user-name) (email :col-type (or (:varchar 128) :null) :initarg :email :accessor user-email)) (:metaclass mito:dao-table-class))
  • 21. CREATE TABLE user ( id BIGSERIAL NOT NULL PRIMARY KEY, name VARCHAR(64) NOT NULL, email VARCHAR(128), created_at TIME, updated_at TIME ) (defclass user () ((name :col-type (:varchar 64) :initarg :name :accessor user-name) (email :col-type (or (:varchar 128) :null) :initarg :email :accessor user-email)) (:metaclass mito:dao-table-class))
  • 22. CREATE TABLE user ( id BIGSERIAL NOT NULL PRIMARY KEY, name VARCHAR(64) NOT NULL, email VARCHAR(128), created_at TIME, updated_at TIME ) (defclass user () ((name :col-type (:varchar 64) :initarg :name :accessor user-name) (email :col-type (or (:varchar 128) :null) :initarg :email :accessor user-email)) (:metaclass mito:dao-table-class))
  • 23. CREATE TABLE user ( id BIGSERIAL NOT NULL PRIMARY KEY, name VARCHAR(64) NOT NULL, email VARCHAR(128), created_at TIME, updated_at TIME ) (defclass user () ((name :col-type (:varchar 64) :initarg :name :accessor user-name) (email :col-type (or (:varchar 128) :null) :initarg :email :accessor user-email)) (:metaclass mito:dao-table-class))
  • 24. CREATE TABLE user ( id BIGSERIAL NOT NULL PRIMARY KEY, name VARCHAR(64) NOT NULL, email VARCHAR(128), created_at TIME, updated_at TIME ) (defclass user () ((name :col-type (:varchar 64) :initarg :name :accessor user-name) (email :col-type (or (:varchar 128) :null) :initarg :email :accessor user-email)) (:metaclass mito:dao-table-class)) auto-pk record-timestamps
  • 26. Reference between DB table classes (defclass user () … (:metaclass mito:dao-table-class))
  • 27. (defclass tweet () ((status :col-type :text :initarg :status :accessor tweet-status) (user-id :col-type (:bigint () :unsigned) :initarg :user-id :accessor tweet-user-id)) (:metaclass mito:dao-table-class)) Reference between DB table classes (defclass user () … (:metaclass mito:dao-table-class))
  • 28. (defclass tweet () ((status :col-type :text :initarg :status :accessor tweet-status) (user-id :col-type (:bigint () :unsigned) :initarg :user-id :accessor tweet-user-id)) (:metaclass mito:dao-table-class)) Reference between DB table classes (defclass user () … (:metaclass mito:dao-table-class)) (defun tweet-user (tweet) (mito:find-dao ‘user :id (tweet-user-id tweet)))
  • 29. (defclass tweet () ((status :col-type :text :initarg :status :accessor tweet-status) (user-id :col-type (:bigint () :unsigned) :initarg :user-id :accessor tweet-user-id)) (:metaclass mito:dao-table-class)) Reference between DB table classes (defclass user () … (:metaclass mito:dao-table-class)) (defun tweet-user (tweet) (mito:find-dao ‘user :id (tweet-user-id tweet))) These kind of accessors are quite common.
  • 30. Reference between DB table classes (defclass user () … (:metaclass mito:dao-table-class)) (defclass tweet () ((status :col-type :text :initarg :status :accessor tweet-status) (user :col-type user :initarg :user :accessor tweet-user)) (:metaclass mito:dao-table-class))
  • 31. It may cause a performance issue: N+1 query.
  • 33. Reference between DB table classes (defclass user () … (:metaclass mito:dao-table-class)) (defclass tweet () ((status :col-type :text :initarg :status :accessor tweet-status) (user :col-type user :initarg :user :accessor tweet-user)) (:metaclass mito:dao-table-class)) ;; Tweets contain “Japan” (select-dao 'tweet (where (:like :status “%Japan%"))) ;; Getting names of tweeted users. (mapcar (lambda (tweet) (user-name (tweet-user tweet))) *) BAD EXAMPLE
  • 34. Reference between DB table classes (defclass user () … (:metaclass mito:dao-table-class)) (defclass tweet () ((status :col-type :text :initarg :status :accessor tweet-status) (user :col-type user :initarg :user :accessor tweet-user)) (:metaclass mito:dao-table-class)) ;; Tweets contain “Japan” (select-dao 'tweet (where (:like :status “%Japan%"))) ;; Getting names of tweeted users. (mapcar (lambda (tweet) (user-name (tweet-user tweet))) *) SQL execution for each records. (N times) BAD EXAMPLE
  • 35. Reference between DB table classes (defclass user () … (:metaclass mito:dao-table-class)) (defclass tweet () ((status :col-type :text :initarg :status :accessor tweet-status) (user :col-type user :initarg :user :accessor tweet-user)) (:metaclass mito:dao-table-class)) ;; Tweets contain “Japan” (select-dao 'tweet (includes 'user) (where (:like :status “%Japan%"))) ;; No additional SQLs will be executed. (tweet-user (first *)) GOOD EXAMPLE
  • 36. Reference between DB table classes (defclass user () … (:metaclass mito:dao-table-class)) (defclass tweet () ((status :col-type :text :initarg :status :accessor tweet-status) (user :col-type user :initarg :user :accessor tweet-user)) (:metaclass mito:dao-table-class)) ;; Tweets contain “Japan” (select-dao 'tweet (includes 'user) (where (:like :status “%Japan%"))) ;; No additional SQLs will be executed. (tweet-user (first *)) Throw 1 query to retrieve users beforehand. GOOD EXAMPLE
  • 38. Sometimes similar DB tables are needed. Photo by Andrey Shipilov
  • 39. Inheritance of DB table classes Ex) SQL Antipatterns: Logical Deletion slideshare.net/t_wada/ronsakucasual slideshare.net/SoudaiSone/postgre-sql-54919575 PostgreSQL Antipatterns
  • 40. Inheritance of DB table classes Ex) SQL Antipatterns: Logical Deletion (defclass user () ((name :col-type (:varchar 64) :initarg :name :accessor user-name) (email :col-type (or (:varchar 128) :null) :initarg :email :accessor user-email)) (:metaclass mito:dao-table-class)) (defclass deleted-user (user) ((deleted-at :col-type :datetime :initarg :deleted-at :initform (local-time:now) :accessor user-deleted-at)) (:metaclass mito:dao-table-class))
  • 41. Inheritance of DB table classes Ex) SQL Antipatterns: Logical Deletion (defclass user () ((name :col-type (:varchar 64) :initarg :name :accessor user-name) (email :col-type (or (:varchar 128) :null) :initarg :email :accessor user-email)) (:metaclass mito:dao-table-class)) (defclass deleted-user (user) ((deleted-at :col-type :datetime :initarg :deleted-at :initform (local-time:now) :accessor user-deleted-at)) (:metaclass mito:dao-table-class)) CREATE TABLE deleted_user ( id BIGSERIAL NOT NULL PRIMARY KEY, name VARCHAR(64) NOT NULL, email VARCHAR(128), deleted_at TIME NOT NULL, created_at TIME, updated_at TIME )
  • 42. Inheritance of DB table classes Ex) SQL Antipatterns: Logical Deletion (defclass user () ((name :col-type (:varchar 64) :initarg :name :accessor user-name) (email :col-type (or (:varchar 128) :null) :initarg :email :accessor user-email)) (:metaclass mito:dao-table-class)) (defclass deleted-user (user) ((deleted-at :col-type :datetime :initarg :deleted-at :initform (local-time:now) :accessor user-deleted-at)) (:metaclass mito:dao-table-class)) CREATE TABLE deleted_user ( id BIGSERIAL NOT NULL PRIMARY KEY, name VARCHAR(64) NOT NULL, email VARCHAR(128), deleted_at TIME NOT NULL, created_at TIME, updated_at TIME )
  • 43. Inheritance of DB table classes Ex) SQL Antipatterns: Logical Deletion (defmethod mito:delete-dao :before ((user user)) (mito:create-dao ‘deleted-user :id (object-id user) :name (user-name user) :email (user-email user) :created-at (object-created-at user) :updated-at (object-updated-at user))) Copy “user” records to “deleted_user” before deleting.
  • 44. Mixin DB table injection Photo by Steve Snodgrass
  • 45. Inheritance of DB table classes - Mixin Mixin ▸ Injects columns and methods ▸ record-timestamps is an actual example ▸ Adds created_at & updated_at
  • 46. Inheritance of DB table classes - Mixin Ex) mito-auth ▸ Managing user passwords is dull ▸ Stores hashed passwords ▸ Authenticates github.com/fukamachi/mito-auth
  • 47. Inheritance of DB table classes - Mixin Ex) mito-auth (defclass user (has-secure-password) ((name :col-type (:varchar 64) :initarg :name :accessor user-name) (email :col-type (or (:varchar 128) :null) :initarg :email :accessor user-email)) (:metaclass mito:dao-table-class)) github.com/fukamachi/mito-auth
  • 48. Inheritance of DB table classes - Mixin Ex) mito-auth (defclass user (has-secure-password) ((name :col-type (:varchar 64) :initarg :name :accessor user-name) (email :col-type (or (:varchar 128) :null) :initarg :email :accessor user-email)) (:metaclass mito:dao-table-class)) (mito:create-dao ‘user :name “fukamachi” :email “e.arrows@gmail.com” :password “c0mmon-l1sp”) github.com/fukamachi/mito-auth
  • 49. Inheritance of DB table classes - Mixin Ex) mito-auth (defclass user (has-secure-password) ((name :col-type (:varchar 64) :initarg :name :accessor user-name) (email :col-type (or (:varchar 128) :null) :initarg :email :accessor user-email)) (:metaclass mito:dao-table-class)) (mito:create-dao ‘user :name “fukamachi” :email “e.arrows@gmail.com” :password “c0mmon-l1sp”) Stores a hashed password and salt, not a plain text. github.com/fukamachi/mito-auth
  • 50. What wasn’t mentioned ▸ Migrations ▸ Schema versioning ▸ Inflation/deflation ▸ See https://github.com/fukamachi/mito
  • 53. Thanks. See Also ▸ https://github.com/fukamachi/mito ▸ https://github.com/fukamachi/mito-auth ▸ https://github.com/fukamachi/mito-attachment