You are on page 1of 19

FACULTY OF BASIC SCIENCES& INFORMATION TECHNOLOGY

2020/2021 SEMESTER II OPEN BOOK EXAMINATIONS AUGUST 2021


BCS, BIT, DCS, DIT

PAPER: DATABASE PROGRAMMING


PAPER CODE: BIT/DIT 2202/ BCS/DCS 2202
DATE:
TIME: 7:00AM -4:00 PM
GUIDELINES
1. You are required to print out the same work submitted via the LMS; any alterations will be
treated as examination malpractice and will lead to automatic cancellation of the examination.

2. Submit hard copies of all your Work to the Examinations Office at Kampala Campus after
clearance from the accounts department; attach a photocopy of your registration card on your
work.
N.B. Handing in of hard copies will be as follows
a) MONDAY 13th September 2021 (ONLY 1ST YEARS) from 9:00 am to 4:00 pm
b) TUESDAY 14th September 2021 (ONLY 2ND YEARS) from 9:00 am to 4:00 pm
c) WEDNESDAY 15th September 2021(ONLY 3RD YEARS) from 9:00 am to 4:00 pm

Kindly follow the above schedule and submit on the right date & time, and observe SOPs to
keep safe.

Page 1 of 19
SECTION A (Attempt All Questions in this
section 40 Marks)

Question 1

This course was presented with a case study called the DreamHome property
management application.

You have been requested to design the DreamHome database starting with the
Entity-Relationship diagram. Some assistance has been given to you in determining
the.tables in the application with the corresponding primary keys. You are required
to apply your E-R diagram, and SQL knowledge to create the database, and the
tables, populate them with some data and retrieve some information using
appropriate queries.

Study the following description of requirements carefully to support you in


answering the questions:

Data Requirements
A Users’ Requirements Specification for DreamHome Case Study

Branches
DreamHome is a property for rent business and has branch offices in cities throughout the United
Kingdom. Each branch office is allocated members of staff, including a Manager, who manages
the operations of the office. The data describing a branch office includes a unique branch
number, address (street, city, and postcode), telephone numbers (up to a maximum of three),
and the name of the member of staff who currently manges the office.

Additional data is held on each Manager, which includes the date that the Manager assumed his
or her position at the current branch office, and a monthly bonus payment based upon his or her
performance in the property for rent market.

Staff
Members of staff with the role of Supervisor are responsible for the day-to-day activities of an
allocated group of staff called Assistants (up to a maximum of 10, at any one time). Not all
members of staff are assigned to a Supervisor. The data stored regarding each member of staff
includes staff number, names, address, position, salary, name of Supervisor (where applicable),
and the details of the branch office at which a member of staff is currently working. The staff
number is unique across all branches of DreamHome.

Page 2 of 19
Properties for rent
Each branch office offers a range of properties for rent. The data stored for each property
includes property number, address (street, city, postcode), type, number of rooms, monthly
rent, and the details of the property owner. The property number is unique across all branch
offices. The management of a property is assigned to a member of staff whenever it is rented out
or requires to be rented out. A member of staff may manage a maximum of 100 properties for
rent at any one time.

When a given property is available for rent, the property details will be displayed on the
DreamHome Web site and, when necessary, as advertisements in local and national newspapers.

Property owners
The details of property owners are also stored. There are two main types of property owner:
private owners and business owners. The data stored for private owners includes owner
number, names, address, telephone number, email, and password. The data stored on business
owners includes name of business, type of business, address, telephone number, email, password,
and contact name.
The password will allow owners access to parts of the DreamHome database using the Web.

Clients
DreamHome refers to members of the public interested in renting property as clients. To become
a client, a person must first register at a branch office of DreamHome. The data stored on clients
includes client number, name, telephone number, email, preferred type of accommodation, and
the maximum rent that the client is prepared to pay. Also stored is the name of the member of
staff who processed the registration, the date the client joined, and some details on the branch
office at which the client registered. The client number is unique across all DreamHome
branches.

