Vous êtes sur la page 1sur 92

INFORMATION

MANAGEMENT 1
LABORATORY MANUAL
Prepared By
Mrs. Bermelita T. Domingo, MIT

Name of Student:

Course & Year:

School Year:

Semester:

Information Technology Department


Center of Development
School of Engineering, Architecture and Information Technology
Saint Mary’s University | Bayombong, Nueva Vizcaya
CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

TABLE OF CONTENTS

TITLE OF CONTENT PAGE

1 SMU PROGRAM EDUCATIONAL OUTCOMES

2 BSIT PROGRAM OUTCOMES

3 COURSE DESCRIPTION

4 LABORATORY DO’S AND DON’T’S

5 INSTRUCTIONS TO STUDENTS

6 GUIDELINES FOR INSTRUCTORS

7 LIST OF LABORATORY EXERCISES

8 PROJECT DESCRIPTION

9 REFERENCES

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 1


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

SMU PROGRAM EDUCATIONAL OUTCOMES

The Bachelor of Science in Information Technology (BSIT) program prepares graduates to develop
experts in information technology and computing sciences equipping our graduates to prepare well for their
career as I.T. professionals and become tomorrow’s leaders and achievers in the industry, the academe and the
government. They can work in an IT organization or department and contribute to the achievement of the
business goals and objectives though the Implementation and use of information technology.

The BSIT program supports the vision/missions of the school and the institution and will enable its
graduates to:
 Have the ability to hold progressively more responsible positions in the IT field, including positions
that are supervisory or managerial in nature.
 Engage in life-long learning and professional development.
 Communicate effectively as an IT professional with users, peers, and higher management.
 Work effectively on teams, whether as a participant or as a leader.
 Demonstrate ethical behavior as an IT professional and sensitivity to the impact of technology on
society.

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 2


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

BSIT PROGRAM OUTCOMES


The BSIT is a four-year degree program designed to prepare graduates to address various user needs
involving the selection, development, application, integration and management of computing technologies
within an organization. The program includes the study of the utilization of both hardware and software
technologies involving planning, installing, customizing, operating, managing and administering and
maintaining information technology infrastructure that provides computing solutions to address the needs of an
organization.

The program prepares graduates to address various user needs involving the selection, development,
application, integration and management of computing technologies within organization.

After finishing the BSIT program, the graduate should be able to:

Common to all Programs


