Skip to content

Instantly share code, notes, and snippets.

@DeepNeuralAI
Last active March 28, 2019 07:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DeepNeuralAI/5365ba16d9a4b79af44419341110ddd2 to your computer and use it in GitHub Desktop.
Save DeepNeuralAI/5365ba16d9a4b79af44419341110ddd2 to your computer and use it in GitHub Desktop.
Introduction to Databases

Database Introduction

Outline

  • Spring Cleaning (Installing PostgreSQL)
  • Database Concepts
  • Entity Relationship Diagram
  • Intro to SQL

Spring Cleaning

For Mac:

Install Postgres with Homebrew:

brew update
brew install postgres

Check version

$ postgres --version
> postgres (PostgreSQL) 11.2

For WSL/Ubuntu Sourced from Here:
Install PostgreSQL using WSL

Installation

sudo apt update
sudo apt install postgresql postgresql-contrib

Check Version

psql --version

Database Concepts

What Is a Database?

Some common definitions:

  • A structured set of data held in a computer, especially one that is accessible

Put another way:

  • It’s a structured system to put your data in that imposes rules upon that data

In simple terms...

a structured set of data held in a computer, especially one that is accessible

Oprah

Why Do We Need a Database
We need an organized way to store data permanently, for it to be persistent

Common Misconceptions

We often think of words like Oracle, SQL Server, MongoDB as databases. But, they are actually a way of managing different databases. Specifically, they are known as a DBMS or a Database Management System

Visually:

A database is:
DB

We can think of a DBMS such as MySQL or PostgreSQL as:
DBMS

Going further, we can express the flow of data with: Data Flow

Why might a DBMS be important?

Fundamentally, DBMS's are advantageous for:

  1. Reducing Data Redundancy
  2. Data Sharing
  3. Data Integrity
  4. Data Security
  5. Backup and Recovery
  6. Privacy/Authorization
  7. Backup and Recovery
  8. Data Consistency

Let's explain a couple of these topics above that are critical to databases:

Data Integrity

Another way of ensuring that the data is accurate and consistent.

Data Consistency

Any change or database transaction must change the affected data only in allowed ways.

Types of DBMS

  1. Relational
  2. Hierarchial
  3. Network
  4. Object Oriented
  5. NoSQL

DBMS types

We are only going to focus on relational database management systems (RDBMS)

  • Most commonly used
  • Understand this, and the other types are easier to learn

We are most likely going to use PostgreSQL.

Street Slang

Source: Lingo

Query: An information request from a database

Transaction: A sequence of queries that perform the desired task

Schema: The structure of a database. A logical blueprint of how the database is not only constructed, but how things are related to each other.

Distributed vs Centralized: A centralized DB only has one database file, kept at a single location. A distributed one is built of multiple database files stored in multiple locations

Scalability: The ability for a database to handle a growing amount of data

Liam Neeson

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment