Lecturer: John Shepherd
Web Site: http://www.cse.unsw.edu.au/~cs9315/
(If WebCMS unavailable, use http://www.cse.unsw.edu.au/~cs9315/24T1/)
❖ Lecturer |
John Shepherd | ||
Deputy Head of School (education) | ||
K17-410 (turn right from lift) | ||
cs9315@cse.unsw.edu.au | ||
still working out the details | ||
e-Learning Technologies (e.g. Webcms) Information Extraction/Integration Information Retrieval/Web Search Multimedia Databases Query Processing |
❖ Useful Contacts |
cs9315@cse.unsw.edu.au | ||
Enrolment problems | ||
Illness, Misadventure Assignment extension, Supp Exam Must be documented | ||
Assignment Problems | ||
Detailed assignment Problems |
❖ Course Goals |
Introduce you to:
❖ Pre-requisites |
We assume that you are already familiar with
open, close, lseek, read, write, flock
❖ Exercise: SQL (revision) |
Given the following schema:
Students(sid, name, degree, ...) e.g. Students(3322111, 'John Smith', 'MEngSc', ...) Courses(cid, code, term, title, ...) e.g. Courses(1732, 'COMP9311', '12s1', 'Databases', ...) Enrolments(sid, cid, mark, grade) e.g. Enrolments(3322111, 1732, 50, 'PS')
Write an SQL query to solve the problem
❖ Exercise: Unix File I/O (revision) |
Write a C program that reads a file, block-by-block.
Command-line parameters:
open, read
Count and display how many blocks/bytes read.
❖ Learning/Teaching |
What's available for you:
Note: Exercises and videos will be available only after the lecture.
❖ Learning/Teaching (cont) |
Things that you need to do:
❖ Rough Schedule |
intro, dbms review, RA, catalogs | ||
storage: disks, buffers, pages, tuples | ||
RA ops: scan, sort, projection | ||
selection: heaps, hashing, indexes | ||
selection: N-d matching, similarity | ||
no lectures | ||
joins: naive, sort-merge, hash join | ||
query processing, optimisation | ||
transactions: concurrency, recovery | ||
distributed and non-SQL databases |
❖ Textbooks |
No official text book; several are suitable ...
❖ Prac Work |
In this course, we use PostgreSQL v15.6 (compulsory)
Prac Work requires you to compile PostgreSQL from source code
Sort out any problems ASAP (preferably at a help session).
❖ Prac Work (cont) |
PostgreSQL is a large software system:
You will need to learn to navigate this code effectively.
Will discuss relevant parts in lectures to help with this.
PostgreSQL books?
❖ Assignments |
Schedule of assignment work:
Description | Due | Marks | ||||
New Data Type | Week 5 | 15% | ||||
Query Processing | Week 10 | 20% |
Assignments will be carried out individually
Ultimately, submission is via CSE's give
Will spend some time in lectures reviewing assignments.
Assignments will require up-front code-reading (see Pracs).
❖ Assignments (cont) |
Don't leave assignments to the last minute
❖ Assignments (cont) |
Cheating will be penalised with mark of zero for that assignment
❖ Quizzes |
Over the course of the semester ...
But they contribute 15% of your overall mark for the course.
No extensions on quizzes, since solutions released on following Monday
For valid special consideration on quiz
❖ Exam |
Three-hour exam in the May exam period.
Exam is held in CSE Labs (learn the environment, VLab)
PostgreSQL and C documentation (only) will be available in the exam.
Things that we can't reasonably test in the exam:
Contains: descriptive questions, analysis, small programming exercises.
Exam contributes 50% of the overall mark for this course.
❖ Exam (cont) |
If you cannot attend the final exam ...
You get one chance at passing the exam
Exam hurdle 20/50 (which is 40%)
You must attend the exam in-person
❖ Assessment Summary |
Your final mark/grade is computed according to the following:
quiz = mark for on-line quizzes (out of 15) ass1 = mark for assignment 1 (out of 15) ass2 = mark for assignment 2 (out of 20) exam = mark for final exam (out of 50) okExam = exam > 20/50 (after scaling) mark = ass1 + ass2 + quiz + exam grade = HD|DN|CR|PS, if mark ≥ 50 && okExam = FL, if mark < 50 && okExam = UF, if !okExam
❖ Relational DBMS Functionality |
Relational DBMSs provide a variety of functionalities:
❖ Data Definition |
Relational data: relations/tables, tuples, values, types, e.g.
create domain WAMvalue float check (value between 0.0 and 100.0); create table Students ( id integer, -- e.g. 3123456 familyName text, -- e.g. 'Smith' givenName text, -- e.g. 'John' birthDate date, -- e.g. '1-Mar-1984' wam WAMvalue, -- e.g. 85.4 primary key (id) );
The above adds meta-data to the database.
DBMSs typically store meta-data as special tables (catalog).
❖ Data Definition (cont) |
Input: DDL statement (e.g. create table
Result: meta-data in catalog is modified
❖ Data Modification |
Critical function of DBMS: changing data
insert
delete
update
insert into Enrolments(student,course,mark) values (3312345, 5542, 75); update Enrolments set mark = 77 where student = 3354321 and course = 5542; delete Enrolments where student = 3112233;
❖ Data Modification (cont) |
Input: DML statements
❖ Query Evaluator |
Most common function of relational DBMSs
select s.id, c.code, e.mark from Students s join Enrolments e on s.id = e.student join Courses c on e.course = c.id;
❖ DBMS Architecture |
The aim of this course is to
Practical reason:
❖ DBMS Architecture (cont) |
Important factors related to DBMS architecture
** SSDs change things a little, but most high volume bulk storage still on disks
❖ DBMS Architecture (cont) |
Implementation of DBMS operations is complicated by
Transactions/reliability require some form of logging.
❖ Installing PostgreSQL |
PostgreSQL is available via the COMP9315 web site.
Provided as tar-file in ~cs9315/web/24T1/postgresql/
File: postgresql-15.6.tar.bz2
Unpacked, source code + binaries is ~210MB **
If using on CSE, do not put it under your home directory
Place it under /localstorage/YOU/
❖ Before Installing ... |
If you have databases from previous DB courses
... login to... run your old server for the last time ... $ pg_dump -O -x myFavDB > /localstorage/YOU/myFavDB.dump ... stop your old server for the last time ... ... remove data from your old server ... $ rm -fr /localstorage/YOU/pgsql ... install and run your new PostgreSQL 15.6 server ... $ createdb myFavDB $ psql myFavDB -f /srvr/YOU/myFavDB.dump ... your old database is restored under 15.6 ... vxdb@ ...
❖ Installing/Using PostgreSQL |
Environment setup for running PostgreSQL in COMP9315:
# Must be "source"d from sh, bash, ksh, ... export PGDATA=/localstorage/$USER/pgsql/data export PGHOST=$PGDATA export LD_LIBRARY_PATH=/localstorage/$USER/pgsql/lib export PATH=/localstorage/$USER/pgsql/bin:$PATH alias p0="pg_ctl stop" alias p1="pg_ctl -l $PGDATA/log start"
Will probably work (with tweaks) on home laptop if Linux or MacOS
❖ Installing/Using PostgreSQL (cont) |
Brief summary of installation:
$ tar xfj ..../postgresql/src.tar.bz2 # create a directory postgresql-11.3 # set up environment variables $ configure --prefix=$PGHOME $ make $ make install $ source your/environment/file $ initdb # set up postgresql configuration ... done once? $ edit postgresql.conf $ pg_ctl start -l $PGDATA/log # do some work with PostgreSQL databases $ pg_ctl stop
❖ Exercise: Install PostgreSQL |
Follow instruction from previous slide (or P01)
❖ Using PostgreSQL for Assignments |
If changes don't modify storage structures ...
$ edit source code
$ pg_ctl stop
$ make
$ make install
$ pg_ctl start -l $PGDATA/log
# run tests, analyse results, ...
$ pg_ctl stop
In this case, existing databases will continue to work ok.
❖ Using PostgreSQL for Assignments (cont) |
If changes modify storage structures ...
$ edit source code
$ save a copy of postgresql.conf
$ pg_dump testdb > testdb.dump
$ pg_ctl stop
$ make
$ make install
$ rm -fr $PGDATA
$ initdb
$ restore postgresql.conf
$ pg_ctl start -l $PGDATA/log
$ createdb testdb
$ psql testdb -f testdb.dump
# run tests and analyse results
Old databases will not work with the new server.
❖ Using PostgreSQL for Assignments (cont) |
Troubleshooting ...
$PGDATA/log
$PGDATA
postmster.pid
Produced: 13 Feb 2024