PO1 Articulate and discuss the latest developments in the specific field of practice
PO2 Effectively communicate orally and in writing using both English and Filipino
PO3 Work effectively and independently in multi-disciplinary and multi-cultural teams
PO4 Act in recognition of professional social and ethical responsibility
PO5 Preserve and promote Filipino historical and cultural heritage
Common to Discipline
PO6 Analyze complex problems and identify and define the computing requirements needed to design
an appropriate solution
PO7 Apply computing and other knowledge domains to address real world problems
PO8 Design and develop computing solutions using a system level perspective
PO9 Utilize modern computing tools
Specific to a Sub-Discipline
Knowledge for Solving Computing Problems
PO10 Apply knowledge of computing science and mathematics appropriate to the discipline
PO11 Demonstrate best practices and standards and their applications
Problem Analysis
PO12 Analyze complex problems and identify and define computing requirements appropriate to its
solution
PO13 Identify and analyze user needs and take them into account in the selection, creation, evaluation
and administration of computer based systems
Design/Development of Solutions
PO14 Design, implement and evaluate computer based systems, processes, components, or programs to
meet desired needs and requirements under various constraints
PO15 Integrate IT based solutions into the user environment effectively
Modern Tool Usage
PO16 Apply knowledge through the use of current techniques, skills, tools and practices necessary for the
IT profession.
Individual and Team Work
PO17 Function effectively as a member or leader of a development team recognizing the different roles
within a team to accomplish a company’s goal.
PO18 Assist in the creation of an effective IT project plan.
Communication
PO19 Communicate effectively with the computing community and with society at large about complex
computing activities through logical writing, presentations and clear instructions.
[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 3
CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

Computing Professionalism and Social Responsibility


PO20 Analyze the local and global impact of computing information technology on individuals,
organizations and society.
PO21 Understand professional, ethical, legal security and social issues and responsibilities in the
utilization of information technology.
Life Long Learning
PO22 Recognize the need for and engage in planning self-learning and improving performance as a
foundation for continuing professional development.

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 4


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

COURSE DESCRIPTION

Course Descriptive Title INFORMATION MANAGEMENT I

Pre-requisites Data Structures and Algorithms

Credit Hours Lecture: 2 Laboratory: 3 Total: 5

Time Allotment Lecture: 36 Laboratory: 54 Total: 90

Course Description This course will introduce to the students the concepts of database
management. This will also teach the students the skills necessary to build and
design databases. Issuance of queries to access and manipulate records will also
be covered in this course. The course includes four major topics namely: (1)
introduction to databases; (2) entity-relationship model (3) relational model
and (4) introduction to SQL query;

The first topic introduces the students to databases including its history as well
as how databases evolved thru time. It also gives a comparison between using
databases and file systems. The second topic intends to challenge and improve
the logical thinking skills of students thru sets of requirements that require
conversion to an entity-relationship (ER) diagram. The third topic aims to teach
the students the core concepts of the relational database model. The fourth topic
includes working on data using Data Definition Languages and Data
Manipulation Languages. This will give the students a glimpse of how data
inside a database management system (DBMS) is created and manipulated.

Course Outcomes After completing this course, you should be able to:

 Discuss the basic concepts, best practices and standards in database


management
 Evaluate the different latest database management tools
 Create an Entity Relationship Diagram that suits to the given
requirements
 Build a functional database using the different database models
 Utilize specified database management system software through the
use of Structured Query Language

Software Tools  Microsoft SQL Server


 MySQL Server
 MySQL Workbench
 PDF Reader
 Internet browsers
 Word Documents

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 5


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

LABORATORY RULES AND GUIDELINES


A. Students are not allowed to:
1. Enter/use the computer laboratory rooms without the permission of the subject instructor
2. Reconfigure and modify/change desktop settings especially screen savers or setup of any computer
terminal
3. Open or load software especially games not related to the lesson/subject
4. Use flash drive or CDs without the permission of instructor and the computer laboratory technician
5. Eat and drink inside the computer laboratory room
6. Open, delete or modify files of other students
7. Transfer from one computer to another without the consent or permission of the instructor
8. Write or vandalize the computer units or its peripherals
9. Transfer computer parts/units and its peripherals to another unit
B. Student caught stealing/tampering with computer units and/or its peripherals will replace the computer
parts/units lost and will be subjected to disciplinary action.
C. Sit-in are strictly prohibited.
D. All belongings except jewelries, wallets and cellphones should deposited in the area provided for, only
writing pens and notebooks should be bought in the workstations.
E. Each student per subject should be assigned to a permanent computer terminal to use for the whole
duration of the semester.
F. Modification, damage, error or terminal malfunction should immediately be reported to instructor and/or
computer laboratory technicians for proper action.
G. Practice the CLEAN, HEALTHY, SAFE and FRIENDLY program of the university in computer
laboratories at all time.

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 6


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

LIST OF LABORATORY EXERCISES

CHAPTER 1: Overview of Database Environment and Development Process


Laboratory Exercise 1:1- Overview of Databases
Laboratory Exercise 1:2- DBMS Components
Laboratory Exercise 1:3- DBMS Architectures
Laboratory Exercise 1:4- DBMS Models
Laboratory Exercise 1:5- Requirements Gathering

CHAPTER 2: Entity Relationship (ER) Model


Laboratory Exercise 2:1- Entities and Attributes
Laboratory Exercise 2:2- Weak Entity
Laboratory Exercise 2:3- ERD Notations
Laboratory Exercise 2:4- Creating ER Diagrams
Laboratory Exercise 2:5- Creating ER Diagrams
Laboratory Exercise 2:6- Creating ER Diagrams
Laboratory Exercise 2:7- Enhanced ER Model

CHAPTER 3: Relational Model


Laboratory Exercise 3:1- Codd’s 12 Rules
Laboratory Exercise 3:2- Implementation of RDBMS
Laboratory Exercise 3:3- Referential Integrity Constraints
Laboratory Exercise 3:4- RDBMS Basic Concepts

CHAPTER 4: Database Normalization


Laboratory Exercise 4:1- Introduction to Normalization
Laboratory Exercise 4:2- Normalization Forms
Laboratory Exercise 4:3- Database Normalization (3NF)

CHAPTER 5: Introduction to SQL


Laboratory Exercise 5:1- DDL Statements
Laboratory Exercise 5:2- DDL Statements
Laboratory Exercise 5:3- DML Statements
Laboratory Exercise 5:4- DQL Statements
Laboratory Exercise 5:5- DQL Statements
Laboratory Exercise 5:6- DQL Statements
Laboratory Exercise 5:7- DQL Statements
Laboratory Exercise 5:8- DQL Statements
Laboratory Exercise 5:9- DQL Statements
Laboratory Exercise 5:10- DQL Statements

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 7


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

INSTRUCTIONS TO STUDENTS
1. Students should be regular and come prepared for the laboratory exercises.
2. In case a student misses a class, it is his/her responsibility to complete that missed activities
3. Students should bring the observation book, lab journal and lab manual. Prescribed textbook and class
notes can be kept ready for reference if required.
4. They should implement the given experiment individually.
5. While conducting the experiments students should see that their output would meet the following
criteria:
a. Program Correctness: The application meets all the requirements specified in the project
specification.
b. Effective Communication / Concept Understanding: Answers to question are correct,
reasonable, and reflective of the code.
c. Readability: The program conforms to a coding standard that promotes code readability.

6. Once the experiment(s) get executed, they should show the process and ouput to the instructors and
copy the same in their observation book.
7. Questions for lab tests and exam need not necessarily be limited to the questions in the manual, but
could involve some variations and / or combinations of the questions.

GUIDELINES FOR INSTRUCTORS


1. Students should be informed in the beginning itself that questions in the practical examination will not
necessarily be limited to the questions from the manual, but could involve some variations and/or
combinations of the questions mentioned in the manual.
2. A group of questions of similar complexity are grouped for a lab. The instructor can choose any
arbitrary set of 3 to 5 questions from the manual for that week so as to avoid students copying from
previous batches and also enables the instructor to assess the student.

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 8


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

CHAPTER 1:
OVERVIEW OF DATABASE ENVIRONMENT

Introduction

Data is nothing but facts and statistics stored or free flowing over a network, generally it's raw and unprocessed.
For example: When you visit any website, they might store you IP address, that is data, in return they might
add a cookie in your browser, marking you that you visited the website, that is data, your name, it's data, your
age, it's data.
Data becomes information when it is processed, turning it into something meaningful. Like, based on the cookie
data saved on user's browser, if a website can analyze that generally men of age 20-25 visit us more, that is
information, derived from the data collected.

What is a Database?
A Database is a collection of related data organized in a way that data can be easily accessed, managed and
updated. Database can be software based or hardware based, with one sole purpose, storing data.
During early computer days, data was collected and stored on tapes, which were mostly write-only, which
means once data is stored on it, it can never be read again. They were slow and bulky, and soon computer
scientists realized that they needed a better solution to this problem.
Larry Ellison, the co-founder of Oracle was amongst the first few, who realized the need for a software based
Database Management System.

What is DBMS?
A DBMS is a software that allows creation, definition and manipulation of database, allowing users to store,
process and analyze data easily. DBMS provides us with an interface or a tool, to perform various operations
like creating database, storing data in it, updating data, creating tables in the database and a lot more.
DBMS also provides protection and security to the databases. It also maintains data consistency in case of
multiple users.
Here are some examples of popular DBMS used these days:

 MySql
 Oracle
 SQL Server
 IBM DB2
 PostgreSQL
 Amazon SimpleDB (cloud based) etc.

Characteristics of Database Management System


A database management system has following characteristics:
Data stored into Tables: Data is never directly stored into the database. Data is stored into tables, created
inside the database. DBMS also allows to have relationships between tables which makes the data more
meaningful and connected. You can easily understand what type of data is stored where by looking at all the
tables created in a database.

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 9


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

Reduced Redundancy: In the modern world hard drives are very cheap, but earlier when hard drives were too
expensive, unnecessary repetition of data in database was a big problem. But DBMS follows Normalization
which divides the data in such a way that repetition is minimum.
Data Consistency: On Live data, i.e. data that is being continuously updated and added, maintaining the
consistency of data can become a challenge. But DBMS handles it all by itself.
Support Multiple user and Concurrent Access: DBMS allows multiple users to work on it (update, insert,
delete data) at the same time and still manages to maintain the data consistency.
Query Statements: DBMS provides users with a simple Query Statements, using which data can be easily
fetched, inserted, deleted and updated in a database.
Security: The DBMS also takes care of the security of data, protecting the data from un-authorized access. In
a typical DBMS, we can create user accounts with different access permissions, using which we can easily
secure our data by restricting user access.
DBMS supports transactions, which allows us to better handle and manage data integrity in real world
applications where multi-threading is extensively used.

Advantages of DBMS
 Segregation of application program.
 Minimal data delicacy or data redundancy.
 Easy retrieval of data using the Query Statements.
 Reduced development time and maintenance need.
 With Cloud Datacenters, we now have Database Management Systems capable of storing almost
infinite data.
 Seamless integration into the application programming statements which makes it very easier to add a
database to almost any application or website.

Disadvantages of DBMS
 It's Complexity
 Except MySQL, which is open source, licensed DBMSs are generally costly.
 They are large in size.

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 10


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

Laboratory Exercise 1.1


OVERVIEW OF DATABASES
Name Score

Course & Year Date

In this lab, you will be able to:


1. Differentiate data with information
2. Describe the application of database management system in an organization

Direction: Answer the following questions on the space provided.

1. Using the internet, look for companies/organizations/agencies which uses database approaches and provide
the following details:
Name of
Company/Agency/Organization

Data involved

Output/information provided

URL/Source

2. Based on your output on #1, enumerate some of the characteristics of database management system that
can be found within the website. Provide brief discussion in each characteristic.
Example: Security: The company secures information through authentication of users.
Characteristics Discussion

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 11


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

Components of DBMS
The database management system can be divided into five major components; they are:

 Hardware
 Software
 Data
 Procedures
 Database Access Statements
Let's have a simple diagram to see how they all fit together to form a database management system.

Hardware
When we say Hardware, we mean computer, hard disks, I/O channels for data, and any other physical
component involved before any data is successfully stored into the memory.
When we run Oracle or MySQL on our personal computer, then our computer's Hard Disk, our Keyboard using
which we type in all the commands, our computer's RAM, ROM all become a part of the DBMS hardware.
Software
This is the main component, as this is the program which controls everything. The DBMS software is more
like a wrapper around the physical database, which provides us with an easy-to-use interface to store, access
and update data.

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 12


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

The DBMS software is capable of understanding the Database Access Statements and interpret it into actual
database commands to execute them on the DB.
Data
Data is that resource, for which DBMS was designed. The motive behind the creation of DBMS was to store
and utilize data.
In a typical Database, the user saved Data is present and meta data is stored.
Metadata is data about the data. This 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.
Procedures
Procedures refer to general instructions to use a database management system. This includes procedures to
setup and install a DBMS, to login and logout of DBMS software, to manage databases, to take backups,
generating reports etc.
Database Access Statements
Database Access Statements is a simple Statements designed to write commands to access, insert, update and
delete data stored in any database.
A user can write commands in the Database Access Statements and submit it to the DBMS for execution, which
is then translated and executed by the DBMS.
User can create new databases, tables, insert data, fetch stored data, update data and delete the data using the
access Statements.

Users
Database Administrators: Database Administrator or DBA is the one who manages the complete database
management system. DBA takes care of the security of the DBMS, it's availability, managing the license keys,
managing user accounts and access etc.
Application Programmer or Software Developer: This user group is involved in developing and designing the
parts of DBMS.
End User: These days all the modern applications, web or mobile, store user data. How do you think they do
it? Yes, applications are programmed in such a way that they collect user data and store the data on DBMS
systems running on their server. End users are the one who store, retrieve, update and delete data.

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 13


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

Laboratory Exercise 1.2


DBMS COMPONENTS
Name Score

Course & Year Date

In this lab, you will be able to:


1. Determine the different components of databases in an organization

1. Saint Mary’s University is using a database approach information system for processing data within the
school. Describe the different components of database management system being used. Describe also the
different users.

Description of school’s DBMS components Description of DBMS users

2. Among the different DBMS components, which is the most vital component? Discuss your answer.

_______________________________________________________________________________
_______________________________________________________________________________
_______________________________________________________________________________
_______________________________________________________________________________
_______________________________________________________________________________
_______________________________________________________________________________

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 14


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

Understanding DBMS Architecture

A Database Management system is not always directly available for users and applications to access and store
data in it. A Database Management system can be centralized (all the data stored at one location),
decentralized (multiple copies of database at different locations) or hierarchical, depending upon its
architecture.

1-tier DBMS architecture also exist; this is when the database is directly available to the user for using it to
store data. Generally, such a setup is used for local application development, where programmers
communicate directly with the database for quick response.

Database Architecture is logically of two types:

 2-tier DBMS architecture


 3-tier DBMS architecture

2-tier DBMS Architecture

2-tier DBMS architecture includes an Application layer between the user and the DBMS, which is responsible
to communicate the user's request to the database management system and then send the response from the
DBMS to the user.

An application interface known as ODBC (Open Database Connectivity) provides an API that allow client side
program to call the DBMS. Most DBMS vendors provide ODBC drivers for their DBMS.

Such an architecture provides the DBMS extra security as it is not exposed to the End User directly. Also,
security can be improved by adding security and authentication checks in the Application layer too.

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 15


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

3-tier DBMS Architecture

3-tier DBMS architecture is the most commonly used architecture for web applications.

It is an extension of the 2-tier architecture. In the 2-tier architecture, we have an application layer which can be
accessed programmatically to perform various operations on the DBMS. The application generally understands
the Database Access Statements and processes end users requests to the DBMS.

In 3-tier architecture, an additional Presentation or GUI Layer is added, which provides a graphical user
interface for the End user to interact with the DBMS.

For the end user, the GUI layer is the Database System, and the end user has no idea about the application layer
and the DBMS system.

If you have used MySQL, then you must have seen PHPMyAdmin, it is the best example of a 3-tier DBMS
architecture.

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 16


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

Laboratory Exercise 1.3


DATABASE ARCHITECTURE
Name Score

Course & Year Date

In this lab, you will be able to:


1. Explain the types of database management system architecture

Direction: Provide your answers for the given questions.

1. What is the type of database management system architecture used for banks? Discuss.

2. What is the role of GUI/Presentation layer in the 3-tier database management architecture? Discuss.

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 17


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

DBMS Database Models


A Database model defines the logical design and structure of a database and defines how data will be stored,
accessed and updated in a database management system. While the Relational Model is the most widely used
database model, there are other models too:

 Hierarchical Model
 Network Model
 Entity-relationship Model
 Relational Model
Hierarchical Model
This database model organizes data into a tree-like-structure, with a single root, to which all the other data is
linked. The hierarchy starts from the Root data, and expands like a tree, adding child nodes to the parent
nodes.
In this model, a child node will only have a single parent node.
This model efficiently describes many real-world relationships like index of a book, recipes etc.
In hierarchical model, data is organized into tree-like structure with one one-to-many relationship between
two different types of data, for example, one department can have many courses, many professors and off-
course many students.

Network Model
This is an extension of the Hierarchical model. In this model data is organized more like a graph, and are
allowed to have more than one parent node.
In this database model data is more related as more relationships are established in this database model. Also,
as the data is more related, hence accessing the data is also easier and fast. This database model was used to
map many-to-many data relationships.
This was the most widely used database model, before Relational Model was introduced.

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 18


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

Entity-relationship Model
In this database model, relationships are created by dividing object of interest into entity and its characteristics
into attributes.
Different entities are related using relationships.
E-R Models are defined to represent the relationships into pictorial form to make it easier for different
stakeholders to understand.
This model is good to design a database, which can then be turned into tables in relational model (explained
below).
Let's take an example, if we have to design a School Database, then Student will be an entity with attributes
name, age, address etc. As Address is generally complex, it can be another entity with attributes street name,
pincode, city etc., and there will be a relationship between them.
Relationships can also be of different types.

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 19


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

Relational Model
In this model, data is organized in two-dimensional tables and the relationship is maintained by storing a
common field.
This model was introduced by E.F Codd in 1970, and since then it has been the most widely used database
model, in fact, we can say the only database model used around the world.
The basic structure of data in the relational model is tables. All the information related to a particular type is
stored in rows of that table.
Hence, tables are also known as relations in relational model.

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 20


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

Laboratory Exercise 1.4


DBMS MODELS
Name Score

Course & Year Date

In this lab, you will be able to:


1. Differentiate relational model with other types of DBMS models
2. Determine the relationship between ER model and relational model

What makes relational model unique from other types of DBMS models? What are the benefits of
using this model? Discuss your answers.
_________________________________________________________________________________
_________________________________________________________________________________
_________________________________________________________________________________
_________________________________________________________________________________
_________________________________________________________________________________
_________________________________________________________________________________
_________________________________________________________________________________
_________________________________________________________________________________
_________________________________________________________________________________
What is the relation of ER model with relational model? Discuss your answers.
_________________________________________________________________________________
_________________________________________________________________________________
_________________________________________________________________________________
_________________________________________________________________________________
_________________________________________________________________________________
_________________________________________________________________________________
_________________________________________________________________________________
_________________________________________________________________________________
_________________________________________________________________________________

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 21


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

Database Development Process

Database application development is the process of obtaining real-world requirements, analyzing


requirements, designing the data and functions of the system, and then implementing the operations in the
system.

Phase 1: Requirements Gathering

During this step, the database designers have to interview the customers (database users) to understand the
proposed system and obtain and document the data and functional requirements. Interviews can be an excellent
way of gathering information. They are especially good for asking “open ended questions.” Open ended
questions are questions that don’t have a definite answer. You can ask things like “What is the best thing about
the current system?”
Questionnaires are best for “close ended” questions. Closed ended questions: Multiple choice, true and false,
ranked value questions—questions with a definite answer. Questionnaires have some advantages over
interviews. They can be quicker and easier to arrange than interviews. Example of question:
Which is the most important factor when you are looking for a tutoring session to sign up for? a. The particular
tutor b. The time slot c. Neither of the above
The result of this step is a document that includes the detailed requirements provided by the users. The
requirements should not describe how the data is to be processed, but rather what the data items are, what
attributes they have, what constraints apply and the relationships that hold between the data items.

Phase 2: Analysis

Data analysis begins with the statement of data requirements and then produces a conceptual data model. The
aim of analysis is to obtain a detailed description of the data that will suit user requirements so that both high
and low level properties of data and their use are dealt with. These include properties such as the possible range
of values that can be permitted for attributes (e.g., in the school database example, the student course code,
course title and credit points). As a result, analysis focuses on the questions, “What is required?” not “How is
it achieved?”

Guidelines for Developing an ER Diagram


Note: These are general guidelines that will assist in developing a strong basis for the actual database design
(the logical model).
1. Document all entities discovered during the information-gathering stage.
2. Document all attributes that belong to each entity. Select candidate and primary keys. Ensure that all non-
key attributes for each entity are full functionally dependent on the primary key.
3. Develop an initial ER diagram and review it with appropriate personnel. (Remember that this is an iterative
process.)
4. Create new entities (tables) for multivalued attributes and repeating groups. Incorporate these new entities
(tables) in the ER diagram. Review with appropriate personnel.
5. Verify ER modeling by normalizing tables.
At the end of our design stage, the logical schema will be specified by SQL data definition Statements (DDL)
statements, which describe the database that needs to be implemented to meet the user requirements.

Phase 3: Implementation

Implementation involves the construction of a database according to the specification of a logical schema. This
will include the specification of an appropriate storage schema, security enforcement, external schema and so
on. Implementation is heavily influenced by the choice of available DBMSs, database tools and operating
environment.

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 22


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

Laboratory Exercise 1.5


REQUIREMENTS GATHERING
Name Score

Course & Year Date

In this lab, you will be able to:


1. Write documents to review
2. Write interview questions (open-ended)
3. Write short questionnaire (close-ended questions)

You are going to create a database to track clubs and activities on campus. Make a list of some of the types
of documents you would like to look at.

You are going to interview several students who belong to various clubs mentioned above, and their faculty
advisors. You will have one hour to conduct the interview. Think about what questions you might ask.
QUESTIONS FOR STUDENTS QUESTIONS FOR ADVISERS

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 23


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

Create a questionnaire with at least 5 questions to follow up on the interview in question 3. It will be
distributed to about 20 classrooms on campus.

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 24


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

CHAPTER 2:
ENTITY-RELATIONSHIP (ER) MODEL

Basic Concepts of ER Model in DBMS

Entity-relationship model is a model used for design and representation of relationships between data.

The main data objects are termed as Entities, with their details defined as attributes, some of these attributes are
important and are used to identify the entity, and different entities are related using relationships.

In short, to understand about the ER Model, we must understand about:

 Entity and Entity Set


 What are Attributes? And Types of Attributes.
 Keys
 Relationships

Let's take an example to explain everything. For a School Management Software, we will have to store Student
information, Teacher information, Classes, Subjects taught in each class etc.

ER Model: Entity and Entity Set

Considering the above example, Student is an entity, Teacher is an entity, similarly, Class, Subject etc. are also
entities.

An Entity is generally a real-world object which has characteristics and holds relationships in a DBMS.

Examples of entities:

Person: Employee, Student, Patient


Place: Store, Building
Object: Machine, product, and Car
Event: Sale, Registration, Renewal
Concept: Account, Course

If a Student is an Entity, then the complete dataset of all the students will be the Entity Set.

ER Model: Attributes

If a Student is an Entity, then student's roll no., student's name, student's age, student's gender etc. will be its
attributes.

An attribute can be of many types, here are different types of attributes defined in ER database model:

 Simple attribute: The attributes with values that are atomic and cannot be broken down further are
simple attributes. For example, student's age.

 Composite attribute: A composite attribute is made up of more than one simple attribute. For example,
student's address will contain, house no., street name, pincode etc.

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 25


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

 Derived attribute: These are the attributes which are not present in the whole database management
system, but are derived using other attributes. For example, average age of students in a class.

 Single-valued attribute: As the name suggests, they have a single value.

 Multi-valued attribute: And, they can have multiple values.

ER Model: Keys

If the attribute roll no. can uniquely identify a student entity, amongst all the students, then the attribute roll no.
will be said to be a key.

Following are the types of Keys:

ER Model: Relationships

When an Entity is related to another Entity, they are said to have a relationship. For example, A Class Entity is
related to Student entity, because students study in classes, hence this is a relationship.

Depending upon the number of entities involved, a degree is assigned to relationships.

For example, if 2 entities are involved, it is said to be Binary relationship, if 3 entities are involved, it is said to
be Ternary relationship, and so on.

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 26


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

Laboratory Exercise 2.1


ENTITIES AND ATTRIBUTES
Name Score

Course & Year Date

In this lab, you will be able to:


1. Identify entities and attributes

1. Draw out the entities and attributes from the given scenario.
Example: Entity: Student
Attributes: IDNo, Name, Date of Birth, Address, Age

A manufacturing company produces products. The following product information is stored: product name,
product ID and quantity on hand. These products are made up of many components. Each component can be
supplied by one or more suppliers. The following component information is kept: component ID, name,
description, suppliers who supply them, and products in which they are used. The supplier ID and name is also
recorded under supplier.
ENTITIES ATTRIBUTES

2. Give at least two examples of attributes based on your student copy of subjects, schedule and fees.

TYPES OF ATTRIBUTES EXAMPLES OF ATTRIBUTE


Simple Attribute
Composite Attribute
Derived Attribute
Single-valued Attribute

Multi-valued Attribute

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 27


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

Working with ER Diagrams


ER Diagram is a visual representation of data that describes how data is related to each other. In ER Model, we
disintegrate data into entities, attributes and setup relationships between entities, all this can be represented
visually using the ER diagram.
For example, in the below diagram, anyone can see and understand what the diagram wants to convey:
Developer develops a website, whereas a Visitor visits a website.

Components of ER Diagram
Entity, Attributes, Relationships etc. form the components of ER Diagram and there are defined symbols and
shapes to represent each one of them.
Let's see how we can represent these in our ER Diagram.
Entity
Simple rectangular box represents an Entity.

Relationships between Entities - Weak and Strong


Rhombus is used to setup relationships between two or more entities.

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 28


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

Attributes for any Entity


Ellipse is used to represent attributes of any entity. It is connected to the entity.

Weak Entity
Weak entity is an entity that depends on another entity. Weak entity doesn't have any key attribute of its own.
Double rectangle is used to represent a weak entity.

Key Attribute for any Entity


Key attribute represents the main characteristic of an Entity. It is used to represent a Primary key. Ellipse with
the text underlined, represents Key Attribute.
To represent a Key attribute, the attribute name inside the Ellipse is underlined.

Derived Attribute for any Entity


Derived attributes are those which are derived based on other attributes, for example, age can be derived from
date of birth.
To represent a derived attribute, another dotted ellipse is created inside the main ellipse.

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 29


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

Multivalued Attribute for any Entity


Double Ellipse, one inside another, represents the attribute which can have multiple values.

Composite Attribute for any Entity


A composite attribute is the attribute, which also has attributes.

Relationship
A Relationship describes relation between entities. Relationship is represented using diamonds or rhombus in
Chen notation.
There are three types of relationship that exist between Entities.

 Binary Relationship
 Recursive/Unary Relationship
 Ternary Relationship
Binary Relationship
Binary Relationship means relation between two Entities.

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 30


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

Cardinality
The degree of relationship (cardinality) is represented by characters “1”, “N” or “M” usually placed at the
ends of the relationships:
One to One Relationship (1:1)
This type of relationship is rarely seen in real world.

The example describes that one student can enroll only for one course and a course will also have only one
Student. This is not what you will usually see in real-world relationships.
One to Many Relationship (1: N)
The below example showcases this relationship, which means that 1 student can opt for many courses, but a
course can only have 1 student. Sounds weird! This is how it is.

Many to One Relationship (N:1)


It reflects business rule that many entities can be associated with just one entity. For example, Student enrolls
for only one Course but a Course can have many Students.

Many to Many Relationship (M: N)


One student may belong to more than one student organizations, and one organization can admit more than
one student.

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 31


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

Recursive Relationship
When an Entity is related with itself it is known as Recursive Relationship.

Ternary Relationship
Relationship of degree three is called Ternary relationship.
A Ternary relationship involves three entities. In such relationships we always consider two entities together
and then look upon the third.

For example, in the diagram above, we have three related entities, Company, Product and Sector. To understand
the relationship better or to define rules around the model, we should relate two entities and then derive the
third one.
A Company produces many Products/ each product is produced by exactly one company.
A Company operates in only one Sector / each sector has many companies operating in it.
Considering the above two rules or relationships, we see that although the complete relationship involves three
entities, but we are looking at two entities at a time.

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 32


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

Laboratory Exercise 2.2


WEAK ENTITY
Name Score

Course & Year Date

In this lab, you will be able to:


1. Identify entity
2. Determine weak entity among entities

Direction: Determine the weak entity with the following statements.

Example: A supplier can exist without providing components.


Entities: Supplier, Components
Weak Entity: Components

DESCRIPTIONS ENTITIES WEAK ENTITY

A salesperson may sell many cars,


but each car is sold by only one
salesperson.

A customer may buy many cars, but


each car is bought by only one
customer.

A customer may come in just to have


his or her car serviced; that is, a
customer need not buy a car to be
classified as a customer.

A salesperson writes a single invoice


for each car he or she sells.

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 33


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

ERD Notations
Creation of an ERD requires the choice of specific set of notations, which the best suits for your database design.
Two notations - Chen’s and Crow's Foot are applied for ERDs design. Chen's notation was developed first and
has linguistic approach, the boxes represent the entities and are considered as nouns, relationships between them
are shown as diamonds in a verb form. Over time Chen’s style was adapted into the popular standard - Crow’s
Foot notation, where entities are shown as boxes and relationships - as labeled lines.
Chen’s Notation
The first standard notation for ERD was proposed by Chen. Chen's notation is very rich on the data modeling
tools and standard notation symbols and elements for drawing easy understandable Entity-relationship
diagrams, Attribute diagrams, Decomposition charts, which are especially popular for designing relational
databases. The entity is the main term; it is a set of instances abstract or real objects with common characteristics
or attributes. Any system's object is represented by one uniquely identified entity, relationships describe the
links between the entities.

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 34


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

Example of using Chen’s Notation

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 35


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

Crow’s Foot Notation


Crow's Foot notation proposed by Gordon Everest represents the entity by rectangle containing its name (name
must be unique within this model), and relation - by the line which links two entities involved in relationship.
The relationship's plurality is graphically indicated by a "plug" on the end of the link, the optionality - by a
circle.
The Crow's Foot ERD notation is often used in software engineering and database design. The originator of
Crow’s Foot notation offered the idea of how to visually represent the different types of relationships that can
exist between objects in an entity relationship diagram (ERD). The Crow’s Foot notation is often used in ER
models to how a particular table data can reference data in other tables within a database.

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 36


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

