25 - NoSQL Databases#

Key-Value Stores#

  • Key-value stores focus on high performance, availability, and scalability

    • Can store structured, semi-structured, and unstructured data

  • Key: unique identifier associated with a data item

    • Used for fast retrieval

  • Value: the data item itself

    • Can be string or array of bytes

    • Application interprets the structure

  • No query language

DynamoDB#

  • DynamoDB is an AWS service

  • Table holds a collection of self-describing items

  • Item consists of attribute-value pairs

    • Attribute values can be single or multi-valued

  • Primary key used to locate items within a table

    • Can be a single attribute or pair of attributes

Voldemort#

  • Voldemort is an open-source key-value system similar to DynamoDB

  • Features

    • Simple basic operations (get, put, delete)

    • High-level formatted data values

    • Consistent hashing for distributing (key, value) pairs

    • Consistency and versioning

      • Concurrent writes allowed

      • Each write associated with a vector clock

Consistent Hashing#

Consistent hashing is a distributed hashing scheme that operates independently of the number of servers or objects in a distributed hash table.

Graph Databases#

In a graph database, data is stored as a collection of verticies (nodes) and edges. It is possible to store data on both edges and verticies.

Neo4j#

Neo4j is an open-source graph database system.

  • Nodes can have zero, one, or several labels (types)

  • Both nodes and relationships can have properties

  • Each relationship has a start node, end node, and relationship type

  • Properties specified using a map (key-value) pattern

  • Somewhat similar to ER/EER concepts

Creating Nodes in Neo4j

  • CREATE command

  • Part of high-level declarative query language Cypher

  • Node label can be specified when a node is created

  • Properties are enclosed in curly brackets

Examples#

Creating nodes

  • CREATE (e1:EMPLOYEE, {Empid:'1', Lname:'Smith', Fname:'John', Minit:'B'})

  • CREATE (e1:EMPLOYEE, {Empid:'2', Lname:'Wong', Fname:'Franklin', Minit:'B'})

  • CREATE (e1:EMPLOYEE, {Empid:'3', Lname:'Zelaya', Fname:'Alicia', Minit:'B'})

  • CREATE (e1:EMPLOYEE, {Empid:'4', Lname:'Wallace', Fname:'Jennifer', Minit:'S'})

Creating relationships

  • CREATE (e1)-[:WorksFor]->(d1)

  • CREATE (e3)-[:WorksFor]->(d2)

  • CREATE (d1)-[:Manager]->(e2)

  • CREATE (d2)-[:Manager]->(e4)