Giter VIP home page Giter VIP logo

facet's Introduction

Faceteer

codecov Test

Faceteer is meant to make it easier to work with a single table DynamoDB architecture.

The structure and records that are kept in a Dynamo DB table are more so designed around how you access the data instead of the structure of the data itself.

If you're not familiar with the Dynamo DB single table concepts, this video is a good starting point.

Amazon DynamoDB deep dive

What is a Facet?

DynamoDB does not natively have the concept of a Facet. Instead, a Facet is a pattern used when designing a single table DynamoDB schema.

In a single table DynamoDB schema your partition key and sort keys are named PK and SK. The partition and sort keys for GSIs will also be named generically as GSI1PK, GSISK1, GSI2PK, GSI2SK, etc.

By computing the partition and sort keys for a model, many different data models can use a single DynamoDB table. We can also store related data within the same partition.

The Facet is simply a data model with instructions on how to build the partition and sort keys for the model.

Example

Let's say we're building an application that tracks reservations for meeting rooms for our organization.

There are many building that have meeting rooms, and the meeting rooms have a unique number in the building.

First lets create the models for a Building and a Room.

export interface Building {
  id: number;
  name: string;
  city: string;
  state: string;
}

export interface Room {
  id: number;
  buildingId: number;
  floor: number;
  capacity: number;
}

The actual records stored in DynamoDB under our single table pattern might look like this:

{
  PK: "#BUILDING_1",
  SK: "#BUILDING_1",
  id: 1,
  name: "The Strand",
  city: "Brooklyn",
  state: "NY",
}

{
  PK: "#BUILDING_1",
  SK: "#ROOM_7",
  id: 7,
  buildingId: 1,
  floor: 12,
  capacity: 8,
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.