Example of using Crow’s Foot Notation

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 37


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

Steps to Create an ERD (Using Crow’s Foot Notation)

Let's study them with an example:


In a university, a Student enrolls in Courses. A student must be assigned to at least one or more Courses. Each
course is taught by a single Professor. To maintain instruction quality, a Professor can deliver only one course.
Step 1: Entity Identification
We have three entities:

 Student
 Course
 Professor
Step 2: Relationship Identification
We have the following two relationships:

 The student is assigned a course


 Professor delivers a course

Step 3: Cardinality Identification


For them problem statement we know that,

 A student can be assigned multiple courses


 A Professor can deliver only one course

Step 4: Identify Attributes


You need to study the files, forms, reports, data currently maintained by the organization to identify attributes.
You can also conduct interviews with various stakeholders to identify entities. Initially, it's important to identify
the attributes without mapping them to a particular entity.

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 38


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

Once, you have a list of Attributes, you need to map them to the identified entities. Ensure an attribute is to be
paired with exactly one entity. If you think an attribute should belong to more than one entity, use a modifier
to make it unique.
Once the mapping is done, identify the primary Keys. If a unique key is not readily available, create one.

Step 5: Create the ERD


A more modern representation of ERD Diagram:

Best Practices for Developing Effective ER Diagrams


 Eliminate any redundant entities or relationships
 You need to make sure that all your entities and relationships are properly labeled
 There may be various valid approaches to an ER diagram. You need to make sure
that the ER diagram supports all the data you need to store
 You should assure that each entity only appears a single time in the ER diagram
 Name every relationship, entity, and attribute are represented on your diagram
 Never connect relationships to each other
 You should use colors to highlight important portions of the ER diagram

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 39


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

Laboratory Exercise 2.3


ERD NOTATIONS
Name Score

Course & Year Date

In this lab, you will be able to:


1. Differentiate Chen with Crow’s Foot notation
2. Determine cardinality among relationships

Direction: Provide your answers for the following:


1. Which do you prefer to use as ERD notation, Chen or Crow’s foot? Explain your answer.

2. Identify the cardinality ratio of the following problem: (1:1, 1: N, N:1, M: N)

PROBLEM CARDINALITY

Patients are each assigned to a ward (room).


Those staff who are nurses are assigned to zero or more wards.
Each ward has at least one nurse assigned.
Those staff who are doctors are assigned to zero or more patients.
Patients may or may not have a doctor assigned, and they may have
more than one doctor.

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 40


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

Laboratory Exercise 2.4


CREATING ER DIAGRAMS
Name Score

Course & Year Date

In this lab, you will be able to:


1. Determine entities and their relationships
2. Use ERD notations to create diagrams

Direction: Draw ER diagrams for the following. Put the degree of relationship. You can use either Chen or
Crow’s foot notation.
Example: Each component can be supplied by one or more suppliers.

1. When a customer takes one or more cars in for repair or service, one service ticket is written for each
car.

2. A car brought in for service can be worked on by many mechanics, and each mechanic may work on
many cars.

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 41


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

Laboratory Exercise 2.5


CREATING ER DIAGRAMS
Name Score

Course & Year Date

In this lab, you will be able to:


1. Determine entities, attributes and relationships
2. Create ER diagram using ER notations

Direction: Create a complete ER diagram for the following scenario. Use either Chen or Crow’s foot notation.

A company database needs to store information about employees (identified by ssn, with salary and phone
as attributes), departments (identified by dno, with dname and budget as attributes), and children of
employees (with name and age as attributes).
Employees work in departments; a child must be identified uniquely by name when the parent (who is an
employee; assume that only one parent works for the company) is known.

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 42


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

Laboratory Exercise 2.6


CREATING ER DIAGRAMS
Name Score

Course & Year Date

In this lab, you will be able to:


1. Determine entities, attributes and relationships
2. Create ER diagram using ER notations

Direction: Create a complete ER diagram for the following scenario. Use either Chen or Crow’s foot notation.

A manufacturing company has several assembly plants in different cities. Each plant produces one product
which requires certain parts in its assembly. The parts are from appropriate suppliers, located in different
cities. Obtained in bulk amounts, certain parts may be used in more than one product.

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 43


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

Enhanced ER Model

As the complexity of data increased in the late 1980s, it became more and more difficult to use the traditional
ER Model for database modelling. Hence some improvements or enhancements were made to the existing ER
Model to make it able to handle the complex applications better.

Supertype and Subtypes

Sometimes it makes sense to subdivide an entity into subtypes. This


may be the case when a group of instances has special properties,
such as attributes or relationships that exist only for that group. In
this case, the entity is called a “supertype” and each group is called
a “subtype”.

A subtype:
– Inherits all attributes of the supertype
– Inherits all relationships of the supertype
– Usually has its own attributes or relationships
– Is drawn within the supertype
– Never exists alone
– May have subtypes of its own

When an ER model is complete, subtypes never


stand alone.

In other words, if an entity has a subtype, a


second subtype
must also exist. This makes sense.

A single subtype is exactly the same as the


supertype.

This idea leads to the two subtype rules:

–Exhaustive: Every instance of the supertype is


also an instance of one of the subtypes. All
subtypes are listed without omission.
–Mutually Exclusive: Each instance of a
supertype is an instance of only one possible
subtype.

When modeling supertypes and subtypes, you


can use three questions to see if the subtype is
correctly identified:
– Is this subtype a kind of supertype?
– Have I covered all possible cases?
(exhaustive)
– Does each instance fit into one and only one subtype? (mutually exclusive)

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 44


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

Specialization and Generalization

After learning supertypes and subtypes, you can now create more enhanced ER model using specialization
and generalization.

Generalization is a bottom-up approach in which two lower level entities combine to form a higher level
entity. In generalization, the higher level entity can also combine with other lower level entities to make
further higher level entity.

For example, Saving and Current account types entities can be generalized and an entity with name Account
can be created, which covers both.

Specialization is opposite to Generalization. It is a top-down approach in which one higher level entity can be
broken down into two lower level entity. In specialization, a higher level entity may not have any lower-level
entity sets, it's possible.

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 45


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

More examples on Enhanced-ER Diagram

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 46


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

Laboratory Exercise 2.7


ENHANCED ER MODEL
Name Score

Course & Year Date

In this lab, you will be able to:


1. Define and give an examples of subtypes of a supertype
2. Apply generalization or specialization into ER diagram

1. Give example of subtypes for the following supertypes:

SUPERTYPE SUBTYPES
1. STUDENT
2. EMPLOYEE
3. BUILDING
4. EVENT
5. DOCUMENT

2. Given the following subtypes of ACCOUNT, draw the diagram and rearrange the attributes to show
the shared attributes and unique attributes of each subtype. Use generalization or specialization.
• CHECKING: Acct No, Date Opened, Balance, Service Charge
• SAVINGS: Acct No, Date Opened, Balance, Interest Rate
• LOAN: Acct No, Date Opened, Balance, Interest Rate, Payment

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 47


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

CHAPTER 3:
RELATIONAL MODEL
Codd's Rule for Relational DBMS
E.F Codd was a Computer Scientist who invented the Relational model for Database management. Based on
relational model, the Relational database was created. Codd proposed 13 rules popularly known as Codd's 12
rules to test DBMS's concept against his relational model. Codd's rule actually define what quality a DBMS
requires in order to become a Relational Database Management System(RDBMS). Till now, there is hardly any
commercial product that follows all the 13 Codd's rules. Even Oracle follows only eight and half (8.5) out of
13. The Codd's 12 rules are as follows:
Rule zero
This rule states that for a system to qualify as an RDBMS, it must be able to manage database entirely through
the relational capabilities.
Rule 1: Information rule
All information (including metadata) is to be represented as stored data in cells of tables. The rows and columns
have to be strictly unordered.
Rule 2: Guaranteed Access
Each unique piece of data (atomic value) should be accessible by: Table Name + Primary Key(Row) +
Attribute(column).
NOTE: Ability to directly access via POINTER is a violation of this rule.
Rule 3: Systematic treatment of NULL
Null has several meanings, it can mean missing data, not applicable or no value. It should be handled
consistently. Also, Primary key must not be null, ever. Expression on NULL must give null.
Rule 4: Active Online Catalog
Database dictionary(catalog) is the structure description of the complete Database and it must be stored online.
The Catalog must be governed by same rules as rest of the database. The same query Statements should be used
on catalog as used to query database.
Rule 5: Powerful and Well-Structured Statements
One well-structured Statements must be there to provide all manners of access to the data stored in the database.
Example: SQL, etc. If the database allows access to the data without the use of this Statements, then that is a
violation.
Rule 6: View Updating Rule
All the view that are theoretically updatable should be updatable by the system as well.
Rule 7: Relational Level Operation
There must be Insert, Delete, Update operations at each level of relations. Set operation like Union, Intersection
and minus should also be supported.

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 48


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

Rule 8: Physical Data Independence


The physical storage of data should not matter to the system. If say, some file supporting table is renamed or
moved from one disk to another, it should not affect the application.
Rule 9: Logical Data Independence
If there is change in the logical structure (table structures) of the database, the user view of data should not
change. Say, if a table is split into two tables, a new view should give result as the join of the two tables. This
rule is most difficult to satisfy.
Rule 10: Integrity Independence
The database should be able to enforce its own integrity rather than using other programs. Key and Check
constraints, trigger etc., should be stored in Data Dictionary. This also make RDBMS independent of front-end.
Rule 11: Distribution Independence
A database should work properly regardless of its distribution across a network. Even if a database is
geographically distributed, with data stored in pieces, the end user should get an impression that it is stored at
the same place. This lays the foundation of distributed database.
Rule 12: No subversion Rule
If low level access is allowed to a system, it should not be able to subvert or bypass integrity rules to change
the data. This can be achieved by some sort of looking or encryption.

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 49


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

Laboratory Exercise 3.1


CODD’S 12 RULES
Name Score

Course & Year Date

In this lab, you will be able to:


1. Determine the application of Codd’s 12 rules into designing database management system

Direction: Conduct a thorough online research to look for researches/articles that used Codd’s 12 rules as basis
for implementing a quality database management system. Provide the following details based on your research:

TITLE OF RESEARCH/ARTICLE
AUTHOR (IF ANY)
DATE PUBLISHED
TITLE OF JOURNAL (IF
PUBLISHED IN A JOURNAL)

SUMMARY OF USING CODD’S


12 RULES AS REFERENCE

URL REFERENCE

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 50


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

Relational Database Management System (RDBMS)


A Relational Database Management System(RDBMS) is a database management system based on the relational
model introduced by E.F Codd.
RDBMS is used to manage Relational database. Relational database is a collection of organized set of tables
related to each other, and from which data can be accessed easily. Relational Database is the most commonly
used database these days.
Some popular Relational Database management systems are:

 DB2 and Informix Dynamic Server - IBM


 Oracle and RDB – Oracle
 SQL Server and Access - Microsoft
Basic Relational DBMS Concepts
Attribute: Each column in a Table. Attributes are the properties which define a relation. e.g., Student_Rollno,
NAME,etc
Tables: In the Relational model the, relations are saved in the table format. It is stored along with its entities.
A table has two properties rows and columns. Rows represent records and columns represent attributes.
Tuple: It is nothing but a single row of a table, which contains a single record.
Relation Schema: A relation schema represents the name of the relation with its attributes.
Degree: The total number of attributes which in the relation is called the degree of the relation.
Cardinality: Total number of rows present in the Table.
Column: The column represents the set of values for a specific attribute.
Relation instance: Relation instance is a finite set of tuples in the RDBMS system. Relation instances never
have duplicate tuples.
Relation key: Every row has one, two or multiple attributes, which is called relation key.
Attribute domain: Every attribute has some pre-defined value and scope which is known as attribute domain

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 51


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

Relational Integrity Constraints


Every relation in a relational database model should abide by or follow a few constraints to be a valid relation,
these constraints are called as Relational Integrity Constraints.
The three main Integrity Constraints are:

 Key Constraints
 Domain Constraints
 Referential integrity Constraints
Key Constraints
We store data in tables, to later access it whenever required. In every table one or more than one attributes
together are used to fetch data from tables. The Key Constraint specifies that there should be such an
attribute(column) in a relation(table), which can be used to fetch data for any tuple(row).
The Key attribute should never be NULL or same for two different row of data.
For example, in the Employee table we can use the attribute ID to fetch data for each of the employee. No value
of ID is null and it is unique for every row, hence it can be our Key attribute.
Domain Constraint
Domain constraints can be violated if an attribute value is not appearing in the corresponding domain or it is
not of the appropriate data type.
Domain constraints specify that within each tuple, and the value of each attribute must be unique. This is
specified as data types which include standard data types integers, real numbers, characters, Booleans, variable
length strings, etc.
Referential Integrity Constraint
Referential integrity constraints are based on the concept of Foreign Keys. A foreign key is an important
attribute of a relation which should be referred to in other relationships. Referential integrity constraint state
happens where relation refers to a key attribute of a different or same relation. However, that key element must
exist in the table.

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 52


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

Laboratory Exercise 3.2


IMPLEMENTATION OF DBMS
Name Score

Course & Year Date

In this lab, you will be able to:


1. Determine the implementation of RDBMS into organizations
2. Identify the impact of RDBMS into organizations

Direction: Use online searching for the following questions:

1. Search for an organization that implements RDBMS into their operation. Fill out the following:
NAME OF
ORGANIZATION/COMPANY

DESCRIPTION OF RDBMS
IMPLEMENTATION

(include system/application
name (if any), database
software used, database model
used (should be RDBMS) and
others)

IMPACT OF
IMPLEMENTATION

(benefits gained,
advantages/disadvantages)

URL REFERENCE

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 53


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

Laboratory Exercise 3.3


RELATIONAL INTEGRITY CONSTRAINTS
Name Score

Course & Year Date

In this lab, you will be able to:


1. Discuss relational integrity constraints

Direction: Provide brief answers for the following:

Use real-life scenario to explain further about Domain Constraints.

What happens if an implemented RDBMS do not apply Referential Integrity Constraints? Discuss.

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 54


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

Operations in Relational Model


Four basic operations performed on relational database model are:

 Insert: used to insert data into the relation


 Delete: used to delete tuples from the table.
 Modify: allows you to change the values of some attributes in existing tuples.
 Select: allows you to choose a specific range of data.
Whenever one of these operations are applied, integrity constraints specified on the relational database schema
must never be violated.

Best Practices for creating a Relational Model


 Data need to be represented as a collection of relations
 Each relation should be depicted clearly in the table
 Rows should contain data about instances of an entity
 Columns must contain data about attributes of the entity
 Cells of the table should hold a single value
 Each column should be given a unique name
 No two rows can be identical
 The values of an attribute should be from the same domain

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 55


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

ER Model to Relational Model


As we all know that ER Model can be represented using ER Diagrams which is a great way of designing and
representing the database design in more of a flow chart form.
It is very convenient to design the database using the ER Model by creating an ER diagram and later on
converting it into relational model to design your tables.
Not all the ER Model constraints and components can be directly transformed into relational model, but an
approximate schema can be derived.
Entity in ER Model is changed into tables, or we can say for every Entity in ER model, a table is created in
Relational Model.
And the attributes of the Entity get converted to columns of the table.
And the primary key specified for the entity in the ER model, will become the primary key for the table in
relational model.
For example, for the below ER Diagram in ER Model,

A table with name Student will be created in relational model, which will have 4 columns, id, name, age,
address and id will be the primary key for this table.
Points to Remember
Similarly, we can generate relational database schema using the ER diagram. Following are some key points
to keep in mind while doing so:

 Entity gets converted into Table, with all the attributes becoming fields(columns) in the table.
 Relationship between entities is also converted into table with primary keys of the related entities also
stored in it as foreign keys.
 Primary Keys should be properly set.
 For any relationship of Weak Entity, if primary key of any other entity is included in a table, foreign
key constraint must be defined.

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 56


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

Introduction to Database Keys


Keys are very important part of Relational database model. They are used to establish and identify relationships
between tables and also to uniquely identify any record or row of data inside a table.
A Key can be a single attribute or a group of attributes, where the combination may act as a key.
Why we need a Key?
In real world applications, number of tables required for storing the data is huge, and the different tables are
related to each other as well.
Also, tables store a lot of data in them. Tables generally extends to thousands of records stored in them, unsorted
and unorganized.
Now to fetch any particular record from such dataset, you will have to apply some conditions, but what if there
is duplicate data present and every time you try to fetch some data by applying certain condition, you get the
wrong data. How many trials before you get the right data?
To avoid all this, Keys are defined to easily identify any row of data in a table.
Let's try to understand about all the keys using a simple example.

Super Key
Super Key is defined as a set of attributes within a table that can uniquely identify each record within a table.
Super Key is a superset of Candidate key.
In the table defined above super key would include student_id, (student_id, name), phone etc.
Confused? The first one is pretty simple as student_id is unique for every row of data; hence it can be used to
identity each row uniquely.
Next comes, (student_id, name), now name of two students can be same, but their student_id can't be same
hence this combination can also be a key.
Similarly, phone number for every student will be unique, hence again, phone can also be a key.
So they all are super keys.

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 57


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

Candidate Key
Candidate keys are defined as the minimal set of fields which can uniquely identify each record in a table. It is
an attribute or a set of attributes that can act as a Primary Key for a table to uniquely identify each record in
that table. There can be more than one candidate key.
In our example, student_id and phone both are candidate keys for table Student.
A candidate key can never be NULL or empty. And its value should be unique.
There can be more than one candidate keys for a table.
A candidate key can be a combination of more than one columns(attributes).
Primary Key
Primary key is a candidate key that is most appropriate to become the main key for any table. It is a key that
can uniquely identify each record in a table.

