Codecademy Logo

Database Basics

Print Cheatsheet

Databases: Definition

In software engineering, databases are systems that store, modify, and access collections of information electronically.

Databases: Data Types

Databases can store a variety of data types including strings, numeric data, booleans, dates and times, and files of various extensions.

Database Management System (DBMS)

A database management system (DBMS) is software designed to manage a database. Database management systems allow developers to communicate with a database, via code or a graphical user interface, to perform database operations and administrative actions such as user management.

Databases: Tabular Form

Tabular form refers to a database structure that stores data as a collection of tables with each table consisting of several rows and columns.

Relational or SQL Databases

Relational databases organize data into individual tables via rows and columns. Each column represents an attribute of the data stored and each row is an individual record of the data. Many relational databases use Structured Query Language (SQL) to store and retrieve data, and as such are often referred to as SQL databases.

Relational Database Relationship Types

Relational databases represent data in terms of its relationship to other data. These types of databases organize data into tables and establish relationships between them. The most common types of relationships between tables are: “one-to-one”, “one-to-many”, and “many-to-many”.

Let’s use books to illustrate examples of database relationships:

  • The relationship between a book and it’s ISBN number can be represented as a “one-to-one” relationship. Each book has one ISBN number, and each ISBN number belongs to one book.
  • The relationship between publisher and book titles can be represented as a “one-to-many” relationship. Each publisher has published many books but each book can only be released by one publisher.
  • The relationship between book titles and authors can be represented as “many-to-many”. Each author may have written many books and each book can have multiple authors.

Database Schema: Definition

A database schema is a blueprint that outlines how a database’s data will be structured and organized. It is always a good idea to have a database schema in place before actually inserting data.

Relation Database: Predefined Schema

Relational databases typically follow predefined schemas. Developers outline the tables and their associated relationships before inserting any data.

SQL Databases: Disadvantages

Two considerable disadvantages of working with relational databases are:

  • They can be costly to set up, scale, and maintain.
  • The organization of data into tables consumes a great deal of space which can negatively impact cost and performance.

Non-Relational or NoSQL Databases

Non-relational, or NoSQL, databases is an umbrella term that refers to any database that does not follow the relational model provided by traditional database management systems.

The image above depicts a document database that stores data in JSON format.

NoSQL Databases: Advantages

Considerable advantages of NoSQL databases are:

  • They are relatively inexpensive to maintain.
  • The flexible nature of their schema makes them highly adaptable to an application’s changing needs.

NoSQL Databases: Disadvantages

Due to their flexible, unstructured nature, NoSQL databases can make accuracy a challenge to maintain.

NoSQL Databases

A NoSQL database is a type of database which uses different data models than the traditional relational model used with SQL.

Key-Value NoSQL Database

A key-value NoSQL database uses individual records consisting of:

  • Name, which is the key
  • Data, which is the value

The data is assigned to a name when stored.

Document-based NoSQL Database

A document-based NoSQL database stores objects which contain data in standard encodings such as JSON, YAML, or XML.

Graph-Based NoSQL Database

A graph-based NoSQL database connects many data objects (nodes) together through relationships (edges).

This type of database combines the querying of relational databases with NoSQL flexibility and scalability.

Column-Oriented NoSQL Database

A column-oriented NoSQL database groups data into columns instead of using the rows of a traditional database.

The columns can consist of different sizes and stored data types.