Tables: At the core of every database

Introduction to Relational Databases in SQL

Timo Grossenbacher

Data Journalist

Redundancy in the university_professors table

SELECT *
FROM university_professors
LIMIT 3;
Introduction to Relational Databases in SQL
-[ RECORD 1 ]--------+-------------------------------------------------
firstname            | Karl
lastname             | Aberer
university           | ETH Lausanne
university_shortname | EPF
university_city      | Lausanne
function             | Chairman of L3S Advisory Board
organization         | L3S Advisory Board
organization_sector  | Education & research
-[ RECORD 2 ]--------+-------------------------------------------------
firstname            | Karl
lastname             | Aberer
university           | ETH Lausanne
university_shortname | EPF
university_city      | Lausanne
function             | Member Conseil of Zeno-Karl Schindler Foundation
organization         | Zeno-Karl Schindler Foundation
organization_sector  | Education & research
-[ RECORD 3 ]--------+-------------------------------------------------
firstname            | Karl
lastname             | Aberer
(truncated)
function             | Member of Conseil Fondation IDIAP
organization         | Fondation IDIAP
(truncated)
Introduction to Relational Databases in SQL

Introduction to Relational Databases in SQL

Currently: One "entity type" in the database

Introduction to Relational Databases in SQL

A better database model with three entity types

Old:

New:

Introduction to Relational Databases in SQL

A better database model with four entity types

Introduction to Relational Databases in SQL

Create new tables with CREATE TABLE

CREATE TABLE table_name (
 column_a data_type,
 column_b data_type,
 column_c data_type
);
Introduction to Relational Databases in SQL

Create new tables with CREATE TABLE

CREATE TABLE weather (
 clouds text,
 temperature numeric,
 weather_station char(5)
);

Introduction to Relational Databases in SQL

Let's practice!

Introduction to Relational Databases in SQL

Preparing Video For Download...