Leases
When a property is rented out, a lease is drawn up between the client and the property. The data
listed in detail on the lease includes lease number, client number, name and address, property
number and address, monthly rent, method of payment, an indication of whether the deposit has
been paid deposit (calculated as twice the monthly rent), duration of lease, and the start and end
dates of the lease period.

Newspapers
When required, the details of properties for rent are advertised in local and national newspapers.
The data stored includes the property number, address, type, number of rooms, rent, the date
advertised, the name of the newspaper, and the cost to advertise. The data stored on each
newspaper includes the newspaper name, address, telephone number, and contact name.

Branch User Views of DreamHome

Transaction Requirements (Sample)

Page 3 of 19
Data entry
Enter the details of a new branch (such as branch B003 in Glasgow).
Enter the details of a new member of staff at a branch (such as Ann Beech at branch B003).
Enter the details of a lease between a client and property (such as client Mike
Ritchie renting out property number PG4 from the 10-May-12 to 9-May-13).
Enter the details of a property advertised in a newspaper (such as property number
PG4 advertised in the Glasgow Daily newspaper on the 06-May-12).

Data update/deletion
Update/delete the details of a branch.
Update/delete the details of a member of staff at a branch.
Update/delete the details of a given lease at a given branch.
Update/delete the details of a newspaper advertisement at a given branch.

Data queries
Examples of queries required by the Branch user views:
(a) List the details of branches in a given city.
(b) Identify the total number of branches in each city.
(c) List the name, position, and salary of staff at a given branch, ordered by staff name.
(d) Identify the total number of staff and the sum of their salaries.
(e) Identify the total number of staff in each position at branches in Glasgow.
(f) List the name of each Manager at each branch, ordered by branch address.
(g) List the names of staff supervised by a named Supervisor.
(h) List the property number, address, type, and rent of all properties in Glasgow, ordered by
rental amount.
(i) List the details of properties for rent managed by a named member of staff.
(j) Identify the total number of properties assigned to each member of staff at a given branch.
(k) List the details of properties provided by business owners at a given branch.
(l) Identify the total number of properties of each type at all branches.
(m) Identify the details of private property owners that provide more than one property for rent.
(n) Identify flats with at least three rooms and with a monthly rent no higher than £500 in
Aberdeen.
(o) List the number, name, and telephone number of clients and their property preferences at a
given branch.
(p) Identify the properties that have been advertised more than the average number of times.
(q) List the details of leases due to expire next month at a given branch.
(r) List the total number of leases with rental periods that are less than one year at branches in
London.
(s) List the total possible daily rental for property at each branch, ordered by branch number.

Staff User Views of DreamHome


Data Requirements
Staff
The data required on members of staff includes staff number, name (first and last name),
position, gender, date of birth (DOB), and name of the Supervisor (where appropriate). Members

Page 4 of 19
of staff in the position of Supervisor supervise an allocated group of staff (up to a maximum of
10 at any one time).

Properties for rent


The data stored on property for rent includes property number, address (street, city, and
postcode), type, number of rooms, monthly rent, and the details of the property owner. The
monthly rent for a property is reviewed annually. Most of the properties rented out by
DreamHome are apartments (or flats). The management of a property is assigned to a member of
staff whenever it is rented out or ready to be rented out. A member of staff may manage a
maximum of 100 properties for rent at any one time.

Property owners
There are two main types of property owner: private owners and business owners.
The data stored on private owners includes owner number, name (first and last name), address,
telephone number, email, and password. The data stored on business owners includes owner
number, name of business, business type, address, telephone number, email, password, and
contact name.

Clients
When a prospective client registers with DreamHome, the data stored includes the client number,
name (first and last name), telephone number, email, and some data on the desired property,
including the preferred type of accommodation and the maximum rent that the client is prepared
to pay. Also stored is the name of the member of staff who registered the new client.

