You are on page 1of 14

14-Sep-2023 DBMS (Batch 2 Question)

1. (a) A bakery is seeking to expand its business.


Identify TWO (2) areas of the business that would benefit from the database.
For each area explain how the bakery would benefit.
Certainly! A database can be immensely beneficial for a bakery in various aspects. Here are two
areas where implementing a database system would be particularly advantageous:
Inventory Management:
Benefits:
Real-time Tracking: A database can be used to track the bakery's inventory in real-time. This means
the bakery can always know how much flour, sugar, eggs, etc. they have in stock. This prevents
overstocking or running out of crucial ingredients.
Order Management: It can help in managing orders by keeping track of available items and updating
quantities as items are sold. This helps prevent over-promising or disappointing customers due to
items being out of stock.
Waste Reduction: With accurate inventory data, the bakery can reduce waste by avoiding over-
purchasing perishable items. This can lead to cost savings.
Forecasting and Planning: Historical data stored in the database can be used to make informed
decisions about future inventory needs. For instance, it can help in planning for seasonal variations in
demand.

Customer Relationship Management (CRM):


Benefits:
Customer Profiling: A database can store customer information, including purchase history,
preferences, contact details, etc. This allows the bakery to better understand its customers and tailor
offerings to their preferences.
Marketing and Promotions: By analyzing customer data, the bakery can target specific customer
segments with tailored marketing campaigns, promotions, and special offers.
Feedback and Reviews: A database can track customer feedback and reviews. This information is
valuable for improving products and services based on customer input.
Loyalty Programs: It can be used to manage loyalty programs where customers can earn rewards
based on their purchases. The database would track points and redemption history.

Implementing a database for both inventory management and customer relationship management
would not only streamline operations but also enable the bakery to provide a more personalized and
efficient service to its customers. It would also facilitate data-driven decision-making, which is
crucial for the bakery's growth and success in a competitive market.
1. (b) fast food restaurant
Customer
Order
MenuItem
Employee
Ingredient
Location

4. (a) (1) What is the degree in database term


4. (a) (2) what is the schema in database term

In database terminology, "degree" refers to the number of attributes (or columns) in a relation (table)
in a database. It indicates how many properties or characteristics are associated with each tuple (row)
in a relation.
For example, if you have a relation named "Employees" with attributes like EmployeeID, FirstName,
LastName, and Position, then the degree of the "Employees" relation is 4 because it has four
attributes.
A database schema is considered the “blueprint” of a database which describes how the data may
relate to other tables or other data models. However, the schema does not actually contain data.
A schema describes the organization and storage of data in a database and defines the relationship
between various tables.
Database Schema Definition
A database schema refers to the logical and visual configuration of the entire relational database. The
database objects are often grouped and displayed as tables, functions, and relations. A schema
describes the organization and storage of data in a database and defines the relationship between
various tables. A database schema includes descriptive details of the database that can be depicted
through schema diagrams.
How are database schemas designed?
Database designers create database schemas to help programmers interact with the database
efficiently. The process of creating a database is known as data modeling. To design a database
schema, you need to gather information and arrange them into tables, rows, and columns. You need
to organize the information to make it easier to understand, relate, and use.
What is database schema design?
Database schema design provides a blueprint to develop the architecture of the database, so a
massive amount of information can be stored systematically. It also refers to the strategies and best
practices involved in constructing a database. Database schema design makes the data much easier to
consume, interpret, and retrieve by organizing it into separate entities and determining the
relationships between organized entities.
How to design a database schema
Database schema design ensures data has consistent formatting, all entries have a primary key, and
important data is not excluded. A database schema can exist as visual or logical, including a set of
formulas to govern the database. Developers use these formulas and data definitions to create the
database schema.
The most common types of database schemas are outlined below:
Hierarchical model: A database schema with tree-like structures with child nodes attached to the
root node is hierarchical. This database schema model can store nested data, including family trees.
Flat model: A flat model organizes data into a single or two-dimensional array-like in a spreadsheet
with rows and columns. The model is appropriate for simple data without complex relations that can
be arranged in tabular format.
Relational model: The relational model is similar to a flat model in which data is organized into
tables, rows, and columns. However, in this model, you can define relationships between different
entities.
Star schema: A star database schema organizes data into "dimensions" and "facts." Dimensions
include descriptive data, while facts have numeric values.
Snowflake schema: The snowflake database schema is a logical representation of data in a database.
The representation of this type of schema is similar to snowflake, where multiple dimensions are
attached to a single centralized fact table.
Network model: A network database schema includes data as multiple nodes connected. This model
is used to accomplish specific tasks as it allows complex connections such as many-to-many
relationships.

