Skip to content
UoL CS Notes

Other NoSQL Databases

COMP207 Lectures

Document Stores

This is a database that stores an ObjectID associated in a document (typically in JSON).

JSON vs XML

We can represent the following XML:

<?xml version=“1.0” standalone=“yes”>
<students>
	<student>
		<name>Anna</name>
		<number>20171989</number>
		<programme>G402</programme>
	</student>
	<student>
		<name>John</name>
		<number>20174378</number>
		<programme>G702</programme>
	</student></students>

as the following JSON file:

{"students":[
	{"name": "Anna",
	"number":20171989,
	"programme":"G402"},
	{"name": "John",
	"number":20174378,
	"programme":"G702"},
	
]}
  • {} are used for objects.
  • [] are used for arrays.

MongoDB

This DBMS stores documents in a variant of JSON:

  • Creating/managing collections:

      dc.createCollection("students")
    
  • Insert/update/delete documents:

      db.students.insert{
          {name: "Anna", studentID: 20171989, year: 2}
      }
    
  • Finding documents:

      db.students.find({year: 2})
      db.students.find({year: {$lt: 3}}).sort({year:1})
    

MongoDB Properties

Sharding (horizontal fragmentation):

  • Collections are split into horizontal fragments.
  • Based on the shard key:
    • Indexed Field
    • Exists in all documents.

Replication:

  • Horizontal fragments of collections are replicated.
  • Master-slave approach:
    • Primary copy (master) and secondary copies (replicas).
    • Updates - On master, then delegated to replicas.
    • Reads - Delegated to master (default) or to any replica.

Transaction Support:

  • ACID is supported on the newest version from 2020.
  • Isolation is not fully supported as only snapshots are completed.

Column Stores

Column stores are laid out like so:

  • Student:

      name   contact        
      first last address city postcode email  
    123 Anna Collins

The following are different to normal tables:

  • Column Family - A group of column qualifiers.
    • Column Qualifier - Conventional columns.

    These are referenced as <columnfamiliy>:<columnqualifier>.

Hbase

This column store implementation uses the hadoop distributed file system:

  • Creating tables:

      create 'STUDENT','NAME','Grade','Programme'
    
  • Inserting rows:

      put 'STUDENT','row1','Name:Fname','Anna'
      put 'STUDENT','row1','Grade:COMP207','100'
    
  • Finding documents:

      get 'STUDENT','row1'
      scan 'STUDENT'
    

    scan is used for going through the whole table.

Hbase Properties

Hbase uses two levels of fragmentation:

  • Top Level - Rows are divided into regions (ranges of rows).
  • Bottom Level - Regions store different column families in different nodes (computers).

There is no transaction support.

Each item has a time stamp and one can access past version of the database (if setup):

> get ’STUDENT’, ‘row1’
	COLUMN	CELL
	name:first	timestamp=1511139129384, value=Anna
	name:last	timestamp=1511139140333, value=…

Graph Databases

These store data as a graph with:

  • Objects and attributes on the nodes.
  • Relations on the arcs.

Data is then accessed using an SQL-like path query language.