Property viewings
Clients may request to view property. The data stored includes client number, names and
telephone number, property number and address, date the client viewed the property, and any
comments made by the client regarding the suitability of the property. A client may view the
same property only once on a given date.

Leases
Once a client finds a suitable property, a lease is drawn up. The information on the lease includes
lease number, client number and name, property number, address, type and number of rooms,
monthly rent, method of payment, deposit (calculated as twice the monthly rent), whether the
deposit is paid, the start and end dates of the rental period, and the duration of the lease. The
lease number is unique across all DreamHome branches. A client may hold a lease associated
with a given property from a minimum of three months to a maximum of 1 year.

The following are the DreamHome entities and they are listed with their corresponding
attributes; in bold and underlined, are the selected primary keys for the entity/ relation / table.

Branch (branchNo, street, city, postcode)


Staff (staffNo, fName, IName, position, sex, DOB, salary, branchNo)
PropertyForRent (propertyNo, street, city, postcode, type, rooms, rent, ownerNo, staffNo, branchNo)
Client (clientNo, fName, IName, telNo, prefType, maxRent, eMail)

Page 5 of 19
PrivateOwner (ownerNo, fName, IName, address, telNo, eMail, password)
Viewing (clientNo, propertyNo, viewDate, comment)
Registration (clientNo, branchNo, staffNo, datejoined)

(a) Draw an Entity-Relationship diagram corresponding to the requirements information


provided.
(b) Using Schema showing tables, their Primary keys(bold and underlined), and other
attributes, and Sample Data, Develop the DreamHome database and its associated
tables
(c) Using SQL together with the DreamHome Database develop queries to:
(i) List full details of all staff.
(ii) Produce a list of salaries for all staff, showing only the staff number, the first and last
names, and the salary details.
(iii) List the property numbers of all properties that have been viewed.
(iv) Produce a list of monthly salaries for all staff, showing the staff number, the first and
last names, and the salary details.
(v) List all staff with a salary greater than £10,000.
(vi) List the addresses of all branch offices in London or Glasgow.
(vii) List all staff with a salary between £20,000 and £30,000.
(viii) List all managers and supervisors.
(ix) Find all owners with the string ‘Glasgow’ in their address.

Page 6 of 19
196720

Page 7 of 19
Page 8 of 19
SECTION B (Attempt 3 Questions in this section 60 Marks)

Question 2.

Discuss each of the following terms (use drawings, figures to illustrate your work):

(a) data;
Data, in the context of databases, refers to all the single items that are stored in a database,
either individually or as a set(tables).

(b) database;

 A database is a shared collection of logically related data (and a description of this data),
designed to meet the information needs of an organization.

 Below is an example of a database showing Sales and Stock Control Departments


accessing the database through Application programs and the DBMS.

(b) database management system;


The DBMS is the software that interacts with the users, application programs, and the
database. It enables users to define, create, and maintain the database and also

Page 9 of 19
provides controlled access to this database.

(c) database application program;


 Also known as the Database System. This refers to a computer program that interacts
with the database by issuing an appropriate request (typically an SQL statement) to the
DBMS. It interacts with the database along with the DBMS and the database itself.

(d) data independence;

Data Independence is defined as a property of DBMS that helps you to change the Database
schema at one level of a database system without requiring to change the schema at the next
higher level. Data independence helps you to keep data separated from all programs that make
use of it. It helps you to improve the quality of the data

In DBMS there are two types/levels of data independence

1. Physical data independence

Physical data independence helps you to separate conceptual levels from the
internal/physical levels. It allows you to provide a logical description of the database
without the need to specify physical structures.

Page 10 of 19
With Physical independence, you can easily change the physical storage structures or
devices with an effect on the conceptual schema. Any change done would be absorbed
by the mapping between the conceptual and internal levels. Physical data independence
is achieved by the presence of the internal level of the database and then the
transformation from the conceptual level of the database to the internal level.

2. Logical data independence.

Logical Data Independence is the ability to change the conceptual scheme without
changing: -

a. External views
b. External API or programs

