23
www.intothebox.org

ITB2016 - NoSQL with mongodb and ColdFusion (CFML)

Embed Size (px)

Citation preview

www.intothebox.org

MEIn a nutshell

BUILDING NOSQL APPSwith MongoDB

(the “tech tasting” super high-level mix)

WHEN TO USE NOSQL(and when NOT to)

“When the only tool you have is a hammer, everything looks like a nail.” - Maslow’s Law of the Instrument

NoSQL Strengths• Consistent data data representation throughout logic• Fast and flexible for rapid development• Simplicity of serialization and storage makes clustering easy• Object-based query syntax• Native Javascript support (Mongo)

NoSQL Strengths

=

Consistency in data representation

SQL RDBMS Strengths• Relationship management• Schema enforcement• Wide usage and understanding of SQL• Highly configurable roles and permissions, evolved for

enterprise use• Built-in functions, stored procedures, views, etc.

NoSQL Use Cases• Networking applications• CMS/Document/Entity-driven applications• Feedback-driven applications• Data collection & analytics• 3rd party aggregation applications

RDBMS Use Cases• Accounting/Finance/Mathematical Applications• Applications with relationships which enforce other

relationships (e.g. - e-commerce, travel, quality control)

SCHEMA ENFORCEMENTin a schema-less environment

NoSQL NormalizationThe process of mapping data segments from relevant

relationships in to other objects

CLUSTERING & SHARDINGdistributed scaling with MongoDB

SHARDINGDistribution of collection segments (and GridFS binary objects)

across a number of servershosts= [

{ serverName='ds012345.mongolab.com', serverPort='12345', username="myUsername", password="my53cUr3P455", authenticationDB="myremotedb" }, //note that we only needed the credentials and the authenticationDB value for the first host entry. //All other hosts must use the same values. { serverName='ds023456.mongolab.com', serverPort='23456', }, { serverName='ds034567.mongolab.com', serverPort='34567', }

]

GRIDFSlow-overhead solution for storing, streaming and serving files in

MongoDB

GRIDFS

GRIDFSvar User = getModel("User").load("54e523599b67bde3c7b2f03d");

var ProfilePhoto = getModel("ProfileImages")//Set and normalize our person modelProfilePhoto.set('person.id',Person.get_id())//Load our photo in to GridFSProfilePhoto.loadFile(filePath=expandPath('/includes/tmp/MyProfilePhoto.jpg'),deleteFile=true);ProfilePhoto.create();

var Image = getModel("ProfileImage").load(rc.id);//calling writeImageToBrowser() will flush the image to the browser with headersImage.writeImageToBrowser(argumentCollection=imageArgs);

CBMongoDBMongoDB’s ORM for Coldbox

box install cbmongodb

CBMongoDB• Originally used the CFMongoDB library (uses 2.0 series

driver)• Upgraded in 2015 to use the native Java Driver (current

version 3.2.1)• Designed to provide schema management throughout the

application lifecycle• Automatic normalization• Familiar query syntax

CBMongoDB

CBMongoDB

Q&A

Next Session Begins @ 5:00PM