14. Databases

Database refers to logical grouping of data that can support the electronic storage and manipulation of data from a computer system.

  • Typically controlled by a database management system (DBMS)

Over past five decades, databases have evolved from flat file-based types to innovative relational and non-relational databases. Historically, databases have categorized into four groups:

  1. Flat file-based
    • Consists of file systems with data maintained in files.
  2. Heirarchical file-based database
    • Similar to a flat file-based system but the files share a parent-child relationship.
  3. Relational databases
    • Manage data into tables
  4. Non-relational databases
    • Customized databases

A. Relational Databases

(aka) relational database management system (RDMB), stores data in tables.

Tables use columns to hep define the information being stored and rows that hold actual data.

  • Contains atleast column with unique values and that acts as the primary key
    • When a table’s primary key is used in a different table, the column in the second table is called a foreign key.

SQL - Structured query language is used to interact with relational databases. It is a standard language for relational database management systems and supports data retrival, query, and manipulation.


  1. MySQL
  2. Oracle
  3. Microsoft SQL Server
  4. PostgreSQL
  5. MariaDB


  1. Data accuracy - usage of primary and foreign keys help connect and identify databases
  2. Simplified model
  3. Easy access to data
  4. Normalization

I. When to use a relational database

  • Preferred option for house data that contains a fairly strong structure with rows and columns
  • Prime candidates - Include data points with a consistent meaning that can be placed into categories and that have relationships
  • Better choice in scenarios in which repeated data analysis will result in a need to constantly query specific data cross sections.

B. Non-relational Databases

Non-relational databases contain data stored in a non-tabular format and commonly use data structures such as documents or objects.

Two most common types of non-relational databases are:

  1. Document-based
    • Stores data in documents
    • Supports variety of data types, such as strings, numbers, arrays, and objects
  2. Key-value
    • Stores data in key-value pairs


  1. MongoDB
  2. Amazon DynamoDB
  3. Redis
  4. Cassandra
  5. ETCD
  6. Google cloud Firestore


  1. Simple data management
  2. Greater readability
  3. Enhanced ability
  4. Open-source options
  5. High-performance
  6. Better scalability

I. When to use a non-relational database

  • Suitable for use cases in which there is a large amount of data that relates to a single topic
    • Audience segments
    • Unified customer profiles
    • Industry-wide trend data
    • Application databases
    • Large collections of images, text or other data
  • When data that is stored needs to be flixble in terms of size or shape