Relational Database Management Systems

COMP3311 20T3 ♢ RDBMSs ♢ [0/12]
❖ What is an RDBMS?

A relational database management system (RDBMS) is

Note: databases provide persistent storage of information
COMP3311 20T3 ♢ RDBMSs ♢ [1/12]
❖ RDBMSs in COMP3311

PostgreSQL

SQLite
COMP3311 20T3 ♢ RDBMSs ♢ [2/12]
❖ PostgreSQL Architecture

PostgreSQL's client-server architecture:


[Diagram:Pics/dbms/pgarch.png]

COMP3311 20T3 ♢ RDBMSs ♢ [3/12]
❖ SQLite Architecture

SQLite's serverless architecture:


[Diagram:Pics/dbms/sqarch.png]

COMP3311 20T3 ♢ RDBMSs ♢ [4/12]
❖ Using PostgreSQL in CSE

Using your PostgreSQL server in CSE (once installed):

wagner$ ssh YOU@grieg
grieg$ source /srvr/YOU/env
grieg$ pg start
grieg$ psql myDatabase
... do stuff with your database ...
grieg$ pg stop
grieg$ exit

Need to run the command  priv srvr  once before the above will work

COMP3311 20T3 ♢ RDBMSs ♢ [5/12]
❖ Using PostgreSQL in CSE (cont)

PostgreSQL files (helps to understand state of server)

COMP3311 20T3 ♢ RDBMSs ♢ [6/12]
❖ Managing Databases

Shell commands to create/remove databases:

(If no dbname supplied, assumes a database called YOU )

Shell commands to dump/restore database contents:

(Database dbname is typically created just before restore)

Main SQL statements in dumpfile:   CREATE TABLE,    ALTER TABLE,    COPY

COMP3311 20T3 ♢ RDBMSs ♢ [7/12]
❖ Managing Tables

SQL statements:

(All conform to SQL standard, but all also have extensions)

DROP..CASCADE also drops objects which depend on the table

TRUNCATE..CASCADE truncates tables which refer to the table

COMP3311 20T3 ♢ RDBMSs ♢ [8/12]
❖ Managing Tuples

SQL statements:

Attrs = ( attr1,, ... attrn )         Tuple = ( val1,, ... valn )

AttrValueChanges is a comma-separated list of:

Each list element assigns a new value to a given attribute.
COMP3311 20T3 ♢ RDBMSs ♢ [9/12]
❖ Table Definition Example

Make a table to hold student data:

CREATE TABLE Student (
    zid     serial,
    family  varchar(40),
    given   varchar(40) NOT null,
    d_o_b   date NOT NULL,
    gender  char(1) check (gender in ('M','F')),
    degree  integer,
    PRIMARY KEY (zid),
    FOREIGN KEY (degree) REFERENCES Degrees(did)
);


serial is a special type which automaticall generates unique integer values

COMP3311 20T3 ♢ RDBMSs ♢ [10/12]
❖ Exercise: Creating/Populating Databases

Do the following:

COMP3311 20T3 ♢ RDBMSs ♢ [11/12]
❖ Managing Other DB Objects

Databases contain objects other than tables and tuples:

Most have SQL statements for: Views and functions also have available: See PostgreSQL documentation Section VI, Chapter I for SQL statement details.
COMP3311 20T3 ♢ RDBMSs ♢ [12/12]


Produced: 20 Sep 2020