Rapid Data Modeling and Testing AARON BENTON
Rapid Data Modeling and Testing
AARON BENTON
bit.ly/cbcommunity
+
OUR CAPABILITIES
6
Enthusiasm Disillusionment Panic
Search for the Guilty
Punishment of the Innocent
Praise for Non-Participants
First, solve the problem. Then, write the code.“ ”John Johnson
Data Modeling
Phases• Conceptual • Logical • Physical
Conceptual Data Modeling
Entity NamesEntity Relationships
Users Products
Line Items
Orders
N 1Person Birthplace Location Person Location
Born In
Birthplace of
Person Location(1, 1) Born In
Birthplace of (0, N)
<< Entity >> Person
0. .N
1
<< Entity >> Location
<< Relationship >>Born in >
< Birthplace of
Chen
Person LocationIDEF1x
Person LocationBorn In
Birthplace of
Bachman
Crow's Foot
ISO
UML
Logical Data Modeling
Entity NamesEntity AttributesEntity Relationships
UsersUser ID (PK)
Username
Password
First Name
Last Name
Address
City
State
Zip Code
Country
Phone
OrdersOrder ID (PK)
Order Number
User ID (FK)
Order Date
Address
City
State
Zip Code
Country
Phone
Credit Card
Expiration Date
Order Line ItemsOrder ID (FK)
Product ID (FK)
Quantity
Total
ProductsProduct ID (PK)
Product Name
Description
Price
Physical Data ModelingEntity Names -> Table NamesEntity Attributes -> Field NamesEntity Relationships -> Keys Data Types
NoSql Modeling• How do you represent a model? • What tools do you use? • How do you show relationships? • Does code define the model? • What key patterns should be used?
JSON
JSON Schema
YAML
Now What?
20
Fake Data Generators• FakerJS • ChanceJS • json-generator.com • objgen.com/json • mockaroo.com • jsonschema.net
Relationships are Hard
FakeIT
Fakeit• CLI Tool inspired by Swagger • Models defined in YAML • Generates JSON, CSON, YAML, CSV • Exports to Couchbase, Sync Gateway, Zip,
Console
Fakeit Data• Exposes FakerJS and ChanceJS • Custom Build Functions w/ Pre and Post • Multiple Models • Dependencies • Definitions
*fakeit is for structure, cbworkloadgen is for sizing
npm install fakeit -g
Original YAML Model
Simple Model
30
Data Attribute
Console Output
File Output
Output Formats
CSV Output
Zip Archive
. . . ?
Couchbase
What about Mobile…?
Sync Gateway
Sync Gateway with Auth
How does it Work?
Property Data:
value
• A static value to be used • Executed at build time
fake
• A FakerJS template string • Executed at build time
pre_build
• Function body used to initialize a property
• Property is set to the returned value
build
• Function body used to set a property
• Property is set to the returned value
post_build
• Function body used to manipulate a property after it has been set
• Property is set to the returned value
pre_run
• Function body that is executed before any models are generated
post_run
• Function body that is executed before after all models have been generated
FlowModel
Pre_RUNModel
PRE_BUILD
Initialize Property
Value (EACH)
Start Document
Run
Property PRE_BUILD +
BUILD (EACH)
PROPERTY POST_BUILD
(EACH)
MODEL POST_BUILD
MODEL POST_RUN
Flow
Flow
Multiple Models
Multiple Models
Dependencies
Users Products Reviews Orders
Dependencies
Dependencies
Definitions
Definitions
continents.json countries.csv
Input
continents.json countries.csv
Input
How we use FakeIt• YAML models store in the repository • Make commands to generate data • Docker Compose:
• Nginx • Couchbase • Sync Gateway
• Testing / QA
Demos
Fakeit Examples• Contacts • Ecommerce • Flat • Flight Data • Music • Simple • Social
github.com/bentonam/fakeit-examples
Questions?
HOW TO CONTACT MEDon’t hesitate to contact with me. I will be happy to answer your questions.
TWITTER: @bentonam
github.com/bentonam
EMAIL: [email protected]
THANK YOU