Database

Types of databases

Characteristic Relational Non-relational Graph
Representation Multiple tables, each containing columns and rows Collection of documents
Single table with keys and values
Collections of nodes and relationships
Data design Normalized relational or dimensional data warehouse. Denormalized document, wide column or key value Denormalized entity relationship
Optimized Optimized for storage Optimized for compute Optimized for relationships
Query style Language: SQL Language: many
Uses object querying
Language: many
Uses object querying
Scaling Scale vertically Scale horizontally Hybrid
Implementation OLTP business systems, OLAP data warehouse OLTP web/mobile apps OLTP web/mobile apps

Types of data models

Data models describes how data is represented.

Relational models

Dimensional model

Schema is a way of describing how something such as data is organized.

Denormalized/NoSQL schemas

SQL vs. No SQL Pasted image 20230620231249.png|500

Key elements of database schema

Transactional & Analytical Processing

Typically, there are two types of workloads that databases are optimized for, transactional processing and analytical processing:

online transaction processing (OLTP)

online analytical processing (OLAP)

However, both the terms OLTP and OLAP have become outdated.

Types of Relational Databases

Row-based indexes Columnar indexes
Storage on disk Row by row Column by column
Read/write Best at random reads and writes Best at sequential reads and writes
Best for Returning full rows of data based on a key Returning aggregations of column values
Implementation Transactional systems Analytical processing
Data compression Low to medium compression can be achieved High compression is the norm

Factors of database performance

Database Consistency

There are two methods that databases implement for consistency: ACID and BASE.

ACID (Atomicity, Consistency, Isolation, and Durability)

= a method for maintaining consistency and integrity in a structured database

BASE (Basically Available, Soft state, Eventually consistent)

= a method for maintaining consistency and integrity in a structured or semistructured database

ACID compliance BASE compliance
Strong consistency Weak consistency – stale data is OK
Isolation is key Availability is key
Focus on committed results Best effort results
Conservative (pessimistic) availability Aggressive (optimistic) availability