Any change made will be absorbed by the mapping between external and conceptual
levels.

When compared to Physical Data independence, it is challenging to achieve logical data


independence.

Illustration

(e) security;

Page 11 of 19
Database security refers to the range of tools, controls, and measures designed to establish
and preserve database confidentiality, integrity, and availability.

Database security must address and protect the following:

 The data in the database


 The database management system (DBMS)
 Any associated applications
 The physical database server and/or the virtual database server and the underlying
hardware
 The computing and/or network infrastructure used to access the database

Illustration

(f) integrity;
Data integrity refers to the overall accuracy, completeness, reliability and consistence of
data in a database either logically or physically. It can be specified by the lack of variation

Page 12 of 19
between two instances or consecutive updates of a record, indicating that your information
is error-free.
Illustration

(g) views
A database view is a subset of a database and is based on a query that runs on one or more
database tables. It is a virtual table that does not necessarily exist in the database but is
generated by the DBMS from the underlying base tables whenever it’s accessed. Database
views are saved in the database as named queries and can be used to save frequently used,
complex queries.

In a University setting, different users of the database may access the database and access
only the information that is useful for their operation. For example, the accounts office,
Students and Staff Members can have a different view of the same database and have
different information displayed to them basing on their roles on the database system.
Illustration

Page 13 of 19
Question 3
(i) What is a database management system DBMS?
The DBMS is the software that interacts with the users, application programs, and the
database. It enables users to define, create, and maintain the database and also provides
controlled access to this database.

(ii) Discuss the following issues as they relate to a DBMS:


a. Hardware
This refers to computer system(s) that the DBMS and the application
programs run on. These are a set of physical electronic devices such as
computers, I/O devices, storage devices, etc.
b. Software

Page 14 of 19
This is the set of programs used to control and manage the overall database.
This includes the DBMS software itself, the Operating System, the network
software being used to share the data among users, and the application
programs used to access data in the DBMS
c. Data
Data, in the context of databases, refers to all the single items that are stored in
a database, either individually or as a set(tables). There are two types of data stored
in the database, user saved data and meta-data (the ‘data about data’). Meta data is
information stored by the DBMS to better understand the data stored in it.
For example: When I store my Name in a database, the DBMS will store when
the name was stored in the database, what is the size of the name, is it stored as
related data to some other data, or is it independent, all this information is
metadata.

d. Users
In the context of a Database, this refers to any person who uses/interacts with
the database and takes benefits from the database. There will be different types
of users depending on their need and way of accessing the database e.g.
database manager/administrator, application programmers, end-user, database
designer, system analyst etc.

Question 4:
Discuss the advantages of DBMS

A Database Management System (DBMS) is defined as the software system that allows users to define,
create, maintain and control access to the database. DBMS makes it possible for end users to create,
read, update and delete data in database. It is a layer between programs and data.

Advantages

1. Reducing/Controls Data Redundancy


The database approach eliminates redundancy where possible since all information is
stored in the same place. However, it does not eliminate redundancy entirely, but controls
the amount of redundancy inherent in the database.

Page 15 of 19
2. Sharing of Data

In the database, the authorized users of the database can share the data among
themselves since it belongs to the entire organization/group. In this way, more users
share more of the data.

3. Data consistency
By eliminating or controlling redundancy, we’re reducing the risk of inconsistencies
occurring. If data is stored only once in the database, any update to its value has to be
performed only once and the new value is immediately available/reflected to all users.

4. Improved data integrity


Data integrity means that the data is accurate and consistent in the database. Data Integrity is
very important as there are multiple databases in a DBMS. Database integrity is usually
expressed in terms of constraints, which are consistency rules that the database is not
permitted to violate. Data integration allows users to define, and the DBMS to enforce,
integrity constraints.

5. Improved security
Data Security is vital concept in a database. Only authorized users are allowed to access the
database and their identity should be authenticated using a username and password.
Unauthorized users are not be allowed to access the database under any circumstances as it
violates the integrity constraints.