Best practices for database schema design


Outlined below are a few best practices to make the best use of your database schema.
Security: An effective database schema design must focus on data security. Assign roles and
responsibilities to each database user, avoid unauthorized access, and use advanced encryption to
secure sensitive data such as login credentials, personally identifiable information (PII), and
passwords.
Name conventions: To make your schema design more effective, you can define appropriate naming
conventions in your database. Avoid using complex names, special characters, and reserved words in
tables, columns, and field names.
Normalization: Normalization helps eliminate redundancy by ensuring independent entities and
relationships aren’t grouped in the same table and columns. This improves the integrity of the data
and makes it easier for developers to retrieve information. Normalization can also be used to
optimize database performance.
Documentation: Database schemas are crucial for developers and creating documentations. You
must document your database schema design along with instructions, comments, scripts, and more.
What are the two main kinds of database schema?
Physical database schema: The physical database schema represents the physical arrangement of data
and how it’s stored in blocks of storage such as files, indices, key-value pairs.
Logical database schema: Logical database schema describes the logical representation of data and
conveys logical constraints. The data can be described as certain types of data records and is stored
as different data structures. However, internal details like data implementation are hidden at this
level.
What are database schemas used for?
Database schemas are cognitive frameworks or concepts designed to organize information
systematically. Schemas allow interpreting a vast amount of information quickly. Unorganized
databases can be confusing and difficult to maintain and administer. With a clean, efficient, and
consistent database schema design, you can make the best use of your organization's data. Relational
databases highly depend on database schema design to eliminate data redundancy, prevent data
inconsistencies, facilitate data retrieval and analysis, ensure the integrity of the data, and keep it safe
from unauthorized access. It’s crucial to organize data into tables and columns with a strong test
environment. You need a plan to manage data integrity and update your database and source code.

4. (b) primary key, foreign key, data integrity


Primary Key
A primary key, also called a primary keyword, is a column in a relational database table that's
distinctive for each record. It's a unique identifier, such as a driver's license number, telephone
number with area code or vehicle identification number (VIN). A relational database must have only
one primary key. Every row of data must have a primary key value and none of the rows can be null.
The choice of a primary key in a relational database often depends on the preference of the
administrator.
Every entity in a data model should have a primary key, which should be based on a single attribute
or a group of attributes.
The following are the main benefits of a primary key:
helps identify unique data, such as a customer ID;
prevents duplication of records in a table;
helps with updating or deleting only specific records;
helps ensure that fields aren't null;
helps set up relationships between tables; and
ensures row-level accessibility.
A primary key is critical to the operations of an RDBMS. A single table contains thousands of
records, including duplicates. Therefore, it's imperative to use a primary key or closely
related foreign key to ensure no record is ever duplicated and is always uniquely identified.
The following are a few common examples of primary keys:
Social Security Number (SSN). U.S. citizens are issued uniquely identifiable social security
numbers, which can be used as a primary key in a relational database. Some organizations prefer to
use SSNs, as each employee already has one and because of their uniqueness. However, due
to privacy concerns, the use of an SSN can be controversial.
Vehicle Identification Number (VIN). A VIN is a good example of a primary key for a relational
database for a vehicle registration system, as no two vehicles can have the same VIN.
Driver's license number. Driver's licenses are examples of primary keys, as they can officially
identify each user as a licensed driver and their street address in the Department of Motor Vehicles'
database.
Student ID. Students are routinely given a unique ID known as a student ID. Since each student ID is
different for each student, it can be used as a primary key for a database table.
An automatically generated number. This can be an automatically generated key when a new record
is inserted into a table.
How to choose a strong primary key
Strong primary keys are the foundation of an efficient database design. Database developers should
keep the following best practices in mind when trying to create a primary key:
Length. The primary key should be short and consist of one column whenever possible.
Data type. The data type of a primary key should be a numeric, an integer or a short, fixed-width
character.
Uniqueness. A primary key must have a unique value, which implies that no other row in the table
has the same value in the column.
Non-null data value. The data value of a primary key should be non-null and remain constant over
time.
Relevance. The data value used for a primary key should stay relevant. For example, it should mean
the same thing five years from now as it does today.
What's the difference between a primary key, a composite key and a foreign key?
Keys are the fundamental elements used to form a relationship between two tables inside a relational
database. There are stark differences between the three types of database keys -- primary, composite
and foreign keys -- proving the complex nature of relational database standards.
The following are the main characteristics of a primary key, a composite key and a foreign key:
Primary key
The data in a specific column is always unique.
A database table can only have one primary key.
It uniquely identifies a record in a relational database table.
The value of a primary key can't be deleted from the tree structure or the parent table.
It doesn't permit null values.

Foreign key
It links two tables together. This means that the foreign key in one table may refer to the primary key
of another table.
There can be more than one foreign key in a table.
The foreign key column accepts a null value.
It can make a parent-child relationship in a table.
Duplicate values can be stored in the foreign key column.
Composite key
This type of primary key consists of two or more attributes, such as multiple columns.
The data types of different columns could differ from each other.
It becomes the composite key when more than a single column is used to uniquely identify each row
in the table.

Data Integrity
Data integrity is the overall accuracy, completeness, and consistency of data.
When the integrity of data is secure, the information stored in a database will remain complete,
accurate, and reliable, no matter how long it’s stored or how often it’s accessed.
Types of data integrity
Maintaining data integrity requires an understanding of the two types of data integrity: physical
integrity and logical integrity.

Physical integrity
Physical integrity is the protection of the completeness and accuracy of that data as it’s stored,
maintained in storage, and retrieved. When natural disasters strike, the power goes out, or a disk
drive crashes, the physical integrity of data is compromised. Human error, storage erosion, and a host
of other issues can also make it impossible for data processing managers, system programmers,
applications programmers, and internal auditors to obtain accurate data.

Logical integrity
Logical integrity keeps data unchanged as it’s used in different ways in a relational database. Logical
integrity protects data from human error and hackers as well, but in a much different way than
physical integrity does. There are four types of logical integrity:
Entity integrity. Entity integrity relies on the creation of primary keys — the unique values that
identify pieces of data — to ensure that data isn’t listed more than once and that no field in a table is
null. It’s a feature of relational systems which store data in tables that can be linked and used in a
variety of ways.
Referential integrity. Referential integrity refers to the series of processes that make sure data is
stored and used uniformly. Rules embedded into the database’s structure about how foreign keys are
used ensure that only appropriate changes, additions, or deletions of data occur. Rules may include
constraints that eliminate the entry of duplicate data, guarantee that data entry is accurate, and/or
disallow the entry of data that doesn’t apply.
Domain integrity. Domain integrity is the collection of processes that ensure the accuracy of each
piece of data in a domain. In this context, a domain is a set of acceptable values that a column is
allowed to contain. It can include constraints and other measures that limit the format, type, and
amount of data entered.
User-defined integrity. User-defined integrity involves the rules and constraints created by the user
to fit their particular needs. Sometimes entity, referential, and domain integrity aren’t enough to
safeguard data. Often, specific business rules must be taken into account and incorporated into data
integrity measures.
Data integrity is not data security
Data security is the collection of measures taken to keep data from getting corrupted. It incorporates
the use of systems, processes, and procedures that restrict unauthorized access and keep data
inaccessible to those who may wish to use it in harmful or unintended ways. Breaches in data
security may be small and easy to contain or large and capable of causing significant damage.
While data integrity is concerned with keeping information intact and accurate for the entirety of its
existence, the goal of data security is to protect information from outside attacks. Data security is but
one of the many facets of data integrity. Data security is not broad enough to include the many
processes necessary for keeping data complete and accurate over time.

6. (a) Woof Walkers is a local dog walking service that will walk owners’ pets
throughout the day.
The cost of the service for each dog is included in the dog’s details. A dog
walker is given a walk rota each day which lists the dog(s) that they have to
walk.

Customer
customerID
firstName
lastName
contactInfo(email, phone)
address

DogWalker
walkerID
firstName
lastName
emailAddress
phoneNumber
available

Dog
dogID
name
breed
age
size
medicalCondition
(dog-customer one-to-many relationship)

Walk/ Rota
walkerName
dogName
dateTime
duration
location
specialInstruction

Walker's Name: The person responsible for the walk.


Date and Time: When the walk is scheduled to take place.
Duration: How long the walk is expected to last.
Dog(s): The name(s) or ID(s) of the dog(s) scheduled for the walk.
Special Instructions: Any specific requirements or instructions for each dog on the walk.
Location: Where the walk will take place.

WalkSchedule
scheduleID
date
time
duration
(walker – walkSchedule one-to-many relationship walker can have
Many schedule)

