0% found this document useful (0 votes)
11 views25 pages

GEOSPATIAL EXRCISE

The document outlines a lab exercise for a course on Database and Geospatial Computing, focusing on relational database management systems (RDBMS) and SQL. It includes objectives and procedures for various labs, such as creating databases, tables, and performing SQL operations like data manipulation, definition, and control. Additionally, it covers the creation of a student management system and the relationships between entities in a bookshop database.

Uploaded by

ጇን ጁንስ
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views25 pages

GEOSPATIAL EXRCISE

The document outlines a lab exercise for a course on Database and Geospatial Computing, focusing on relational database management systems (RDBMS) and SQL. It includes objectives and procedures for various labs, such as creating databases, tables, and performing SQL operations like data manipulation, definition, and control. Additionally, it covers the creation of a student management system and the relationships between entities in a bookshop database.

Uploaded by

ጇን ጁንስ
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

Data base and Geospatial computing /Course Code: GeGo 5107

Submitted by: Tilaye Sewnet


ID No: PGSR 49501014
Submitted to: Dr. Andinet AShagrie
Date of Submission January /2021
This lab exercise includes the following lab sections.
Lab 1 Introduction to RDBMS and SQL pp. 02
Lab 2 Introduction to Relational Database and Modeling pp. 16
Lab 3 SQL and Data Indexing Techniques in Relational Database pp. 18
Introduction to DBMS assignment Report
Each section of lab assignment has their own objectives and detail procedures. The first lab is
the basic introduction about the data base management systems. It also deals with practical
introduction how to create data base, Query command to create table, edit, and insert data to table.
A database is a collection of data, typically describing the activities of one or more
related organizations. For example, a university database might contain information
about the following;
Entities such as students, faculty, courses, and classrooms.
Relationships between entities, such as students’ enrollment in courses, faculty
teaching courses, and the use of rooms for courses.
A data base management system, or DBMS, is software designed to assist in
maintaining and utilizing large collections of data, and the need for such systems, as
well as their use, is growing rapidly. The alternative to using a DBMS is to use a database is
a collection of data, typically describing the activities of one or more related organizations.
For example, a university database might contain information about the following:

Entities such as students, faculty, courses, and classrooms.


Relationships between entities, such as students’ enrollment in courses, faculty teaching
courses, and the use of rooms for courses. A database management system, or DBMS, is
software designed to assist in maintaining and utilizing large collections of data, and the need
for such systems, as well as their use, is growing rapidly. The alternative to using a DBMS is
to use a hoc approaches that do not carry over from one application to another; for example,
to store the data in files and write application-specific code to manage it.

 Objective of the lab 1


Practictical understanding and ability to use the Fundamental Operations of SQL
Understanding the entity types
Fundamental Operations of SQL
(1) The Data Manipulation Language (DML)
As the name tells, the DML is used to manipulate the data within database. We can send
out data retrieval request using SELECT command, or modify the existing data stored in
tables.
 1. The Data Manipulation Language (DML) part of SQL mainly includes:
 SELECT - extracts data from a database table
 UPDATE - updates data in a database table
 DELETE - deletes data from a database table
 INSERT INTO - inserts new data into a database table
 2. The Data Definition Language (DDL)
The Data Definition Language (DDL) part of SQL permits database tables to be created
or deleted. We can also define indexes (keys), specify links between tables, and impose
constraints between database tables. The most important DDL statements in SQL are:
 CREATE TABLE - creates a new database table
 ALTER TABLE - alters (changes) a database table
 DROP TABLE - deletes a database table
 CREATE INDEX - creates an index (search key)
 DROP INDEX - deletes an index
 3. The Data Control Language (DCL)
DCL is used to create roles, permissions, and referential integrity as well it is used to
control access to database by securing it.
 CREATE ROLE/USER – create a user or role
 GRANT DELETE/UPDATE/CREATE – grant certain privilege to users or roles
 REVOKE DELETE/UPDATE/CREATE – revoke certain privilege from users or role

All the above operations can applied in lab 1


 1.2 detail procedure to create SMS /student management system table
Post geris must be installed correctly.
1. Right click “PostgreSQL SQL 13” at the left “Object browser” panel to connect local
host server, and select “Connect”, and enter “postgres” as the password.
 Creating a data base with name assignment_db
Right click on postgres then click on create. All the procedure is shown by arrow.
2. Write the name assignment_db at general
3. Accept all others by default.
4. Click on Save to save
5. The data base assignment_db created
 Create extension