6. Improved maintenance through data independence


Since a DBMS separates the data descriptions from the applications, it helps make
applications immune to changes in the data descriptions. This is known as data
independence and its provision simplifies database application maintenance.

7. Improved Data Privacy


The privacy rule in a database means only the authorized users can access a database according
to its privacy constraints. There are levels of database access and a user can only view the data
he is allowed to. For example - In social networking sites, access constraints are different for
different accounts a user may want to access.

8. Improved backup and recovery services.


Database Management System automatically takes care of backup and recovery. The users don't
need to backup data periodically because this is taken care of by the DBMS. Moreover, it also
restores the database after a crash or system failure to its previous condition. 

9. Improved data accessibility


DBMS helps make data access more available to the users and reduces the amount of time it
would have taken to get a particular record from the database.
10. increased productivity

Page 16 of 19
As a result of the database being very responsive and easily accessible, the productivity
of the users is increased as they can perform various tasks and operations with in the
shortest period of time.

11. Data Integration


Data integration is a process of combining the data residing at different locations and present
the user with a unified view of data. DBMS systems allow Data Integration with much feasibility.

12. Data concurrency


In DBMS, Data are stored in one or more servers in the network and that there is some software
locking mechanism that prevents the same set of data from being changed by two people at the
same time.
13. Increased end-user productivity  
The availability of data, combined with the tools that transform data into usable
information, empowers end users to make quick, informed decisions that can make the
difference between success and failure in the global economy

Question 5:
Discuss the disadvantages of DBMS

1. High Cost of Hardware and Software Installation – 


This is because, for DBMS, it is mandatory to have a high-speed processor and also a
large memory size. The requirement of this large amount of space and a high-speed
processor needs expensive hardware and expensive software too.

2. High cost of maintenance


Hardware and Software, both require maintenance in order to have systems that are up to
date on security and performance which is very costly. That is, there is a requirement for
sophisticated hardware and software which means that we need to upgrade the hardware
which is used for the file-based system.

Page 17 of 19
3. Complexity
Database management system (DBMS) is so complex for non-technical users. So, it isn’t easy to
manage and maintain database systems. Therefore, training for the designers, users, and
administrators is necessary to efficiently run the database systems.
4. Database Failure
In the database systems, all the data or information of an organization is stored in one
centralized database. If the database of that organization fails, then the data is lost, and
the organization will collapse. So, database failure is a big problem with the database
management system.    
5. Increased Staff Cost (Training costs)
DBMS requires an educated and skilled staff for managing and maintaining the
databases. So, you’d need to spend a lot of money to get this level of trained and
experienced staff.

6. Huge Size
The size of the database is not big at the initial state, but when the user stores a large
amount of data, then it creates many problems. Due to the huge data, database systems do
not provide good results and do not run efficiently. That’s why the size is another
limitation of the database systems.

7. Requirement of Technical Staff


A non-technical people can’t understand the complexity of the database. So, the technical
staff is required for maintaining and handling the database management system.

8. Cost of Data Conversion


It is one of the big disadvantages of the database management system because the cost of
data conversion is very high. There is a requirement for trained, skilled, and experienced
database administrators for converting the data smoothly.

9. Cost of conversion
In some situations, the cost of the DBMS and any extra hardware may be insignificant
compared with the cost of converting existing applications to run on the new DBMS and
hardware. This cost also includes the cost of training staff to use these new systems, and
possibly the employment of specialist staff to help with the conversion and running of the
system.

10. Performance
Since the DBMS is written to be more general, to cater for many applications rather than
just one. The effect is that some applications may not run very fast

11. Higher impact of a failure


The centralization of resources increases the vulnerability of the system. Since all users
and applications rely on the availability of the DBMS, the failure of any component can
bring operations to a complete halt until the failure is repaired.

Page 18 of 19
Question 6: Describe situations when it might be advisable NOT to use a DBMS

Page 19 of 19

You might also like