Professional Documents
Culture Documents
Faculty of Engineering
Department of Computer Engineering
ECOM 3422: Database Systems [spring 2020] Abeer J. Al-Aydi &
Abdallah H. Azzami
Objectives
1. Setting up a database system.
2. Connecting to database using both of graphical and text-based interfaces.
3. Be familiar with the database system.
4. Populating database with data, and run very simple SQL queries.
Table of Content
Objectives________________________________________________________________________________________ 1
Table of Content __________________________________________________________________________________ 1
1. 1 Lab terminology _______________________________________________________________________________ 2
1.2 Installing PostgreSQL ____________________________________________________________________________ 2
1.3 Installing DBeaver ______________________________________________________________________________ 9
1.4 Import DBeaver license _________________________________________________________________________ 13
1.5 Connecting to the database ______________________________________________________________________ 13
1.5.1 Using graphical interface [DBeaver] ____________________________________________________________ 14
1.5.2 Using default text-based interface [psql] ________________________________________________________ 16
1.6 Create tables _________________________________________________________________________________ 17
1.7 Load sample data ______________________________________________________________________________ 20
1.8 Try out some queries ___________________________________________________________________________ 21
1.8.1 Labwork1 _________________________________________________________________________________ 21
1.8.2 Labwork2 _________________________________________________________________________________ 21
1.9 Homework ___________________________________________________________________________________ 21
1.10 Lab policy ___________________________________________________________________________________ 22
1.11 Grading _____________________________________________________________________________________ 22
Lab1 | Accessing the Database
1. 1 Lab terminology
Data: is a collection of facts about the object of interest.
For e.g. Data about an employee would include information like name, address, age, educational qualifications, etc.
Database: is a shared collection of logically related data and description of these data, designed to meet the
information needs of an organization.
Database management system [DBMS]: is a software system that uses a standard method of cataloging,
retrieving, and running queries on data. DBMS manages incoming data, organizes it, and provides ways for the data to
be modified or extracted by users or other programs.
DBMSS examples: MySQL - Oracle - SQL Server - Microsoft Access - IBM DB2 - PostgreSQL.
SQL: is a standardized structured query language for communicating with a database. SQL statements are used to
perform certain operations on existing database and also to create a database. Using SQL a client program can generate
queries on database.
Page 2 of 22
Lab1 | Accessing the Database
Page 3 of 22
Lab1 | Accessing the Database
Page 4 of 22
Lab1 | Accessing the Database
Page 5 of 22
Lab1 | Accessing the Database
Page 6 of 22
Lab1 | Accessing the Database
Page 7 of 22
Lab1 | Accessing the Database
Enter all the necessary information such as the server, database, port, username, and password. To
accept the default, you can press Enter.
Note that you should provide the password that you entered during installing the PostgreSQL.
Enter the command SELECT version(); you will see the result as follows:
Page 8 of 22
Lab1 | Accessing the Database
Page 9 of 22
Lab1 | Accessing the Database
Page 10 of 22
Lab1 | Accessing the Database
Page 11 of 22
Lab1 | Accessing the Database
Page 12 of 22
Lab1 | Accessing the Database
[Note: A database cluster is a collection of databases that is managed by a single instance of a running database server.]
- PostgreSQL has standard system database named template1 which is the default database template for creating new
databases, these are created just like template1.
- There is a second standard system database named template0. This database contains the same data as the initial
contents of template1, that is, only the standard objects predefined by your version of PostgreSQL. template0 should
never be changed after the database cluster has been initialized.
Page 13 of 22
Lab1 | Accessing the Database
Page 14 of 22
Lab1 | Accessing the Database
Page 15 of 22
Lab1 | Accessing the Database
After connecting to PostgreSQL database server, we can view and explore its main database [postgres].
Page 16 of 22
Lab1 | Accessing the Database
Page 17 of 22
Lab1 | Accessing the Database
Page 18 of 22
Lab1 | Accessing the Database
Page 19 of 22
Lab1 | Accessing the Database
Page 20 of 22
Lab1 | Accessing the Database
After loading data, double-click any table to view its fields and data records, you can choose other table to view.
1.8.1 Labwork1
Execute the previous SQL statements using graphical interface - DBeaver –
1.8.2 Labwork2
Execute the previous SQL statements using default text-based interface - psql –
Include results screenshots in your lab report.
1.9 Homework
1. Write a brief about differences between oracle and PostgreSQL.
2. What is the DBMS that is used in our university?
3. In UNI1 database, create new schema and name it “uni-largeSpace”
4. Execute script of “DDL.sql” on the new schema.
5. Execute scripts of “largeRelationsInsertFile.sql” on the new schema, to load data.
6. Execute the following query, using text-based interface, and include your result screenshot in your report
Page 21 of 22
Lab1 | Accessing the Database
1.11 Grading
Lab works+ Attendance 6
Quizzes 4
Homework 8
Practical Mid-Exam 7
Projects 25
Page 22 of 22