Composite Key
Key that consists of two or more attributes that uniquely identify any record in a table is called Composite
key. But the attributes which together form the Composite key are not a key independently or individually.

In the above picture we have a Score table which stores the marks scored by a student in a particular subject.
In this table student_id and subject_id together will form the primary key, hence it is a composite key.

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 58


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

Laboratory Exercise 3.4


RDBMS BASIC CONCEPTS
Name Score

Course & Year Date

In this lab, you will be able to:


1. Identify relational model concepts
2. Identify database keys

Direction: Answer the following:

A. What is the other term for the following:


1. Table
2. Column

3. Row
B. What are described by the following:
1. superset of Candidate key.
2. minimal set of fields which can uniquely identify each record in a table
3. is a candidate key that is most appropriate to become the main key for any table.
4. set of attributes within a table that can uniquely identify each record within a table

C. Why do we need to establish a key in a relational model?

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 59


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

CHAPTER 4:
DATABASE NORMALIZATION

Database Normalization is a technique of organizing the data in the database. Normalization is a systematic
approach of decomposing tables to eliminate data redundancy(repetition) and undesirable characteristics like
Insertion, Update and Deletion Anomalies. It is a multi-step process that puts data into tabular form, removing
duplicated data from the relation tables.
Normalization is used for mainly two purposes,

 Eliminating redundant(useless) data.


 Ensuring data dependencies make sense i.e. data is logically stored.
Problems Without Normalization
If a table is not properly normalized and have data redundancy then it will not only eat up extra memory space
but will also make it difficult to handle and update the database, without facing data loss. Insertion, Updation
and Deletion Anomalies are very frequent if database is not normalized. To understand these anomalies let us
take an example of a Student table.

In the table above, we have data of 4 Computer Sci. students. As we can see, data for the fields branch,
hod(Head of Department) and office_tel is repeated for the students who are in the same branch in the college,
this is Data Redundancy.
Insertion Anomaly
Suppose for a new admission, until and unless a student opts for a branch, data of the student cannot be inserted,
or else we will have to set the branch information as NULL.
Also, if we have to insert data of 100 students of same branch, then the branch information will be repeated for
all those 100 students.
These scenarios are nothing but Insertion anomalies.
Updation Anomaly
What if Mr. X leaves the college? or is no longer the HOD of computer science department? In that case all the
student records will have to be updated, and if by mistake we miss any record, it will lead to data inconsistency.
This is Updation anomaly.

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 60


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

Deletion Anomaly
In our Student table, two different information are kept together, Student information and Branch information.
Hence, at the end of the academic year, if student records are deleted, we will also lose the branch information.
This is Deletion anomaly.

Normalization Rule
Normalization rules are divided into the following normal forms:

 First Normal Form


 Second Normal Form
 Third Normal Form
 BCNF (Boyce Codd Normal Form)
 Fourth Normal Form

First Normal Form (1NF)


For a table to be in the First Normal Form, it should follow the following 4 rules:
Rule 1: Single Valued Attributes
Each column of your table should be
single valued which means they
should not contain multiple values.
Problem
We will explain this with help of an
example later, let's see the other rules
for now.
Rule 2: Attribute Domain should not change
This is more of a "Common Sense" rule. In each column the values stored must be of the same kind or type.
For example: If you have a column dob to save date of births of a set of people, then you cannot or you must
not save 'names' of some of them in that column along with 'date of birth' of others in that column. It should
hold only 'date of birth' for all the records/rows.
Rule 3: Unique name for Attributes/Columns
This rule expects that each column in a
table should have a unique name. This is to
avoid confusion at the time of retrieving
data or performing any other operation on
the stored data.
If one or more columns have same name, Solution
then the DBMS system will be left
confused.
Rule 4: Order doesn't matters
This rule says that the order in which you
store the data in your table doesn't matter.

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 61


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

Second Normal Form (2NF)


For a table to be in the Second Normal Form, it must satisfy two conditions:

 The table should be in the First Normal Form.


 There should be NO Partial Dependency.
Partial Dependency means an attribute is dependent to another attribute and not dependent to the primary key.
If this exists in a table, then it should be removed.
Example: teacher attribute is dependent only to subject_id

Score table

Solution: Remove partial dependency by removing the attribute and place in another table.

Subject table

Score table will be:

Score table

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 62


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

Third Normal Form (3NF)


For a table to be in the third normal form,

 It should be in the Second Normal form.


 And it should not have Transitive Dependency.
Transitive Dependency means a non-prime attribute depends on other non-prime attributes rather than
depending upon the prime attributes or primary key.
Example: exam_name is dependent to the primary keys (student_id + subject_id) but total_marks is dependent
to exam_name

How to remove Transitive Dependency?


Take out the columns exam_name and total_marks from Score table and put them in an Exam table and use the
exam_id wherever required.

The advantage of removing transitive dependency are,

 Amount of data duplication is reduced.


 Data integrity achieved.

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 63


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

Boyce-Codd Normal Form (BCNF)


Boyce-Codd Normal Form or BCNF is an extension to the third normal form, and is also known as 3.5
Normal Form.

For a table to satisfy the Boyce-Codd Normal Form, it should satisfy the following two conditions:
 It should be in the Third Normal Form.
 And, for any dependency A → B, A should be a super key.
Example: A college enrollment table

In the table above:


 One student can enroll for multiple subjects. For example, student with student_id 101, has
opted for subjects - Java & C++
 For each subject, a professor is assigned to the student.
 And, there can be multiple professors teaching one subject like we have for Java.
What do you think should be the Primary Key?
Well, in the table above student_id, subject together form the primary key, because using student_id
and subject, we can find all the columns of the table.
One more important point to note here is, one professor teaches only one subject, but one subject
may have two different professors.
Hence, there is a dependency between subject and professor here, where subject depends on the
professor name.
This table satisfies the 1st Normal form because all the values are atomic, column names are unique
and all the values stored in a particular column are of same domain.
This table also satisfies the 2nd Normal Form as there is no Partial Dependency.
And, there is no Transitive Dependency, hence the table also satisfies the 3rd Normal Form.
But this table is not in Boyce-Codd Normal Form.

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 64


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

Why this table is not in BCNF?


In the table above, student_id, subject form primary key, which means subject column is a prime
attribute.
But, there is one more dependency, professor → subject.
And while subject is a prime attribute, professor is a non-prime attribute, which is not allowed by
BCNF.
How to satisfy BCNF?
To make this relation(table) satisfy BCNF, we will decompose this table into two tables, student
table and professor table.
Below we have the structure for both the tables.

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 65


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

Laboratory Exercise 4.1


INTRODUCTION TO NORMALIZATION
Name Score

Course & Year Date

In this lab, you will be able to:


1. Discuss the importance of database normalization
2. Discuss the different data anomalies

Direction: Answer the following questions:

1. Why do we need to normalize our database? Discuss some key points.

2. Choose a type of data anomaly and give a real-life experience or scenario example.

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 66


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

Laboratory Exercise 4.2


NORMALIZATION FORMS
Name Score

Course & Year Date

In this lab, you will be able to:


1. Evaluate normalization form of tables

Direction: Evaluate the following tables if what rule of normalization form they satisfy.

NORMALIZATION FORM
TABLE
(1NF, 2NF, 3NF)

BRANCH (Branch#, Branch_Addr, (ISBN, Title, Author,


Publisher, Num_copies))

PATIENT (Patient#, Name, DOB, Address, (Prescription#, Drug,


Date, Dosage, Doctor, Secretary))

Big Patient (VisitNo., VisitDate, PatNo, PatAge, PatCity,


ProvNo, ProvSpecialty, Diagnosis)
Member Dinner Food (MEMBER NUM, MEMBER NAME,
MEMBER ADDRESS, DINNER NUM, DINNER DATE,
VENUE CODE, VENUE DESCRIPTION, FOOD CODE, FOOD
DESCRIPTION)

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 67


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

Laboratory Exercise 4.3


DATABASE NORMALIZATION (3NF)
Name Score

Course & Year Date

In this lab, you will be able to:


1. Transform tables to Third Normal Form (3NF)

Direction: Analyze the given set of tables then transform them into 3NF.

