rapid data modeling for mobile – connect silicon valley 2017

71
Rapid Data Modeling and Testing AARON BENTON

Upload: couchbase

Post on 21-Jan-2018

135 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Rapid data modeling for mobile – Connect Silicon Valley 2017

Rapid Data Modeling and Testing

AARON BENTON

Page 2: Rapid data modeling for mobile – Connect Silicon Valley 2017

community.couchbase.com

Page 3: Rapid data modeling for mobile – Connect Silicon Valley 2017
Page 4: Rapid data modeling for mobile – Connect Silicon Valley 2017

+

Couchbase Server Couchbase Mobile

Page 5: Rapid data modeling for mobile – Connect Silicon Valley 2017

Use Cases

• Mobile

• Caching

• User Tracking

• Media

• Short Urls

• Products

• Session Management

Page 6: Rapid data modeling for mobile – Connect Silicon Valley 2017

• How is data represented?

• How are models

communicated?

• How are models

documented?

• How are data types

defined?

Page 7: Rapid data modeling for mobile – Connect Silicon Valley 2017

First, solve the problem. Then, write the code.“ ”- John Johnson

Page 8: Rapid data modeling for mobile – Connect Silicon Valley 2017

Data Modeling

Page 9: Rapid data modeling for mobile – Connect Silicon Valley 2017

Conceptual Data Modeling

Entity Names

Entity Relationships

Users Products

Line Items

Orders

Page 10: Rapid data modeling for mobile – Connect Silicon Valley 2017

Logical Data Modeling

Entity Names

Entity Attributes

Entity Relationships

UsersUser ID (PK)

Username

Password

First Name

Last Name

Address

City

State

Zip Code

Country

Email

Phone

OrdersOrder ID (PK)

Order Number

User ID (FK)

Order Date

Address

City

State

Zip Code

Country

Phone

Email

Credit Card

Expiration Date

Order Line

ItemsOrder ID (FK)

Product ID (FK)

Quantity

Total

Products

Product ID (PK)

Product Name

Description

Price

Page 11: Rapid data modeling for mobile – Connect Silicon Valley 2017

Physical Data ModelingEntity Names -> Table NamesEntity Attributes -> Field NamesEntity Relationships -> KeysPrimary / Foreign KeysData Types

Page 12: Rapid data modeling for mobile – Connect Silicon Valley 2017

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?

Page 13: Rapid data modeling for mobile – Connect Silicon Valley 2017

JSON

Page 14: Rapid data modeling for mobile – Connect Silicon Valley 2017

JSON Schema

Page 15: Rapid data modeling for mobile – Connect Silicon Valley 2017

YAML

Page 16: Rapid data modeling for mobile – Connect Silicon Valley 2017

Now What?

Page 17: Rapid data modeling for mobile – Connect Silicon Valley 2017

START DEVELOPMENT!

Page 18: Rapid data modeling for mobile – Connect Silicon Valley 2017

FAKE DATA

Page 19: Rapid data modeling for mobile – Connect Silicon Valley 2017

WASTED TIME

Page 20: Rapid data modeling for mobile – Connect Silicon Valley 2017
Page 21: Rapid data modeling for mobile – Connect Silicon Valley 2017

Fake Data Generators• FakerJS

• ChanceJS

• json-generator.com

• objgen.com/json

• mockaroo.com

• jsonschema.net

Page 22: Rapid data modeling for mobile – Connect Silicon Valley 2017

Relationships are Hard

Page 23: Rapid data modeling for mobile – Connect Silicon Valley 2017

FakeIT

Page 24: Rapid data modeling for mobile – Connect Silicon Valley 2017

Fakeit

• CLI Tool inspired by Swagger

• Models defined in YAML

• Generates JSON, CSON, YAML, CSV

• Exports to Couchbase, Sync Gateway, Zip,

Console

Page 25: Rapid data modeling for mobile – Connect Silicon Valley 2017

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

Page 26: Rapid data modeling for mobile – Connect Silicon Valley 2017

npm install fakeit -g

Page 27: Rapid data modeling for mobile – Connect Silicon Valley 2017

Original YAML Model

Page 28: Rapid data modeling for mobile – Connect Silicon Valley 2017

Simple Model

28

Data Attribute

Page 29: Rapid data modeling for mobile – Connect Silicon Valley 2017

Console Output

Page 30: Rapid data modeling for mobile – Connect Silicon Valley 2017

File Output