Booking
bookingID
customerID
dogID
scheduleID
Relationships:
Each booking will be associated with one customer, one dog, and one schedule. This forms a many-
to-one relationship between Customer, Dog, Walk Schedule, and Booking.
These entities and their relationships should provide a good starting point for creating your ER
diagram for the dog walking service. Keep in mind that this is a simplified representation and there
may be additional attributes or entities depending on the specific requirements of the service.

A "walk rota" typically refers to a schedule or roster that outlines the planned or assigned walking
shifts for individuals responsible for tasks like dog walking, particularly in professional dog walking
services or animal care facilities.
In the context of a dog walking service, a walk rota would include information such as:
Walker's Name: The person responsible for the walk.
Date and Time: When the walk is scheduled to take place.
Duration: How long the walk is expected to last.
Dog(s): The name(s) or ID(s) of the dog(s) scheduled for the walk.
Special Instructions: Any specific requirements or instructions for each dog on the walk.
Location: Where the walk will take place.
The purpose of a walk rota is to ensure that each dog receives their scheduled walk, and that walkers
have a clear plan for their responsibilities. It helps in managing resources, maintaining a structured
routine for the dogs, and ensuring that no dog is overlooked.
For a professional dog walking service, efficient use of a walk rota can be crucial in providing high-
quality care and services to clients and their pets. It also aids in managing the availability of walkers,
allowing for better planning and coordination.

7. (a) As part of the design stage of a database a CRUD matrix will be used. What
does CRUD mean and provide a clear example for each function.
CRUD is an acronym that stands for Create, Read, Update, and Delete. It is a fundamental concept
in database management and represents the four basic functions that can be performed on data within
a database.
Create:
Function: Create involves adding new data records to a database.
Read:
Function: Read involves retrieving or viewing existing data from a database.
Update:
Function: Update involves modifying or changing existing data records in a database.
Delete:
Function: Delete involves removing existing data records from a database.

How is CRUD performed in a database?


In RDBMS, CRUD operations are performed through Structure Query Language (SQL) commands
The INSERT statement is used for CREATE:
INSERT INTO <table name> VALUES (field value 1, field value, 2…)

The SELECT statement is used for READ:


SELECT field 1, field 2, …FROM <table name> [WHERE <condition>]

The UPDATE statement is used for UPDATE:


UPDATE <table name> SET field1=value1, field2=value2,… [WHERE <condition>]

The DELETE statement is used for DELETE:


DELETE FROM <table name> [WHERE <condition>]

7. (b) Explain the purpose and benefit(s) of a CRUD matrix.


The purpose of the CRUD matrix is to manage the data within a database.

8. (c) Hardware, software and people are said to be components of the DBMS
environment.
Describe what is meant by ‘people’, ensuring you provide a concise answers.
We can identify five major components in the DBMS environment:
1. hardware,
2. software,
3. data,
4. procedures, and
5. people

Hardware
The DBMS and the applications require hardware to run. The hardware can range from
a single personal computer, to a single mainframe, to a network of computers. The particular
hardware depends on the organization’s requirements and the DBMS used. Some
DBMSs run only on particular hardware or operating systems, while others run on a wide
variety of hardware and operating systems. A DBMS requires a minimum amount of main
memory and disk space to run, but this minimum configuration may not necessarily give
acceptable performance.

Software
The software component comprises the DBMS software itself and the application programs,
together with the operating system, including network software if the DBMS is being used
over a network.
Data
The most important component of the DBMS environment, certainly from the end-users’ point of
view, is the data. The database contains both the operational data and the metadata, the ‘data about
data’. The structure of the database is called the schema.

Procedure
Procedures refer to the instructions and rules that govern the design and use of the database. The
users of the system that manage the database require documented procedures on how to use or run
the system. These may consist of instructions on how to:
- log on to the DBMS;
- use a particular DBMS facility or application program;
- start and stop the DBMS;
- make backup copies of the database;
- handle hardware or software failures. This may include procedures on how to identify
the failed component, how to fix the failed component (for example, telephone the
appropriate hardware engineer) and, following the repair of the fault, how to recover the
database;
- change the structure of a table, reorganize the database across multiple disks, improve
performance, or archive data to secondary storage.

People
The fifth component of the DBMS environment: the people.
We can identify four distinct types of people that participate in the DBMS environment:
Data and database administrators,
Database designers,
Application developers, and
End-users.

Data and Database Administrator


