You are on page 1of 21

Relational Model – Introduction

ISYS3414 – Practical Database Concepts


Database Design Process

Hardware and
Operating System
Information about the Problem
Characteristics

Requirement Conceptual Logical Physical


Specification Schema Schema Schema
(Text) (ER / UML) (Relational / SQL) (…)

Requirements Conceptual Physical


Logical
Gathering and Design Design
Design
Analysis
Relational Models
ISYS3414 | Week 2
Relational Model

Created by Edgar
Codd in the 1970s
Simple, elegant and
precise.

Implemented in the
majority of the DBMSs
Example: Oracle
Database, Microsoft
SQL server, IBM DB2, …
Data Structure

•A database is a collection of relations.


•A relation is a table with columns and rows.
•Each column has values of a given domain (data type)
Relational Operators

•With them we can manage schemas, write data, make


queries, …
•Ex.:
•Create tables,
•insert rows in a table,
•delete a table, …
Data Structure

•A database is a collection of relations.


•A relation is a table with columns and rows.
•Each column has values of a given domain (data type)
SQL

• Structured Query Language (SQL)


•Universal Language for the Relational Model
•Stable but in continuous improvement (currently - 8th
Revision)
•SQL-86, SQL-89, SQL-92, SQL:1999, SQL:2003, SQL:2006,
SQL:2008, SQL:2011 SQL:2016
Other data languagues

• SQL-DDL, Data Definition Language


• Creation, update and deletion of tables and integrity restrictions
• SQL-DML, Data Manipulation Language
• Selection, Insertion, update, deletion and query data in tables
Other data models

• There are other data models


oHierarchical and network models already existed in the 1960s

• Relational Model is neutral and declarative: “what, instead of


how”
oIn 1974, SQL was the high-level language (strong abstraction)
proposed.
Relation Properties
SYS2077 | Week 2
Relations

•Relations are tables with columns and rows


oColumns = attributes = data fields
oRows = records = tuples

Important Note:
Do not confuse Relation with Relationship

Relation ≠ Relationship
Relation Schema

oName of the relation


oName and data domain of every column
oEx.: students(sid: integer,
gname: string,
fname: string,
age: integer,
gpa: real)
Relation Instance

oParticular set of (data) rows


oEvery row has the same columns
sid gname fname age gpa
682634 John Smith 20 3.0
632461 Phu Nguyen 21 1.0
612352 Thong Nguyen 19 2.7
603111 Tam Quach 20 0.8

Note: The order of rows is irrelevant


Databases

•Database schema = collection of the


schemas of all relations
•Database instance = collection of the
instances of all relations
Data domain

•Has a name and defines the allowed values


oEx.:
•STRING (text),
•INTEGER (integer numbers),
•REAL (real numbers), …
Mysql datatypes:
https://dev.mysql.com/doc/refman/5.7/en/data-
types.html

SQLite datatypes:
https://sqlite.org/datatype3.html
Data domain

• For efficiency reasons, DBMSs provide more specific domains


oEx.: CHAR(n), VARCHAR(n), DECIMAL(n,m), INT, SMALLINT,
BIGINT, …

• Every column of relation has a domain


Data Domain

• You must choose the proper domain/data type for each column.
• For example, you should not choose a text type for the column “age”.
• Data types have different ranges and, thus, different storages. See the examples
below about the integer types in MySQL:

https://dev.mysql.com/doc/refman/5.7/en/integer-types.html
Degree & Cardinality

• Degree (or Arity) of a relation = numbers of columns


• Cardinality (or “size”) of a relation = numbers of rows/tuples

You might also like