Page 31: Rapid data modeling for mobile – Connect Silicon Valley 2017

Output Formats

Page 32: Rapid data modeling for mobile – Connect Silicon Valley 2017

CSV Output

Page 33: Rapid data modeling for mobile – Connect Silicon Valley 2017

Zip Archive

Page 34: Rapid data modeling for mobile – Connect Silicon Valley 2017
Page 35: Rapid data modeling for mobile – Connect Silicon Valley 2017

Couchbase

Page 36: Rapid data modeling for mobile – Connect Silicon Valley 2017

What about Mobile…?

Page 37: Rapid data modeling for mobile – Connect Silicon Valley 2017

Sync Gateway

Page 38: Rapid data modeling for mobile – Connect Silicon Valley 2017

Channel Property

Page 39: Rapid data modeling for mobile – Connect Silicon Valley 2017

Sync Gateway with Auth

Page 40: Rapid data modeling for mobile – Connect Silicon Valley 2017

How does it Work?

Page 41: Rapid data modeling for mobile – Connect Silicon Valley 2017

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

Page 42: Rapid data modeling for mobile – Connect Silicon Valley 2017
Page 43: Rapid data modeling for mobile – Connect Silicon Valley 2017

Flow

Model

Pre_RUNModel

PRE_BUILD

Initialize

Property

Value

(EACH)

Start

Document

Run

Property

PRE_BUILD

+ BUILD

(EACH)

PROPERTY

POST_BUIL

D (EACH)

MODEL

POST_BUIL

D

MODEL

POST_RUN

Page 44: Rapid data modeling for mobile – Connect Silicon Valley 2017

Flow

Page 45: Rapid data modeling for mobile – Connect Silicon Valley 2017

Flow

Page 46: Rapid data modeling for mobile – Connect Silicon Valley 2017
Page 47: Rapid data modeling for mobile – Connect Silicon Valley 2017

Multiple Models

Page 48: Rapid data modeling for mobile – Connect Silicon Valley 2017

Multiple Models

Page 49: Rapid data modeling for mobile – Connect Silicon Valley 2017

Dependencies

Users Products Reviews Orders

Page 50: Rapid data modeling for mobile – Connect Silicon Valley 2017

Dependencies

Page 51: Rapid data modeling for mobile – Connect Silicon Valley 2017

Dependencies

Page 52: Rapid data modeling for mobile – Connect Silicon Valley 2017

Dependencies with Single Output

Page 53: Rapid data modeling for mobile – Connect Silicon Valley 2017

Definitions

Page 54: Rapid data modeling for mobile – Connect Silicon Valley 2017

Definitions

Page 55: Rapid data modeling for mobile – Connect Silicon Valley 2017
Page 56: Rapid data modeling for mobile – Connect Silicon Valley 2017

continents.json countries.csv

Inputs

Page 57: Rapid data modeling for mobile – Connect Silicon Valley 2017

continents.json countries.csv

Inputs

Page 58: Rapid data modeling for mobile – Connect Silicon Valley 2017
Page 59: Rapid data modeling for mobile – Connect Silicon Valley 2017

Require

Page 60: Rapid data modeling for mobile – Connect Silicon Valley 2017

Require

Page 61: Rapid data modeling for mobile – Connect Silicon Valley 2017
Page 62: Rapid data modeling for mobile – Connect Silicon Valley 2017

Seeds

Page 63: Rapid data modeling for mobile – Connect Silicon Valley 2017

Seeds

Page 64: Rapid data modeling for mobile – Connect Silicon Valley 2017
Page 65: Rapid data modeling for mobile – Connect Silicon Valley 2017

JS API

Page 66: Rapid data modeling for mobile – Connect Silicon Valley 2017

JS API Options

Page 67: Rapid data modeling for mobile – Connect Silicon Valley 2017

How we use FakeIt• YAML models store in the repository

• Make commands to generate data

• Docker Compose:

• Couchbase

• Sync Gateway

• Testing / QA

Page 68: Rapid data modeling for mobile – Connect Silicon Valley 2017

Demos

Page 69: Rapid data modeling for mobile – Connect Silicon Valley 2017

Fakeit Examples• Contacts

• Ecommerce

• Flat

• Flight Data

• Music

• Simple

• Social

bit.ly/fakeit-examples

Page 70: Rapid data modeling for mobile – Connect Silicon Valley 2017

Questions?

Page 71: Rapid data modeling for mobile – Connect Silicon Valley 2017

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!