> For the complete documentation index, see [llms.txt](https://amartyushov.gitbook.io/tech/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://amartyushov.gitbook.io/tech/databases/classification.md).

# Classification

## Key value

<figure><img src="/files/0RV4wYCeTOtP3nsjhHhY" alt=""><figcaption></figcaption></figure>

<table data-full-width="true"><thead><tr><th width="144"></th><th width="97"></th><th width="133">Usage</th><th></th></tr></thead><tbody><tr><td>Redis</td><td>ACID (partly) </td><td>caching, queing, stats</td><td>persistence: in-memory (but snapshoting and append only log)<br>replication: master-slave (for read scalability)<br>clustering is supported</td></tr><tr><td>Memcached</td><td>no ACID</td><td>HTML page cache, SQL result cache</td><td>only in-memory, <span data-gb-custom-inline data-tag="emoji" data-code="274c">❌</span>replication<br>it is common to use <mark style="background-color:orange;">consistent hashing</mark> and <mark style="background-color:orange;">client-side sharding</mark> to distribute data across multiple Memcached servers. This approach requires the application to manage data distribution and handle server failures.</td></tr></tbody></table>

## Wide Column

No schema, no joins

Usecase: time series, historical records, high frequent writes low frequent reads

Best for: queries by primary keys, highly partitionable

<figure><img src="/files/MOiYN6dfVXebkSCrv2uM" alt=""><figcaption></figcaption></figure>

<table data-full-width="true"><thead><tr><th width="143"></th><th></th><th></th></tr></thead><tbody><tr><td>Cassandra</td><td></td><td></td></tr><tr><td>HBase</td><td></td><td></td></tr><tr><td></td><td></td><td></td></tr></tbody></table>

## Document based

|           |   |   |
| --------- | - | - |
| Mongo DB  |   |   |
| Couchbase |   |   |
| Dynamo DB |   |   |

## Types of Data Models in DBMS

### Hierarchical data

Tree-like form. One-to-many relationship. Parent-child relationship. Deletion problem (when parent is deleted all child nodes follow suit). Pointers.

### Relational model

Two-dimensional tables (rows and columns).

### Object-oriented model

Group of objects. Images and other media types (that cannot be kept in relational db). Any object can link to any object. Not the best option for numerical analysis.&#x20;

### Network model

Hierarchical model + many-to-many relationships (multiple parent records).&#x20;

### Float data model

One two-dimensional array of data elements makes up the float data model. The whole table is read to access data.  Efficient for minor models only.

### Entity-relationship (ER) model

Relationships are established in this database model by classifying the object of interest as an entity, and its properties as attributes and these relationships are used to connect various entities. ER diagram is used to show the database’s logical structure simply.

### Semi-structured data model

Generalised version of the relational model that enables flexible data representation, it is impossible to distinguish between data and schema in this model because some entities may lack one or more attributes. In contrast, other entities may have additional characteristics that simplify updating the database’s schema.

## DBMS examples

* PostgreSQL
* MySQL
* MongoDB

{% hint style="info" %}
SQL vs NoSQL classification
{% endhint %}

## SQL

## NoSQL

* [ Couchbase](https://www.couchbase.com/)
  * NoSQL distributed document database (JSON) with many of the best features of a relational DBMS: SQL, distributed ACID transactions, and more

## newSQL

These are SQL databases that scale and distribute globally while still providing transactional processing.

* &#x20;[CockroachDB](https://www.cockroachlabs.com/)
  * CockroachDB is a [distributed SQL](https://www.cockroachlabs.com/blog/what-is-distributed-sql/) database built on a transactional and strongly-consistent key-value store. It **scales** horizontally; **survives** disk, machine, rack, and even datacenter failures with minimal latency disruption and no manual intervention; supports **strongly-consistent** ACID transactions; and provides a familiar **SQL** API for structuring, manipulating, and querying data.

    CockroachDB is inspired by Google's [Spanner](http://research.google.com/archive/spanner.html) and [F1](http://research.google.com/pubs/pub38125.html) technologies, and the [source code](https://github.com/cockroachdb/cockroach) is freely available.
* [Google Cloud Spanner](https://cloud.google.com/spanner)
  * Fully managed relational database with unlimited scale, strong consistency, and up to 99.999% availability.