6. Click on extension select post gis and save. Before this you must install the post GIS.
7. Save the extention.
 Creating empty table
To create tables and to fill the data to the field or table column we use query.
SQL (Structured Query Language) is a special-purpose programming language designed
for managing data held in a relational database management system (RDBMS). SQL is a
simple and unified language, which offers many features to make it as a powerfully diverse
that people can work with a secure way. Using
SQL language, one can retrieve data from a database, insert new records int0 databases,
update/modify and delete existed records. SQL is also a ANSI standard computer language
in the field of database, and supported by most commercial and free/open-source database
systems
8. Right click on schema

 Create the empty table with the name sms_db


9. Right click on the assignment_db data base name to create empty Table.
10. Click On Query editor tool
11. Write command to create table
12. As the command bellow shows the sms_db table has 7 fields or columns. But the 7 fields
are empty. There is no any data.
13. Click to the execute tool
The empty table is created on the public schema table.

 Insert / add the fields or columns


 insert attribute into the field or column
 edit, update, select by filed
As described above command shows the seven empty fields.
I fill the only seven students’ information. These are first name, last name,
stid/students ID, gender, college, department, entrance year, register type and course
registered
To fill this field with data;
1. right click on sms_dbs table
2. go to query editor tool
3. Write the following 18 students information to the to7 column or field.
4. Click to the execute tool to run the program.
You can see the fiiled SMS data by writing the above program on query editor tool work
space. And running the program by clicking on execute too.
 The SMS DB is used to select any data by field what we need with simple and short
time.
 From thousands of data we can find or select the data that we need by writing simple
command on SQL editor tool. Look the following simple example how to select the
data from a number of data in data base.
Eg, select only first name and last name,
I write only select first_name,last_name,
Look other examples I want to select only female students, I will write
Here I can select all the name list who are female.
select first_name,last_name,stid,register_type
from sms_db
WHERE gend='f'

 Lab 2: Introduction to Relational Database and Modeling


Objective of lab
 Understanding the relationship between the three types of modeling.
 Entities relationship
 the primary key and secondary key
 domain of Entities
In my lab 2 book shope database, these relations contain information about entities,
such customers, book ISBN, author, price etc and about relationships, such as supplier and
customer.
 We follow the following procedures to create entity relationship
Creating a data base with name assignment_db
Right click on postgres then click on create. All the procedure is shown by arrow.
1. Write the name assignment_db at general
2. Accept all others by default.
3. Click on Save to save
4. The data base assignment_db created
create table auther(
id int not null primary key, name varchar (50) not null,
date_of_birth int not null);

create table type_of_book(


id int not null,name varchar(50) not null
);
create table customers (
id int not null,name varchar(50) not null,adress varchar (50) not null,
contact int not null
);
create table invoices(
invoices_nmber int not null,invo_date int not null,
payment_day int, amount int not null,customer_id int not null
);

create table item_invoices(


invoices_nmber int not null,item_id int not null,
quantity int not null,isbn int not null primary key,item_ofinvoi int not null
);
create table supplyers(id int not null primary key,
name varchar(50) not null);
create table book(
isbn int not null primary key, title varchar (50) not null,in_stock varchar(50) not null,
price int not null , auotersid int not null,typeid int not null,supplyerid int not null);

BOOK
ISBN TITLE IN_STOCK PRICE

AUTHOR
ID NAME DATE_OF_BIRTH

TYPE_OF_BOOK
ID NAME

INVOICE
INVOICE_NR INVOICE_DATE PAYMENT_DATE AMOUNT

CUSTOMER
ID NAME ADDRESS CONTACT

ITEM_OF_INVOICE
INVOICE_NR ITEM_ID QUANTITY ISBN

SUPPLIER
ID NAME ADDRESS CONTACT
create table socio_economic_city_db ( owenr_name text not null,sex varchar(50)not
null,nationality varchar(50)not null,
sub_city varchar(50)not null,
wereda int not null,ketena int not null,sefer varchar (50)not
null,block_nu varchar(50)not null,
house_number int not null,sttus varchar(50)not null,area boolean
not null,tenue varchar(50) not null,
landuse_type varchar(50)not null,ownership_type varchar(50)
not null);
Indexing
select owenr_name,file_number
FROM public.socio_economic_city_db
where sex='f'
select owenr_name
FROM public.socio_economic_city_db
where file_number='175'

You might also like