1. CLIENT (Client#, Name, Location, Manager#, Manager_name, Manager_location, (Contract#,


Estimated_cost, Completion_date, (Staff#, Staff_name, Staff_location)))

2. DOCTOR (Doctor#, DoctorName, Secretary, (Patient#, PatientName, PatientDOB, PatientAddress,


(Prescription#, Drug, Date, Dosage))

3. PatientVisit (VisitNo., VisitDate, PatNo, PatAge, PatCity)


Provider (ProvNo, ProvSpecialty)
VisitProvDiagnosis(VisitNo., ProvNo, Diagnosis)

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 68


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

Introduction to Structured Query Statements (SQL)


Structure Query Statements(SQL) is a database query Statements used for storing and managing data in
Relational DBMS. SQL was the first commercial Statements introduced for E.F Codd's Relational model of
database. Today almost all RDBMS (MySql, Oracle, Infomix, Sybase, MS Access) use SQL as the standard
database query Statements. SQL is used to perform all types of data operations in RDBMS.

SQL follows the following rules:

 Structure query Statements is not case sensitive. Generally, keywords of SQL are written in uppercase.
 Statements of SQL are dependent on text lines. We can use a single SQL statement on one or multiple
text line.
 Using the SQL statements, you can perform most of the actions in a database.
 SQL depends on tuple relational calculus and relational algebra.

SQL DATA TYPES

Characteristics of SQL
 SQL is easy to learn.
 SQL is used to access data from relational database management systems.
 SQL can execute queries against the database.
 SQL is used to describe the data.
 SQL is used to define the data in the database and manipulate it when needed.
 SQL is used to create and drop the database and table.
 SQL is used to create a view, stored procedure, function in a database.
 SQL allows users to set permissions on tables, procedures, and views.

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 69


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

DDL: Data Definition Statements

This includes changes to the structure of the table like creation of table, altering table, deleting a table etc.

All DDL commands are auto-committed. That means it saves all the changes permanently in the database.

CREATE
To create a database To create a table
command
CREATE TABLE <TABLE_NAME>
(
column_name1 datatype1,
column_name2 datatype2,
SYNTAX: CREATE DATABASE <database_name>; column_name3 datatype3,
column_name4 datatype4
);

CREATE TABLE <student>


(
studID int,
lastName char,
EXAMPLE: CREATE DATABASE studentDB;
firstName char,
middleName char,
dateOfBirth date
);
CREATE TABLE <student>
(
studID int,
lastName char,
NOTE: When declaring Primary key to table  firstName char,
middleName char,
dateOfBirth date,
Primary Key(studID)
);
alter command is used for altering the table structure, such as,
 to add a column to existing table
ALTER  to rename any existing column
command  to change datatype of any column or to modify its size.
 to drop a column from the table.

ALTER TABLE table_name ADD( ALTER TABLE table_name modify(


SYNTAX: column_name datatype column_name datatype
); );
ALTER TABLE table_name RENAME
ALTER TABLE table_name DROP(
old_column_name TO
column_name);
new_column_name;
ALTER TABLE student ADD( ALTER TABLE student MODIFY(
EXAMPLE: address VARCHAR(200) address varchar(300)
); );

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 70


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

ALTER TABLE student RENAME ALTER TABLE student DROP(


address TO location; address);
RENAME is used in ORACLE. For MYSQL, use CHANGE.
SYNTAX: ALTER TABLE Customer CHANGE Address Addr char(50);
TRUNCATE removes all the records from a table
command
SYNTAX: TRUNCATE TABLE table_name;
EXAMPLE: TRUNCATE TABLE student;
DROP completely removes a table from the database or delete a database
command
SYNTAX: DROP TABLE table_name; DROP DATABASE database_name;
EXAMPLE: DROP TABLE student; DROP DATABASE studentDB;
RENAME RENAME TABLE old_table_name to new_table_name;
command
EXAMPLE: RENAME TABLE student to students_info;
EXAMPLE PROBLEM

Database name: employeeDB

TABLE NAME COLUMN NAMES DATA TYPES


empID (Primary Key) int
empName char
tblEmployee
empBday date
empAddress varchar
ADD column dateHired
Rename column empBday to empDOB
Rename tblEmployee to EmpInfo

DDL Procedure using MySQL (Command line Editor)


mysql> create database employeeDB;
Query OK, 1 row affected (0.01 sec)
mysql> use employeeDB;
Database changed
mysql> create table tblEmployee (
-> empID int,
-> empName char,
-> empBday date,
-> empAddress varchar,
-> primary key(empID));
Query OK, 0 rows affected (0.05 sec)
mysql> alter table tblEmployee add (
-> dateHired date);
Query OK, 0 rows affected (0.04 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> alter table tblEmployee CHANGE empBday empDOB date;
Query OK, 0 rows affected (0.02 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> RENAME table tblEmployee TO EmpInfo;
Query OK, 0 rows affected (0.01 sec)

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 71


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

DML: Data Manipulation Statements

DML commands are used for manipulating the data stored in the table and not the table itself.

DML commands are not auto-committed. It means changes are not permanent to database, they can be rolled
back.

Consider this student table:

COMMANDS SYNTAX
INSERT INTO table_name VALUES(data1, data2, ...)
INSERT Example:
INSERT INTO student VALUES(101, 'Adam', 15);

Insert into specific column: INSERT INTO student(id, name) values(102, 'Alex');

UPDATE table_name SET column_name = new_value WHERE


some_condition;
UPDATE
Example:
UPDATE student SET age=18 WHERE student_id=102;

Updating multiple columns: UPDATE student SET name='Abhi', age=17 where


s_id=103;
DELETE DELETE FROM table_name;
Note: This delete all data in a table.
Delete specific record: DELETE FROM student WHERE s_id=102;

TRUNCATE command is different from DELETE command. The delete command will delete all the rows from
a table whereas truncate command not only deletes all the records stored in the table.

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 72


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

Laboratory Exercise 5.1


DDL STATEMENTS
Name Score

Course & Year Date

In this lab, you will be able to:


1. Evaluate SQL codes
2. Provide expected output of given SQL codes

Software/Tools Needed:
1. MySQL server
2. Workbench or SQLyog

Direction: Evaluate the given source code below. If the result is an ERROR, provide the correct code. If the
code is correct, write Query OK.

SQL CODES RESULT

CREATE DATABASE myDatabase;

CREATE TABLE subject (


Code int,
Description char,
Units int,
Hours int,
Primary Key(Code));

ALTER TABLE subject ADD (


CourseNo varchar );

ALTER subject TABLE CHANGE CourseNO


CNO;

RENAME TABLE subject to tblSubject;

DROP TABLE subject;

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 73


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

Laboratory Exercise 5.2


DDL STATEMENTS
Name Score

Course & Year Date

In this lab, you will be able to:


1. Create SQL codes using DDL statements

Software/Tools Needed:
1. MySQL server
2. Workbench or SQLyog

Direction: Provide the SQL codes for the following problems.

PROBLEM SQL CODES

Create database named ‘booksDB’

Create table named ‘tblBooks’ with the


following columns:
booksID- set as integer
title- set as character
author- set as character
publisher- set as character
Set booksID as primary key

Add column ‘price’ as decimal to


tblBooks table

Rename tblBooks to Books

Change column ‘author’ to ‘bookAuthor’

Delete the table Books

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 74


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

Laboratory Exercise 5.3


DML STATEMENTS
Name Score

Course & Year Date

In this lab, you will be able to:


1. Write SQL codes using DML statements

Software/Tools Needed:
1. MySQL server
2. SQLyog or Workbench

Direction: Provide the SQL code based on the ‘tblEmployee’ table.

1. Insert the following data:

2. Change the city of Denzel to Chicago.

3. Change the salary of employee 2 to 250000.

4. Delete the employee named Russell.

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 75


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

DQL: Data Query Statements


Data query Statements is used to fetch data from tables based on conditions that we can easily apply.

SELECT SQL Query


SELECT query is used to retrieve data from a table. It is the most used SQL query. We can retrieve complete
table data, or partial by specifying conditions using the WHERE clause.

Consider the following student table,

DESCRIPTIONS SYNTAX
Selecting all records Select * from student;
Selecting some columns
Select s_id, name, age from student;
e.g. s_id, name and age only
Selecting record with condition Select * from student
e.g. student name is Adam Where name=’Adam’;

Using the WHERE SQL clause


WHERE clause is used to
specify/apply any condition
while retrieving, updating or
deleting data from a table.
This clause is used mostly
with SELECT, UPDATE and DELETE
query.
When we specify a condition
using the WHERE clause then
the query executes only for
those records for which the
condition specified by the
WHERE clause is TRUE.

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 76


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

Applying SELECT and WHERE clause with OPERATORS

General syntax: SELECT [column/s to be displayed]


FROM [table name]
WHERE [conditions]

SAMPLE PROBLEMS SYNTAX


Display the records of students whose age is below SELECT * FROM student
18 WHERE age < 18;
Display the records of students whose address is not SELECT * FROM student
in Delhi WHERE address =! ‘Delhi’;
Display the records of students whose age is form SELECT * FROM student
18 to 22 WHERE age BETWEEN 18 AND 22;
Display the records of students whose name starts SELECT * FROM student
with ‘A’ WHERE name LIKE ‘A%’;
Display the records of students whose name ends SELECT * FROM student
with ‘X’ WHERE name LIKE ‘%X’;
Display the records of students whose name is with SELECT * FROM student
‘B’ WHERE name LIKE ‘%B%’;

NOTE: If the condition involves comparison to character/s, put single quote. If it is numeric, no need to put
single quote.

SELECT WITH LOGICAL OPERATORS

 AND: both conditions must be TRUE


 OR: one condition must be TRUE

SAMPLE PROBLEMS SYNTAX


Display the records of students whose age is below SELECT * FROM student
18 and address is in Banglore WHERE age < 18 AND address=’Banglore’;
SELECT * FROM student
WHERE address = ‘Delhi’ OR
Display the records of students whose address is in
address=’Chennai’;
Delhi or Chennai
SELECT * FROM student
WHERE address IN (‘Delhi’, ‘Chennai’)

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 77


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

SELECT WITH ORDER BY (ASC, DESC)

PROBLEM SQL SYNTAX


Display records arranged in ascending order by SELECT * FROM student ORDER BY name
name ASC;
SELECT * FROM student ORDER BY age
Display records in descending order by age
DESC;

SELECT DISTINCT AND ALIASES


Table: customers

PROBLEM SQL SYNTAX


Selects only the DISTINCT values from the SELECT DISTINCT Country FROM
"Country" column customers;
SQL aliases are used to give a table, or a column
SELECT CustomerName as Names,
in a table, a temporary name.
ContactName as Contact
Example: Display customer names as Names and
FROM customers;
contact names as Contact

SQL AGGREGATE FUNCTIONS

 AVG – calculates the average of a set of values.


 COUNT – counts rows in a specified table or view.
 MIN – gets the minimum value in a set of values.
 MAX – gets the maximum value in a set of values.
 SUM – calculates the sum of values.

General syntax:
SELECT [aggregate function] (column name)
FROM table name;

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 78


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

Table: Products

Note: NULL values are not counted or ignored.


PROBLEM SQL SYNTAX
SELECT COUNT(SupplierID)
Display the total number of suppliers.
FROM Products;
SELECT SUM(Price)
Display the total price.
FROM Products;
SELECT AVG(Price)
Display the average price.
FROM Products;
SELECT MAX(Price)
Display the highest product price.
FROM Products;
SELECT MIN(Price)
Display the lowest product price.
FROM Products;

USING GROUP BY
The GROUP BY clause is used to group rows returned by SELECT statement into a set of summary rows or
groups based on values of columns or expressions. You can apply an aggregate function such as SUM, AVG,
MIN, MAX or COUNT to each group to output the summary information.
GENERAL SYNTAX:
SELECT
column1, column2, aggregate_function(expression)
FROM
table_name
WHERE
condition
GROUP BY column1;

PROBLEM SQL SYNTAX


SELECT SupplierID, SUM(Price)
Display the total price of products delivered by
FROM Products
suppliers.
Group by SupplierID;
SELECT SupplierID, count(CategoryID)
Display the total categories delivered by suppliers. From Products
Group by SupplierID;

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 79


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

SQL HAVING clause

The HAVING clause was added to SQL because the


WHERE keyword could not be used with aggregate
functions.
SYNTAX:
SELECT column_name(s)
FROM table_name
WHERE condition
GROUP BY column_name(s)
HAVING condition
ORDER BY column_name(s);

Example: Display the total numbers of students in


each class. Just include the class with more than 1
student.
Solution:
SELECT COUNT(id),class
FROM STUDENT
GROUP BY class
HAVING COUNT(id) > 1;

SQL JOINS
A JOIN clause is used to combine rows from two or more tables, based on a related column between them.
Different Types of SQL JOINs

 (INNER) JOIN: Returns records that have matching values in both tables
 LEFT (OUTER) JOIN: Returns all records from the left table, and the matched records from the right
table
 RIGHT (OUTER) JOIN: Returns all records from the right table, and the matched records from the
left table
 FULL (OUTER) JOIN: Returns all records when there is a match in either left or right table

SYNTAX: using INNER JOIN


SELECT table1.column1, table1. column2, table2. column1....
FROM table1
INNER JOIN table2
ON table1.matching_column = table2.matching_column;
[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 80
CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

Consider the two tables below:


STUDENT

EXAMPLES
PROBLEM 1: Display the name, roll no. and course id of students.
SELECT Student.NAME, Student.ROLL_NO, StudentCourse.COURSE_ID
FROM Student
SYNTAX
INNER JOIN StudentCourse
ON STUDENT.ROLL_NO= StudentCourse.ROLL_NO;
PROBLEM 2: Display the name of students who take course ID no.2.
SELECT Student.NAME
FROM STUDENT
SYNTAX INNER JOIN StudentCourse
ON STUDENT.ROLL_NO= StudentCourse.ROLL_NO
WHERE StudentCourse.COURSE_ID=2;
PROBLEM 3: Show the names and age of students enrolled in different courses.
SELECT StudentCourse.COURSE_ID, Student.NAME, Student.AGE
FROM Student
SYNTAX
INNER JOIN StudentCourse
ON Student.ROLL_NO = StudentCourse.ROLL_NO;
PROBLEM 4: Show the names and course ID enrolled.
SELECT Student.NAME, StudentCourse.COURSE_ID
FROM Student
SYNTAX
LEFT JOIN StudentCourse
ON StudentCourse.ROLL_NO = Student.ROLL_NO;
Problem 5: Show the name and Course ID of all students.
SELECT Student.NAME,StudentCourse.COURSE_ID
FROM Student
SYNTAX
FULL JOIN StudentCourse
ON StudentCourse.ROLL_NO = Student.ROLL_NO;

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 81


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

Laboratory Exercise 5.4


DQL STATEMENTS
Name Score

Course & Year Date

In this lab, you will be able to:


1. Write SQL codes using SELECT statements

Software/Tools Needed:
1. MySQL server
2. SQLyog or Workbench

Direction: Provide the SQL codes for the following problem.

Table name:
Employee

PROBLEM SQL SYNTAX

Display all records of male employees.

Display the names of female employees.

Display the name and id of employees whose salary


is more than 90000.00.

Display the names of employees who lives in


Florida (FL).

Display the id of employee whose name ended with


‘e’.

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 82


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

Laboratory Exercise 5.5


DQL STATEMENTS
Name Score

Course & Year Date

In this lab, you will be able to:


1. Write SQL codes using SELECT statements
2. Apply SQL basic operators

Software/Tools Needed:
1. MySQL server
2. SQLyog or Workbench

Direction: Provide the SQL codes for the following problem.

Table name:
Employee

PROBLEM SQL SYNTAX


Display the names of employees whose salary is
between 80000 and 90000.

Display the names of employees who lives in


Albania (AL) and Florida (FL).

Display the all records of employees according to


name in descending order.

Display all state codes.

Display the salary of Jorge.

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 83


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

Laboratory Exercise 5.6


DQL STATEMENTS
Name Score

Course & Year Date

In this lab, you will be able to:


1. Write SQL codes using SELECT statements
2. Apply logical operators (AND, OR, NOT)

Software/Tools Needed:
1. MySQL server
2. SQLyog or Workbench

Direction: Provide the SQL codes for the following problem.

Table name:
Employee

PROBLEM SQL SYNTAX


Display the names of female employees who lives
in Albania (AL).

Display the names of employees whose name starts


with ‘J’ or ‘E’.

Display the names of employees whose name starts


with ‘S’ but not end with ‘R’.

Display the names of employees who lives in


Florida (FL) with salary of higher than 90000.

Display the names of male employees whose salary


is not higher than 50000.

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 84


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

Laboratory Exercise 5.7


DQL STATEMENTS
Name Score

Course & Year Date

In this lab, you will be able to:


1. Write SQL codes using SELECT statements
2. Apply aggregate functions

Software/Tools Needed:
1. MySQL server
2. SQLyog or Workbench

Direction: Provide the SQL codes for the following problem.

Table name:
Employee

PROBLEM SQL SYNTAX


Count how many male employees. Use
‘TotalMales’ as column name.

Compute the total salary of female employees.

Show the average amount of salary.

Show the highest and lowest salary.

Compute the total salary of employees who lives in


Florida (FL).

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 85


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

Laboratory Exercise 5.8


DQL STATEMENTS
Name Score

Course & Year Date

In this lab, you will be able to:


1. Write SQL codes using SELECT statements
2. Apply aggregate functions with Group by and Having clause

Software/Tools Needed:
1. MySQL server
2. SQLyog or Workbench

Direction: Provide the SQL codes for the following problem.

Table name:
Employee

PROBLEM SQL SYNTAX

Show the total numbers of employees by gender.

Show the total numbers of employees in each state.


Just show states with more than 1 employees.

Show the total salary of employees by gender.

Show the total male employees in each state codes.

Show the total salary of female employees in each


state.

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 86


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

Laboratory Exercise 5.9


DQL STATEMENTS
Name Score

Course & Year Date

In this lab, you will be able to:


1. Write SQL codes using SELECT statements
2. Apply SQL joins

Software/Tools Needed:
1. MySQL server
2. SQLyog or Workbench

Direction: Provide the SQL codes for the following problem.

PROBLEM SQL SYNTAX


Display the name of customers and the amount of
their orders.

Display the customer id and their order id and


amount.

Compute the total orders of customers. Show the


name and total amount of orders

Display the name of customers and their order id


and address.

Count how many times the customers placed their


orders. Show the customer name and no. orders.

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 87


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

Laboratory Exercise 5.10


DQL STATEMENTS
Name Score

Course & Year Date

In this lab, you will be able to:


1. Write SQL codes using SELECT statements
2. Apply SQL operators, logical operators, aggregate functions, group by and having clause, SQL Joins

Software/Tools Needed:
3. MySQL server
4. SQLyog or Workbench

Direction: Provide the SQL codes for the following problem.

PROBLEM SQL SYNTAX

Display the number of supplier in each city. Name


the columns as “City” and “TotalSupplier”.

Display the supplier ID and the total number of


parts supplied.

Display the parts and total quantity that is higher


than 500.

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 88


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

PROJECT DESCRIPTION
DATABASE DESIGN AND DEVELOPMENT
PROJECT OUTLINE
DELIVERABLES/OUTPUT DESCRIPTIONS PROCESS
I- INTRODUCTION TO DO:
Describes the reason for the project, usually a
problem with the current system or an opportunity
- look over
HISTORY to provide new services. May describe the various documents and
steps and efforts that led to the current state of the reports to gather
project. information
Provides a general statement of the requirements about the data
and expectations of the project. It states only the the database will
high level requirements and does not get into need to store
SCOPE
specifics. It does not go into detail about how things
- prepare an
are to be done. It may include some general
interview (open-
constraints such as time or budget limits.
ended questions)
The things the project is intended to achieve. - conduct the
Objectives aren’t about creating specific elements of interview
OBJECTIVE the database, for instance, but about what the - prepare a
database is supposed to achieve, why the client questionnaire
wants the database in the first place.
(close-ended
questions)
Breaks the project into discrete tasks. Each task
TASK AND - observe the
should have an estimated duration and concrete
DELIVERABLES actual work
deliverables.
process
II- REQUIREMENTS AND BUSINESS RULES TO DO:
A database requirement is something
the database needs to have or do in - Define and list
LIST OF order to meet the business needs of the requirements
REQUIREMENTS organization for which it is being built. - Define business
-data requirements rules
-report requirements - Search materials
-access and security requirements for nouns to
LIST OF ENTITIES AND Entities are things that a database is define entities
ATTRIBUTES concerned with. Attributes are aspects and attributes
of entities. - Identify
LIST OF BUSINESS Business rule is a rule that covers candidate keys
RULES the way data is acquired, stored or for entities
processed.

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 89


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

III- DATABASE DESIGN TO DO:


An entity relation diagram (ERD) is a - Create Entities
diagram of entities, their attributes and and add attributes
the relations among the entities. - Determine the
appropriate
Using Crow’s foot notation:
ENTITY-RELATIONSHIP relationship
DIAGRAM ENTITY NAME between entities
PK Primary Key - Apply
Attribute 1 normalization (3rd
Attribute 2 Normal Form)
Attribute 3

IV- PHYSICAL DESIGN TO DO:


Data Dictionary: contains information - Use MYSQL
about database objects such as tables, database to
indexes, columns, datatypes, and views. implement a
DATA DICTIONARY physical design of
Format:
SQL CODES: the database based
Table Name:
on the logical
Columns Data Size Description Key
- DATA DEFINITION Type ERDs.
STATEMENTS - Choose
(DDL) Data Types: the column specification appropriate data
that determines what kind of data can types for columns
be stored in that column, character vs. - Enter sample data
- DATA numeric or date, for example. into tables
MANIPULATION
Common data types:
STATEMENTS(DML)
- int, decimal
- char, varchar
- date, time

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 90


CC105 [INFORMATION MANAGEMENT 1 | LABORATORY MANUAL]

REFERENCES

Book Reference:
Conger, S. (2014). Hands-on Database: An Introduction to Database Design and Development.

Pearson.

Online Resources:
Ahlawat. A. (2020). DBMS & SQL Tutorial for Beginners. Studytonight.

https://www.studytonight.com/dbms

DBMS Tutorial. w3schools. https://www.w3schools.in/dbms

Database Design Tutorial: Learn Data Modeling. Guru99. https://www.guru99.com/database-

design.html

[ SAINT MARY’S UNIVERSITY | BAYOMBONG, NUEVA VIZCAYA ] 91

Vous aimerez peut-être aussi