The database and the DBMS are corporate resources. Data and database administration are the roles
generally associated with the management and control of a DBMS and its data.
The Data Administrator (DA) is responsible for the management of the data resource including
database planning, development and maintenance of standards, policies and procedures, and
conceptual/logical database design. The DA consults with and advises senior managers, ensuring that
the direction of database development will ultimately support corporate objectives.
The Database Administrator (DBA) is responsible for the physical realization of the database,
including physical database design and implementation, security and integrity control, maintenance
of the operational system, and ensuring satisfactory performance of the applications for users. The
role of the DBA is more technically oriented than the role of the DA, requiring detailed knowledge
of the target DBMS and the system environment.
In some organizations there is no distinction between these two roles.
Database Designer
In large database design projects, we can distinguish between two types of designer:
logical database designers and physical database designers.
1. The logical database designer is concerned with identifying the data (that is, the entities and
attributes), the relationships between the data, and the constraints on the data that is to be stored in
the database. The logical database designer must have a thorough and complete understanding of the
organization’s data and any constraints on this data (the constraints are sometimes called business
rules).
2. The physical database designer decides how the logical database design is to be physically
realized. This involves:
mapping the logical database design into a set of tables and integrity constraints;
selecting specific storage structures and access methods for the data to achieve good performance;
designing any security measures required on the data.

Application Developer
Once the database has been implemented, the application programs that provide the
required functionality for the end-users must be implemented. This is the responsibility of
the application developers. Each program contains statements that request the DBMS to perform
some operation on the database. This includes retrieving data, inserting, updating, and deleting data.

End User
The end-users are the ‘clients’ for the database. End-users can be classified according to the way
they use the system:
Naïve users are typically unaware of the DBMS. They access the database through
specially written application programs that attempt to make the operations as simple as
possible. They invoke database operations by entering simple commands or choosing
options from a menu. This means that they do not need to know anything about the
database or the DBMS. For example, the checkout assistant at the local supermarket
uses a bar code reader to find out the price of the item. However, there is an application
program present that reads the bar code, looks up the price of the item in the database,
reduces the database field containing the number of such items in stock, and displays
the price on the till.
Sophisticated users. At the other end of the spectrum, the sophisticated end-user is
familiar with the structure of the database and the facilities offered by the DBMS.
Sophisticated end-users may use a high-level query language such as SQL to perform
the required operations. Some sophisticated end-users may even write application programs for their
own use.

The Database Management System (DBMS) environment consists of various components that work
together to facilitate the management and utilization of databases. These components include:
Hardware:
This includes the physical equipment required to host and run the DBMS. It encompasses servers,
storage devices, networking components, and other computing resources.
Software:
DBMS Software: The actual DBMS software itself, which provides the interface and tools for
creating, managing, and interacting with databases.
Operating System: The underlying operating system on which the DBMS software runs.
Data:
The actual information stored in the databases, including structured data (e.g., tables, records) and
potentially unstructured data (e.g., documents, images).
Procedures:
These are the set of instructions or rules that guide the users and administrators in performing
specific tasks related to the database. This can include data entry protocols, backup and recovery
procedures, and more.
Users:
Database Administrators (DBAs): Responsible for the overall management, configuration, and
maintenance of the DBMS environment. They handle tasks like backups, security, and performance
optimization.
Database Developers: Responsible for designing and implementing the database schema, creating
queries, and writing code to interact with the database.
End Users: These are the individuals or applications that interact with the database to retrieve,
update, and analyze data. They may have varying levels of access and permissions.

Application Programs:
These are software programs that interact with the database using APIs (Application Programming
Interfaces) provided by the DBMS. Application programs include web applications, desktop
applications, and other software that utilize the database for data storage and retrieval.
Query Language:
This is a language provided by the DBMS for users and applications to interact with the database.
SQL (Structured Query Language) is one of the most common query languages used in relational
database management systems.
Security and Authorization:
This component encompasses the mechanisms and protocols in place to ensure that only authorized
users have access to the database. It includes user authentication, access control, encryption, and
auditing.
Backup and Recovery:
These processes and procedures ensure that data is regularly backed up and can be restored in case of
accidental deletion, data corruption, or system failures.
Concurrency Control:
This component manages simultaneous access to the database by multiple users or applications to
prevent conflicts and maintain data consistency.

Monitoring and Performance Tuning:


Tools and processes for monitoring the health and performance of the database, as well as optimizing
its performance through tasks like indexing, query optimization, and resource allocation.

Documentation and Metadata:


Information about the structure of the database, including data definitions, relationships, constraints,
and other metadata, is crucial for understanding and managing the database.
These components collectively form the DBMS environment, providing the necessary resources,
tools, and procedures for creating, managing, and using databases effectively.

You might also like