Week 1 Tutorial
Week 1 Tutorial
Question 1
The following is part of a database that stores student and course information:
STUDENT
Name Student-number Class Specialism
Smith 34 A Computing
Allan 58 B Computing
COURSE
Course-number Course-name Credit-points Department
DB2045 Intro to Databases 4 Computing
CS4490 Programming 4 Computing
MA2368 Graph Theory 3 Maths
DB3890 Advanced Databases 4 Computing
STUDENT-GRADE
Student-number Course-number Grade
34 CS4490 A
34 DB2045 B
58 DB2045 D
58 MA2368 A
58 DB3890 C
58 CS4490 B
(a) Identify some informal queries and update operations that you would expect to
apply to the database shown.
Informal queries are requests addressed to others but they are overheard by us.
Some of the informal queries that would expect to the database are
1
• What are the prerequisites for the database course.
• Give the names of the students that complete computing major.
• How many courses are available in the given database.
Update operations are performed on the database to update any of the
information in the database. Some of the update operations are
• Update the course name of the “Into to Database” to “Database”
Course Name = Database, Course-Number = DB2045, Credit-points =
4, and Department = Computing
UPDATE Course
SET Course_Name = 'Database’
WHERE Course_Number = DB2045;
• Insert a new student in database
Name = Kevin, Specialism = MATH, Class = C, Student Number = 45
INSERT INTO Student (Name, Student_Number, Class,
Specialism)
VALUES ('Kevin', '45', 'C', ‘Math’);
• Update the credit of the Programming course
Credit = 3, Course name = Programming, Course number = CS4490
and Department = Computing.
UPDATE Course
SET Course_Name = 'Programming’,
Credit_Point = 3
WHERE Course_Number = CS4490;
(b) Think of different users for the database. What types of functions would each
user need? To which user category would each belong, and what type of
interface would each need?
User interacts with various set of operation in the given database. Their
desires differ from the time to time. But evaluating the data given in the
database, it would be reasonable enough to assume that the user mostly will be
the students, registry staffs and teachers.
User Group Functions Category Interface
Student View Grades Native user Web
View Course details
2
Academic Staff Enter grades Application Departmental
Change grades user/ view
Add new course Sophisticated
Generate grade list user
Registry Staff Add Student Details Application Departmental
Change student user/ view
details Sophisticated
Generate student list user
(c) Choose a database application that you are familiar with. Design a physical
schema. What types of additional information and constraints would you like
to represent in the schema? Think of some example queries for your database.
Due the evolution of Database management system, companies are getting
more from their work because they can keep records of everything. Also, it
makes them faster to search information and records about any people or
product that makes them more effective in work. So here I am sharing a
specific database application of a hospital below;
Patient
Fields Data Type Relationships
PatientID Varchar (5) Primary Key
Name Varchar (20) Not Null
Age int Not Null
Weight int Not Null
Gender Varchar (10) Not Null
Address Varchar (50) Not Null
ContactInfo Int Not Null
Disease Varchar (20) Not Null
DoctorID Varchar (5) Not Null
Doctor
Fields Data Type Relationships
DoctorID Varchar (5) Primary Key
DoctorName Varchar (15) Not Null
Department Varchar (15) Not Null
3
Lab
Fields Data Type Relationships
LabID Varchar (5) Primary Key
PatientID Varchar (5) Foreign Key
Weight Int Not Null
DoctorID Varchar (5) Foreign Key
Date Date/ Time Not Null
Category Varchar (15) Not Null
PatientType Varchar (15) Not Null
Amount int Not Null
Inpatient
Fields Data Type Relationships
PatientID Varchar (5) Foreign Key
RoomNo Varchar (50) Not Null
DateOfAdmission Date/ Time Not Null
DateOfDischarge Date/ Time Not Null
Advance int Not Null
LabID Varchar (5) Foreign Key
Outpatient
Fields Data Type Relationships
PatientID Varchar (5) Foreign Key
Date Date/ Time Not Null
LabID Varchar (5) Foreign Key
Room
Fields Data Type Relationships
RoomNo Varchar (50) Primary Key
RoomType Varchar (50) Not Null
Status Varchar (50) Not Null
Additional Information:
4
• Patient: Patient table holds the data of the people that come for check-
up. The primary key of the table is PatientID.
• Inpatient: It is used to store details of patients who are admitted. It
doesn’t have any of the primary key but instead it has two foreign keys
i.e. PatientID and LabID.
• Outpatient: It contains details of the patient who are came for check-
ups. It doesn’t have any of the primary key but instead it has two
foreign keys i.e. PatientID and LabID.
• Lab: It is used to generate the laboratory reports of the respective
patient. It has a primary key named LabID.
• Room: It represents the information of how many patients are admitted
in any given room. It has a primary key named RoomNo.
Queries:
(a) Display a list of the patients, including its respective attributes.
select * from product;
(b) Display a list of the patients who have received treatment between ’01-Sept-
20’ and ’31-Sept-20’.
select patientID
from patient join inpatient
on patient.patientID = inpatient.patientID
where dateofadmission between '01-Sept-20' and
'31-Sept-20';
Question 2
Define the following terms:
i. Application
An application is referred as an program or software that performs a specific
function directly for an end user or in some cases, for the another application.
An application can be self-contained or a group of programs. The program is a
set of operations that runs the application for the user. For instance,
applications include word processors, database programs, web browsers,
development tools, image editors and communication platforms. Application
utilizes the computer OS and other supporting programs, typically system
software, to function. An application requests services from and
5
communicated with other technologies via an application programming
interface (API).
ii. Conceptual database design
Conceptual database design is the process of constructing a model of the data
is used in an enterprise, independent of all physical considerations. The
conceptual database design phase starts with the formation of a conceptual
data model of the enterprise that is entirely independent of implementation
details such as the target DBMS, use of application programs, programming
languages used, hardware platform, performance issues, or any other physical
deliberations.
iii. Logical schema
Logical schema is a data model of a specific problem domain expressed
independently of a particular database management product or storage
technology (physical data model) but in terms of data structures such as
relational tables and columns, object-oriented classes, or XML tags. Logical
data models represent the abstract structure of a domain of information. They
are often diagrammatic in nature and are most typically used in business
processes that seek to capture things of importance to an organization and how
they relate to one another.
iv. Data definition language
Data Definition Language (DDL) statements are used to classify the database
structure or schema. It is a type of language that allows the DBA or user to
depict and name those entities, attributes, and relationships that are required
for the application along with any associated integrity and security constraints.
The commands used under the DDL are as follows;
• CREATE - used to create objects in the database
• ALTER - used to alters the structure of the database
• DROP - used to delete objects from the database
Question 3
What are the four main types of actions when interacting with databases? Briefly
explain each one.
A database management system is a collection of programs that enables users to create
and maintain a database. The DBMS is general purpose software that facilitates the
6
processes of Defining, Constructing, Manipulating and Sharing data among various
users and applications.
• Define Database
The define database is the process in which the data gets stored into the
database and can be maintained by the DBMS. It involves specifying the data
type, structure, and constraints of the data to be stored in the database. The
database definition or descriptive data information is also stored in the
database in the form of a database catalogue or dictionary; it is also called
meta-data.
• Construct Database
Construct database is the process in which the data get stored into the
database. It is the process of storing the data on some storage medium that is
controlled by the DBMS.
• Manipulate Database
Manipulate database is to retrieve database by using query and to insert,
update and delete the database also. It includes functions such as querying the
database to retrieve specific data, updating the database to reflect changes in
the inworld, and generating reports from the data.
• Share Database
Sharing a database allows multiple users and programs to access the database
simultaneously.