The document describes the challenges faced by a development team working on a CMS project where requirements kept changing. It discusses issues with using Joomla and frameworks when projects become complex. It then proposes using a CMF approach with common and domain-specific boxes to build pages. Finally, it discusses challenges with the relational data model and explores NoSQL options like Redis, MongoDB and CouchDB that may better suit the changing requirements of the project.
33. Pages
• main structure of a web site
• organized as a tree
• a way to express our contents
• usually composed by a series of
containers ( that we'll refer to as
boxes )
domenica 15 maggio 2011
37. Boxes
{Bridge}
Entities Pages
Boxes let entities be shown inside webpages
domenica 15 maggio 2011
38. Boxes
We dispose of different types of
boxes:
• Common
• DSL
domenica 15 maggio 2011
39. Common Box
• Simple
o Input field
o Textarea
o Video
o Image
o File
o Richtext
• Composite
o Input field + image
o input field + image + richetex
o textarea + video
domenica 15 maggio 2011
50. Common Boxes + DSL Boxes
=
The main tool for the developer to build a page
with the CMF
domenica 15 maggio 2011
51. Example : page & box composition
Main
Image
most sold product
product
Richtext
domenica 15 maggio 2011
52. Example : page & box composition
Main
Image
most sold product
product
Richtext
Dsl Boxes
domenica 15 maggio 2011
53. Example : page & box composition
Main
Image
most sold product
product
Common Boxes
Richtext
Dsl Boxes
domenica 15 maggio 2011
54. Example : page & box composition
Main
Image
most sold product
product
Common Boxes
Richtext
Dsl Boxes
domenica 15 maggio 2011
55. Example : page & box composition
Main
Image
most sold product
product
Common Boxes
Richtext
Dsl Boxes
domenica 15 maggio 2011
56. Example : page & box composition
Main
Image
most sold product
product
Common Boxes
Richtext
Dsl Boxes
domenica 15 maggio 2011
57. Example : page & box composition
Main
Image
most sold product
product
Common Boxes
Richtext
Dsl Boxes
domenica 15 maggio 2011
58. The Page-Box Binding Storage
Data can change its structure fastly, according to the domain model.
We need a technology supporting this fast change.
Since we have N box type, to compose a page we should
look for a few tables.
We need a technology supporting this kind of lookups.
domenica 15 maggio 2011
59. so,
How will we
manage the data?
domenica 15 maggio 2011
67. so we know we're gonna face
a few well-known problems...
domenica 15 maggio 2011
68. Data Mapping
Data Structure RDBMS
id
name
parent_id
we have to find a way to re-organize the data-structre to insert our
tree inside a table.
But is really different! Tree find a node in O(nlogn)
domenica 15 maggio 2011
69. Data Mapping
Data Structure RDBMS
is better than before, but isn't the best way
domenica 15 maggio 2011
70. Data Mapping
Data Structure RDBMS
?
... and NOW??????
domenica 15 maggio 2011
71. The Alien
spend more time to normalize
your models
BUT
you always find
something that as a
different Behaviour
domenica 15 maggio 2011
72. Unpredictable
Tomorrow
User Story evolve continous
Worse than the Alien
domenica 15 maggio 2011
73. EAV
formerly known as:
normalization WTF?!?!?!
or:
how to do 70k joins to retrieve an entity of you model
domenica 15 maggio 2011
74. Overnormalized
user_id | mail | phone | address
Large schema is broken
into smaller ones
user_id | mail_id
user_id | phone_id
user_id | address_id
domenica 15 maggio 2011
75. Overnormalized
user_id | mail_id LEFT JOIN
user_id | phone_id LEFT JOIN
...
...
...
...
...
user_id | address_id LEFT JOIN
domenica 15 maggio 2011
76. Overnormalized
Users List
LEFT JOIN LEFT JOIN
LEFT JOIN
LEFT JOIN
LEFT JOIN
LEFT JOIN LEFT JOIN
domenica 15 maggio 2011
77. Overnormalized
LEFT JOIN LEFT JOIN
JOIN LEFT JOIN
LEFTUsers List
LEFT JOIN
LEFT JOIN LEFT JOIN
LEFT JOIN
LEFT JOIN LEFT JOIN
LEFT JOIN
LEFT JOIN
LEFT JOIN LEFT JOIN
LEFT JOIN
LEFT JOIN LEFT JOIN
LEFT JOIN
What if you need to show only a single primary address?
domenica 15 maggio 2011
88. • Written in: C/C++
• Main point: Blazing fast
• Protocol: Telnet-like
• Disk-backed in-memory database,
• but since 2.0, it can swap to disk.
• Master-slave replication
• Simple keys and values,
• but complex operations like
ZREVRANGEBYSCORE
• INCR
• Values can be set to expire (as in a cache)
$ redis-cli set mykey "my binary safe value" => OK
$ redis-cli get mykey => my binary safe value
domenica 15 maggio 2011
89. Best used:
• rapidly changing data with
a foreseeable database size
(should fit mostly in
memory)
For example:
• analytics
• real-time data collection
• caching
• MQ
• log
http://kkovacs.eu/cassandra-vs-mongodb-vs-couchdb-vs-redis
domenica 15 maggio 2011
91. very fast
Object != key->value
domenica 15 maggio 2011
92. very fast
Object != key->value
Not reliable
domenica 15 maggio 2011
93. very fast
Object != key->value
Not reliable
Can I haz otha nozql?
domenica 15 maggio 2011
94. • Written in: C++
• Main point: Retains some friendly properties
of SQL
• Protocol: Custom, binary (BSON)
• Master/slave replication
• speaks JavaScript
• Built-in sharding
• Performance over features
• After crash, it needs to repair tables
> j = { name : 'david', surname : 'funaro' };
{ "name" : "david", "surname" : "funaro" }
> db.things.save(t);
> db.things.find();
{ "_id" : ObjectId("4c2209f9f3924d31102bd84a"), "name" : "mongo" }
domenica 15 maggio 2011
95. Best used:
• you need dynamic queries
• you prefer to define indexes,
not map/reduce functions
• you need good performance on
a big DB
For example:
• all things that you would do
with MySQL or PostgreSQL,
but having predefined columns
really holds you back
http://kkovacs.eu/cassandra-vs-mongodb-vs-couchdb-vs-redis
domenica 15 maggio 2011
99. Document Oriented
Schema Free
Navigate Object
Can I haz otha nozql?
domenica 15 maggio 2011
100. • Written in: Erlang
• Main point: DB consistency, ease of use
• Protocol: HTTP, some say REST
• Bi-directional replication => master-master
• conflict detection ( 409 Conflict )
• MVCC: write operations do not block reads
• Previous versions of documents are available
• Crash-only (reliable) design
• Needs compacting from time to time
• Views: embedded map/reduce
• jQuery library included
curl -d '{"keys":["bar"]}' -X POST http://host:port/foo/_all_docs?include_docs=true
domenica 15 maggio 2011
101. Best used:
• accumulating occasionally-
changing data
• pre-defined queries
• versioning is king
For example:
• CRM/CMS systems
• API
http://kkovacs.eu/cassandra-vs-mongodb-vs-couchdb-vs-redis
domenica 15 maggio 2011
106. Reliable
Document Oriented
Schema Free
Navigate Object
Can I haz otha nozql?
domenica 15 maggio 2011
107. Why do we so hardly
need a GraphDB
like OrientDB?
domenica 15 maggio 2011
108. "GraphDBs don't avoid relations but they embrace them in
a way that they are not a computational problem anymore,
by making them explicit instead of implicit through joins."
Claudio Martella
( http://blog.acaro.org/entry/somebody-is-going-to-hate-me-nosparql )
domenica 15 maggio 2011
109. Easy joins
select from users where city.country.continent = 'Oceania'
domenica 15 maggio 2011
110. Same link semantics,
different objects
select links from menu >> 28:1, 17:5
domenica 15 maggio 2011
111. Same link semantics,
different objects
select from [28:1, 17:5]
28:1 17:5
ExternalLink ProductLink
url: http://www.google.com id: 4
domenica 15 maggio 2011
152. "My only friend, the end"
David Funaro
@ingdavidino
http://davidfunaro.com
domenica 15 maggio 2011
153. "My only friend, the end"
David Funaro Alessandro Nadalin
@ingdavidino @_odino_
http://davidfunaro.com http://odino.org
domenica 15 maggio 2011
154. "My only friend, the end"
David Funaro Alessandro Nadalin
@ingdavidino @_odino_
http://davidfunaro.com http://odino.org
domenica 15 maggio 2011
155. "My only friend, the end"
David Funaro Alessandro Nadalin
@ingdavidino @_odino_
http://davidfunaro.com http://odino.org
http://joind.in/talk/view/3008
domenica 15 maggio 2011