DB Basics

Database

A database is a collection of data that is systematically organized, integrated, and managed for the purpose of sharing and use by multiple people.

DBMS (Database Management System)

  • RDBMS

    • Database management system based on relational model

Relational Database (RDBMS)

  • Consists of a collection of tables organized as relationships with columns and rows

  • Each column records a specific type of data

  • Table rows are collections of values related to each object/entity

RDBMS vs NOSQL

Difference between SQL and NOSQL

Basic Terms

Schema

  • An overall specification regarding the structure and constraints (structure, representation method, relationships, etc.) of data in a database

Table (Relation)

  • A collection of data elements organized using a model of columns and rows

PK

  • A unique value for each row that can uniquely identify stored records

SQL (Structured Query Language)

A language specifically designed to manage data in RDBMS

DBMS SQL command

Creating Tables

ex)

Rename Table

Data Types (in SQLite)

All About Data Types In sqlite

SELECT

  • DISTINCT

    • Retrieve without duplicates

  • COUNT()

    • Retrieve specific count

  • LIKE

    • Wild cards

      • % : There may or may not be a string

      • _ : There must be exactly one character

  • LIMIT ... OFFSET

    • Limit count .... up to what number

    • ex)

CREATE

IF NOT EXISTS

  • Create only when the table does not exist

View Tables

INSERT

UPDATE

DELETE

Select exercise

1. Retrieve all data from the flights table

2. Retrieve all waypoints

3. Retrieve id and flight_num of flights with airfare less than 600

4. Retrieve departure of flights with destination Incheon and price 500 or above

5. Retrieve id and flight_num of flights where the numeric part starts with 0 and ends with 2, and the waypoint is Beijing

ver 1

ver 2

ver 3

.read

+

Pretty Display in CLI

Last updated