Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
43 views

Lesson 1 - Introduction To Database Management System-Merged

This document provides an introduction to database management systems. It discusses that a database management system (DBMS) allows for the storage, management, and retrieval of related data through a set of application programs. The key goals of a DBMS are to store and manage database information conveniently and efficiently. It also describes the types of data handling as data processing, data management systems, and file-oriented approaches. Finally, it outlines some key characteristics of database systems such as concurrent access, structured and described data, separation of data and applications, data integrity, and transactions.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views

Lesson 1 - Introduction To Database Management System-Merged

This document provides an introduction to database management systems. It discusses that a database management system (DBMS) allows for the storage, management, and retrieval of related data through a set of application programs. The key goals of a DBMS are to store and manage database information conveniently and efficiently. It also describes the types of data handling as data processing, data management systems, and file-oriented approaches. Finally, it outlines some key characteristics of database systems such as concurrent access, structured and described data, separation of data and applications, data integrity, and transactions.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 58

MODULE OF INSTRUCTION

Oracle Database
Welcome to the 1st module of this course Database
Management System 1! For this lesson, we will introduce to
you the type of database system and its components.

Database Management A database-management system (DBMS) is a collection of


interrelated data and a set of different application programs
System
use to access those data. This is a collection of related data
with an implicit meaning and hence is a database.

After completing this lesson, the student should be able to:


 Understand what is the difference between data,
information, database and database management
system.
 Discuss the advantage and disadvantage of database
management system.
 Familiarize with the term ER-Model, Entities,
Relationship and Attribute.

The collection of data, also known as the database, contains


information relevant to an enterprise and or in organization.
The main goal of a Database Management System or also
known as DBMS is to provide a way to store, manage and
retrieve database information that is both convenient and
efficient. By data, we mean known facts that can be recorded
and that have implicit meaning. For example, consider the
Database Management System 1 1
Week 1 Data Manipulation Language

student record which have the complete names, course, year


level, and subjects enrolled. With You may have recorded this
data belongs to the student.
A datum – a unit of data – is a symbol or a set of symbols
which is used to represent something. The relationship
between symbols and what they represent is the true value of
what it mean by information. Hence, information is
interpreted data – data supplied with semantics. Knowledge
refers to the practical use of information. While information
can be transported, stored or shared without many difficulties
the same cannot be said about knowledge. Knowledge
necessarily involves a personal experience.

Database systems are designed to manage bulk of


information. The process of managing the data involves both
defining structures for storage of information and providing
mechanisms for the manipulation of information. In addition,
the database system must ensure the security of the
information stored, in the event of system crashes or attempts
at unauthorized access. If the data are shared to different
users, the system must avoid possible anomalous results.
Because information is so important in most organizations,
the reason why computer scientists have developed a large
body of concepts and techniques for managing data in
Database system which is known as Database Management
System.

Types of Handling Data


Handling of data is divided into three types:
1. Data Processing this is the term generally used to

_____________________________________________________________________________________
2
MODULE OF INSTRUCTION
describe what was done by the large computers in the
late 1940's until 1980's. The process of data
processing before is still being done by most large
organization. Example large volumes of raw
transaction data fed into programs that update a master
file, with fixed format reports written to paper.
2. The term Data Management Systems refers to an
expansion of data processing where the raw data that
fed into programs that update a master file, with fixed
format reports written to paper. is now fed into the
system from a variety of sources, including but not
limited to ATMs, EFT, and direct customer entry
through the Internet. The master file concept has been
largely displaced by database management systems,
and static reporting replaced or augmented by ad-hoc
reporting and direct inquiry, including downloading of
data by customers.

3. File Oriented Approach – The computer system in


the earliest business were used to process and manage
business records and produced information. This is
faster and more accurate compared to manual system.
these systems stored groups of records in separate file,
and now called as file processing. In a common file
processing systems, each department has its own files,
designed and stored specifically for those applications.

Characteristics of Database
1. Concurrent Access – is one of the characteristic of a
database system that allows several users to access the

Database Management System 1 3


Week 1 Data Manipulation Language

database concurrently and simultaneously. And


example of this is answering different questions from
different users with the same database is a central
aspect of an information system. The concurrent use
and access of data increases the economy of a system.
2. Structured and Described Data – once of the
fundamental feature of the database approach is that
the database system does not only contain the data but
also the complete definition, structure and description
of these data. These descriptions are the complete
details about the extent, the structure, the type and the
format of all data and, additionally, the relationship
between the data. This kind of stored data is called
metadata.
3. Separation of Data and Applications – As the
structure and describe data is described through
metadata which is also stored in the database.
Application software does not need any knowledge
about the physical data storage like encoding, format,
storage place, structure and the like. The primary task
of application software is to communicate with the
management system via a standardized interface with
the help of a standardized language like SQL or also
know Structure Query Language. The access to the
data and the metadata is done by the DBMS. In this
way, all the applications can be totally separated from
the data.
4. Data Integrity - Data integrity is a mean of quality
and the reliability of the data of a database system. In
a broader sense data, integrity includes also the

_____________________________________________________________________________________
4
MODULE OF INSTRUCTION
protection of the database from unauthorized access
and changes.
5. Transactions - A transaction is a group of actions
which are done within a database to bring it from one
consistent state to a new consistent state. A transaction
is atomic which means that it cannot be divided up
any further. Within a transaction, all or none of the
actions need to be carried out.
6. Data Persistence - Data persistence means that in a
database management system all data is maintained as
long as it is not deleted explicitly in the database. The
life span of data needs to be determined directly or
indirectly be the user and must not be dependent on
system features which means a database administrator
may identify data that must be deleted or retained.

Advantages and Disadvantages of a DBMS


ADBMS has many advantages
1. Data independence: an application programs should
be as independent as possible from details and
structure of data representation and storage. The
Database Management System can provide an abstract
view of the data to insulate application code from such
details.
2. Efficient data access: A Database Management
System utilizes a variety of sophisticated techniques to
store and retrieve data efficiently. This feature is
especially important if the data is stored on external
storage devices.
3. Data integrity and security: If data is always
accessed through the Database Management System,

Database Management System 1 5


Week 1 Data Manipulation Language

the DBMS can enforce integrity constraints on the


data. DBMS can enforce access controls that govern
what data is visible to different classes of users.
4. Data administration: When several users share the
data simultaneously, centralizing the administration of
data can offer significant improvements and security.
5. Concurrent access and crash recovery: A Database
Management System schedule concurrent accesses to
the data in such a manner that users can think of the
data as being accessed by only one user at a time.
Furthermore, the DBMS protects users from the
effects of system failures.
6. Reduced application development time: The
Database Management System supports many
important functions that are common to many
applications which accesses data stored in the DBMS.
This is connected to the high-level interface of data
that facilitates quick development of applications. This
applications are likely to be more robust than
applications developed from scratch or manualy
because many important tasks are handled by the
DBMS instead of being implemented by the
application.

Disadvantages of a DBMS
1. Danger of a Overkill: For small and simple
applications or for single users a database system is
often not advisable.
2. Complexity: Having database system creates
additional complexity and requirements into the

_____________________________________________________________________________________
6
MODULE OF INSTRUCTION
company and or organization. Managing the operation
of a database management system with several users
and databases is quite costly and demanding.
3. Qualified Personnel: The professional operation of a
database system requires fully trained staff. Without a
qualified database administrator nothing will work for
long as no one will able to maintain and manage the
data store in the database.
4. Costs: having a database management system means
new costs are generated for the system itself but also
for additional hardware and the more complex
handling of the system.
5. Lower Efficiency: A database system is a multi-use
software or also known as generic software which is
often less efficient than specialized software which is
produced and optimized exactly for one problem.

Instances, Physical and Logical Schemas


As values are inserted and deleted information in the database
also changes. The group of information stored in the database
at a particular moment is called an instance of the database.
While the overall design of the database is called the
database schema. Schemas are changed infrequently, if at
all.

The physical schema of database describes the design of the


database at the physical level, while the logical schema
describes the design of the database at the logical level.
Database also have several schemas at the view level, also
known as subschemas that describe different views of the
database. The Application programs are used to exhibit

Database Management System 1 7


Week 1 Data Manipulation Language

physical data independence given that it to do not depend on


the physical schema, and thus need not be rewritten if the
physical schema changes.

Data Models
The underlying the structure of a database is the data model: it
is a collection of conceptual tools for describing data,
relationships, semantics, and integrity constraints.

The Entity-Relationship Model


The entity-relationship (E-R) data model is a collection of
different objects, called entities, and of relationships among
these objects. While an entity is a something that describes an
object from other objects.

The connection or association among several entities is called


a relationship. The logical structure or schema of a database
can be represented graphically by an E-R diagram.

Relational Model
The relational model uses a collection of tables to represent
both data and the relationships among those data a table in
relational model is also know an Entity. Each table or entity
has multiple columns or also known as an attribute which is
used to uniquely identify once table or entity to the other, and
each column has a unique name. The data is arranged in a
relation which is visually represented in a two dimensional
table meaning it is a relationship or connections of two or
more table. In the database, the data is inserted into the table
in the form of tuples or also known as values per row. The

_____________________________________________________________________________________
8
MODULE OF INSTRUCTION
relational model is implemented in database where a relation
is represented by a table, a tuple is represented by a row, an
attribute is represented by a column of the table, attribute
name is the name of the column such as ‘identifier’, ‘name’,
‘city’ etc., and attribute value contains the value for column in
the row.

Constraints during or after the creation of table a user may


apply the constraint to the table and form the logical schema.
A constraint is used to uniquely identify a data and restrict
access to the database. In order to identify properly the
selection of which particular row/tuple from the table, the
attributes i.e. column names are used (ID, LASTNAME,
COURSE), and to expedite the selection of the rows some
fields are defined uniquely to use them as indexes, this helps
in searching the required data as fast as possible.

Lesson Summary:
In this lesson, you should have learned the following.
 Database
 Database Management System
 ER Model
 Advantage and Disadvantage if database

Terms to Remember!
 Application programs - are said to exhibit physical
data independence if they do not depend on the
physical schema.
 Data-known facts that can be recorded and that have
implicit meaning.
 Data integrity- is a byword for the quality and the

Database Management System 1 9


Week 1 Data Manipulation Language

reliability of the data of a database system.


 Database-management system (DBMS) - is a
collection of interrelated data and a set of programs
that is used to access and manipulate data stored in the
database.
 Database schema - the overall design of the database
is called the
 Database systems - are designed to manage large
bodies of information.
 Datum – a unit of data – is a symbol or a set of
symbols which is used to represent relevant
information in the database.
 Information - is also known as interpreted data – data
supplied with semantics.
 Instance of the database – is the collection of
information stored in the database at a particular
moment which means the current state of the data.
 Logical schema - describes the design of the database
at the logical level.
 Physical schema - describes the design of the
database at the physical level,
 Relationship - is an association or connection of one
entity to other entities.
 Transaction - is a group of actions or changes made
to the database to bring it from one consistent state to
a new consistent state.

Textbook:

_____________________________________________________________________________________
10
MODULE OF INSTRUCTION
• Oracle Press (2010). Applied Oracle Security

References:
References • Pratt, Philip J. (2010). Database management systems
• Rob, Peter & Coronel, Carlo (2009). Database
Management Systems
• Schwalbe, Kathy (2011). Management of Information
Technology Projects
• Wheeler, Evan (2011). Security Risk Management :
Building an Information Security Risk Management
Program from the Ground Up

Supplementary Links for Reading and Videos


Supplementary Reading
http://www.eazynotes.com/pages/database-management-
system/introduction-to-dbms.html
https://www.w3schools.in/dbms/intro/
http://www.cs.ubc.ca/nest/dbsl/intro.html

Supplementary Video
https://www.youtube.com/watch?v=1057YmExS-I
https://www.youtube.com/watch?v=kTVLO9F1QoY
https://www.youtube.com/watch?v=0uWA4zps-3k

Suggested Reading
• SQL Tutorial. In ws3schools, Retrieved from
http://www.w3schools.com/sql/default.asp
• Database management system. In Encyclopedia
Britannica, Retrieved from
http://www.britannica.com/EBchecked/topic/152201/d
atabase-management-system-DBMS.
• SQL. In Encyclopedia Britannica, Retrieved from
http://www.britannica.com/EBchecked/topic/569684/
SQL

Database Management System 1 11


Week 1 Data Manipulation Language

• Database Administration. In Encyclopedia.com,


Retrieved from
http://www.encyclopedia.com/topic/Database_adminis
tration.aspx
• SQL. In Encyclopedia.com, Retrieved from
http://www.encyclopedia.com/topic/SQL.aspx
• Tutorialspoint.com
• oracle.com
• apex.oracle.com

_____________________________________________________________________________________
12
MODULE OF INSTRUCTION

Oracle Database
Welcome to the second module of this course Database
Management System 1! For this lesson, we will features and
usage of Oracle 11 express edition.

Oracle Database An Oracle database is a collection of data that is treated as a


unit. The main purpose of a database is to store, manage and
retrieve related information. In the database, a key in solving
the problems of information management is known as a
database server.

After completing this lesson, the student should be able to:


 Identify the main focus area of Oracle 11g software.
 Discuss each feature of Oracle.
 Familiarize with the 4 types of Oracle statement to be
used for database management system 1 subject.

Oracle Database 11g offers extensive features across the


following focus areas:
• Infrastructure Grids: The Infrastructure Grid
technology of Oracle enables pooling of low-cost
servers and storage to form systems that deliver the
highest quality of service in terms of manageability,
high availability, and performance. Oracle Database
11g consolidates and extends the benefits of grid
computing. Aside from taking full advantage of grid
Database Management System 1 1
Week 3 Data Manipulation Language

computing, Oracle Database 11g has unique change


assurance features that allows the database
administrator to manage changes in a controlled and
cost effective manner.
• Information Management: Oracle Database 11g has
the capability to extends the existing information
management capabilities in content management,
information integration, and information life-cycle
management areas. Oracle provides content
management of advanced data types such as
Extensible Markup Language (XML), text, spatial,
multimedia, medical imaging, and semantic
technologies.
• Application Development: Oracle Database 11g has
capabilities to use and manage all the major
application development environments which include
the following Applications: PL/SQL, Java/JDBC,
.NET and Windows, PHP, SQL Developer, and
Application Express.

Features of Oracle Database 11g


• Manageability: By using some of the change
assurance, management automation, and fault
diagnostics features, the database administrators or
also known as DBA can increase their productivity,
reduce costs, minimize errors, and maximize quality
of service. Some of the useful features that promote
better management are Database Replay facility, the
SQL Performance Analyzer, and the Automatic SQL

_____________________________________________________________________________________
2
MODULE OF INSTRUCTION
Tuning facility.

• High availability: By using the high availability


features, a database administrator may reduce the risk
of down time and data loss. These features improve
online operations which enable faster database
upgrades.

• Performance: In Oracle capabilities such as


SecureFiles, compression for online transaction
processing (OLTP), Real Application Clusters (RAC)
optimizations, Result Caches, and so on, a database
administrator may improve the performance of
database. Oracle Database 11g help the organizations
to manage large, scalable, transactional, and data
warehousing systems that deliver fast data access
using low-cost modular storage.

• Security: For the security, the Oracle Database 11g


helps organizations manage and protect their
information with the help of unique and secure
configurations, data encryption and masking, and
sophisticated auditing capabilities. This delivers a
secure and scalable platform for reliable and fast
access to all types of information by using the
industry-standard interfaces.

• Information integration: The integration part of


Oracle Database 11g has many features to better
integrate data throughout the enterprise. It also
supports advanced information life-cycle
management capabilities. This helps you manage the
changing data in your database

Database Management System 1 3


Week 3 Data Manipulation Language

Object Relational Database Management System

• Is also known Relational model and object relational


model

• A user-defined data types and objects

• An Object Relational is fully compatible with


relational database

• It supports multimedia and large objects

• Include a high-quality database server features

Relational Database Concept

• In 1970 the relational model was proposed by Dr. E.F


Codd and has been the basis for Relational Database
Management System.

• The relational model is consists of the following:

• A collection of objects (entities) or relations

• A set of operators to act on the relations


which is used to identify the relationship that
may exist per object.

• A data integrity for accuracy and consistency


of data

_____________________________________________________________________________________
4
MODULE OF INSTRUCTION
• A relational database is a collection of relations or a
connection of two-dimensional tables controlled by
the Oracle server.

Relating Multiple Tables

• Each row of data in a table can be uniquely identified


by adding a primary key during or after the table has
been created.

• A user can logically relate data from multiple tables


using foreign keys or also known as the connection
between two or more table.

Using SQL to Query Your Database

Structured query language (SQL) is:

• Is also know as the ANSI standard language for


operating relational databases

• Efficient, easy to learn, and use

• Complete with SQL, where a user can define,


retrieve, and manipulate data in the tables.

SQL Statements Used in the Course

1. Data manipulation language (DML

Database Management System 1 5


Week 3 Data Manipulation Language

 SELECT

 INSERT

 UPDATE

 DELETE

 MERGE

2. Data definition language (DDL)

 CREATE

 ALTER

 DROP

 RENAME

 TRUNCATE

 COMMENT

3. Data control language (DCL

 GRANT

 REVOKE

4. Transaction control

 COMMIT

 ROLLBACK

 SAVEPOINT

Lesson Summary:
In this lesson, you should have learned the following.

_____________________________________________________________________________________
6
MODULE OF INSTRUCTION
• Focus area of Oracle;

• Features; and

• Different type of oracle statements

Terms to Remember!
• In 1970 the relational model was proposed by Dr.
E.F Codd and has been the basis for Relational
Database Management System.
• A relational database is a collection of relations or a
connection of two-dimensional tables controlled by
the Oracle server.

Textbook:
• Oracle Press (2010). Applied Oracle Security

References:
• Pratt, Philip J. (2010). Database management systems
• Rob, Peter & Coronel, Carlo (2009). Database
Management Systems
• Schwalbe, Kathy (2011). Management of Information
Technology Projects
• Wheeler, Evan (2011). Security Risk Management :
Building an Information Security Risk Management
Program from the Ground Up

References
Suggested Reading
• SQL Tutorial. In ws3schools, Retrieved from
http://www.w3schools.com/sql/default.asp

Database Management System 1 7


Week 3 Data Manipulation Language

• Database management system. In Encyclopedia


Britannica, Retrieved from
http://www.britannica.com/EBchecked/topic/152201/
database-management-system-DBMS.
• SQL. In Encyclopedia Britannica, Retrieved from
http://www.britannica.com/EBchecked/topic/569684/
SQL
• Database Administration. In Encyclopedia.com,
Retrieved from
http://www.encyclopedia.com/topic/Database_admini
stration.aspx
• SQL. In Encyclopedia.com, Retrieved from
http://www.encyclopedia.com/topic/SQL.aspx
• Tutorialspoint.com
• oracle.com
• apex.oracle.com

_____________________________________________________________________________________
8
MODULE OF INSTRUCTION

Oracle Database Installation Guide

Welcome to the second module of this course. For this lesson, we will
discuss the task of Database Administrator, System requirement and
Installation procedure.

Before a student may proceed on the next chapter installing this


software Oracle Database 11g is a prerequisite. Student need to create
an account to www.oracle.com in order to download the 11g database
software, moreover without installing the software may hinder the
student to complete the course due to activity file for manual grading
are included in this course.

Oracle Database 11g


This course used the Oracle Database 11g Express Edition (Oracle
Database XE) is an entry-level, small-footprint database based on the
Oracle Database 11g Release 2 code base. It's free to develop, deploy,
and distribute; fast to download; and simple to administer.

At the end of the lesson the student should be able to:

• Describe his/her role as a database administrator (DBA) and


explain typical tasks and tools.

• Plan an Oracle software installation.

• Install the Oracle database software.

The task of a database administor

A database administrator task involved the approach for designing,


implementing, and maintaining an Oracle database which involves the
following tasks:

1. Evaluating the database server hardware needed for


installation
2. Installing the Oracle software
3. Planning the database design and different security
strategy
4. Creating, migrating, and opening the database in
different scenario
5. Backing up the database.

Database Management System 2 1


Week 2 Oracle Database 11g Installation Guide

6. Enrolling system users and or creating new user and


roles as well as planning for their Oracle Network
access.
7. Implementing the database design develop
8. Recovering from database failure or system failure
9. Monitoring database performance at all times

Tools for Administering

1. Oracle Universal Installer


2. Database Configuration Assistant
3. Database Upgrade Assistant
4. Oracle Net Manager
5. Oracle Net Configuration Assistant
6. Oracle Enterprise Manager
7. Server Control Utility
8. Recovery Manager
9. SQL*Loader

Consideration guideline when planning to install Oracle Database 11g

• What Oracle software the database is planning to install?

• Does the current hardware/computer system used by the user


meet the minimum required specifications?

• Is there a recommended order of installation that a user must


follow when multiple products are involved?

• Are there other steps that must be performed by other user


other than the DBA?

System Requirements

1. Memory requirements:

 1 GB for the database instance with Oracle Enterprise


 Manager Database Control
 1.5 GB for the ASM instance and Oracle Restart
2. Disk space requirements

 3 GB of swap space (based on 2 GB RAM)

2
MODULE OF INSTRUCTION

 1 GB of disk space in the /tmp directory


 3.8 GB for the Oracle Database software
 4.5 GB for the Grid Infrastructure software
 1.7 GB for the preconfigured database (optional)
 3.4 GB for the fast recovery area (optional)

3. Operating system

Preparing the Operating System

Create the required operating system users and groups:

– Groups:
– oinstall
– dba
Optional groups (if doing separation of duty across multiple users):

– oper
– asmdba
– asmoper
– asmadmin
• Software owner, usually oracle

• Can create multiple users for multiple product installations

Setting environment Variables:

Oracle environment variables:

1. ORACLE_BASE: Base of the Oracle directory structure.

 Recommended to set this before installation.

2. ORACLE_HOME: The environment in which Oracle


products run. Not required before installation if
ORACLE_BASE is set.

3. ORACLE_SID: Not required before installation, but useful


afterwards for ease of interaction with a particular instance

4. NLS_LANG: Optional environment variable that controls


language, territory, and client character set settings

Database Management System 2 3


Week 2 Oracle Database 11g Installation Guide

Requirements:

• Adequate temporary space


• 64-bit versus 32-bit issues
• Correct operating system (OS)
• OS patch level
• System packages
• System and kernel parameters
• X Server permissions
• Sufficient swapping
• ORACLE_HOME status

Installation Guide:

Step 1:

• Download Oracle Database thru www.oracle.com


• Click on License Agreement
• Choose the type of Operating system used.

Step 2:

• If with existing oracle account provide information on the left


side then click sign in
• If a new user click the CREATE ACCOUNT

4
MODULE OF INSTRUCTION

Step 3:

• Fill up the form with necessary information mark in * are


required field.
• Click Submit

Step 3:

• Once the account is created open your email to confirm the


verification code sent by Oracle.

Step 4:

• Verify the link sent by oracle

Database Management System 2 5


Week 2 Oracle Database 11g Installation Guide

Step 5:
 Once verified the downloading the Oracle will start

Step 6:

 When download is completed double click the rar file >


Click on DISK1>followed by setup.exe
 Clicking the setup.exe will automatically extract the file
downloaded file.

6
MODULE OF INSTRUCTION

Step 7:

 Wait the installation wizard to finish extracting the Oracle


Database 11Express Edition

Database Management System 2 7


Week 2 Oracle Database 11g Installation Guide

 Once done click Next

 Accept the license agreement

8
MODULE OF INSTRUCTION

 Choose location where to install the software, or you may use


the default drive.

 Set you global password: suggested is oracle


Note: for uniformity student are required to follow the
suggested username and password in order to follow on the
succeeding examples.

Database Management System 2 9


Week 2 Oracle Database 11g Installation Guide

 Wait the setting to check all the required setting environment

 Click Finish

10
MODULE OF INSTRUCTION

Note:
1. After clicking the finish button, locate the Oracle 11g
Express edition Folder found on the start menu of your
Operating system.
2. Then click the folder, click the PL/SQL Command Line.
3. When the CMD is open try to log-in using the username
and password set during installation.
4. Type in Connect then click enter
5. Then type the password: oracle (note typing the password
is hidden on the screen)
You must have the CONNECTED message. This means you
successfully log-in in Oracle using the PL/SQL command line.

Lesson Summary:
Before preceding with the next Chapters the student should
finished the following:
 Create Oracle Account – www.oracle.com
 Successfully Install Oracle Database 11g Express
Edition
 Able to establish as user Connection at isqlplus using:
CONNECT
USERNAME: SYSTEM (Global Connection to Oracle)
PASSWORD: oracle (password inputted by the student during
installation)

Database Management System 2 11


Week 2 Oracle Database 11g Installation Guide

Glossary
 NLS_LANG: Optional environment variable that controls
language, territory, and client character set settings

 ORACLE_BASE: Base of the Oracle directory structure.


Recommended to set this before installation.

 ORACLE_HOME: The environment in which Oracle


products run. Not required before installation if
ORACLE_BASE is set.

 ORACLE_SID: Not required before installation, but useful


afterwards for ease of interaction with a particular instance

References
Textbook:
 Oracle Database 11g 2nd Edition K Gopalakrishnan (
2012)

References:
 Carlos, Peter (2009). Database Systems
 Connoly, Thomas & Begg, Carolyn (2010). Database
Systems : A practical approach to design,
implementation and management
 Sciore, Edward (2009). Database Design and
Implementation
 Bulusu, Lakshman (2008). Oracle PL/SQL : Expert
Techniques for Developers and Database
Administrators
 Loshin, David (2008). Master Data Management

Supplementary Reading and Video Link


Supplementary Reading

https://docs.oracle.com/cd/B19306_01/server.102/b14220/intro.htm
http://ugweb.cs.ualberta.ca/~c391/manual/chapt1.html
http://www.oracle-dba-online.com/introduction_to_oracle.htm

12
MODULE OF INSTRUCTION

Supplementary Video
https://www.youtube.com/watch?v=2deZysmz9rE&index=1&list=PLg
Xga1uh_X7dkEmttwzU7ulLa_abCq0N4
https://www.youtube.com/watch?v=B1EO24v2ico
https://www.youtube.com/watch?v=2deZysmz9rE

Other Suggested Readings (e.g. periodicals, articles, websites, IT


applications/software, etc.):
 www.oracle.com
 www.apex.oracle.com
 SQL Tutorial. In ws3schools, Retrieved from
http://www.w3schools.com/sql/default.asp
 SQL. In Encyclopedia Britannica, Retrieved from
http://www.britannica.com/EBchecked/topic/569684/S
QL
 Database Administration. In Encyclopedia.com,
Retrieved from
http://www.encyclopedia.com/topic/Database_administ
ration.aspx
 SQL. In Encyclopedia.com, Retrieved from
http://www.encyclopedia.com/topic/SQL.aspxLearning
Icons

Database Management System 2 13


MODULE OF INSTRUCTION

Data Definition Language


Welcome to the third module of this course Database
Management System 1! For this lesson, we will discuss the
Data Definition Language or also known as DDL.

Data Definition Language is used to create a new table,


modify existing column data type and size, as well as add
new column or drop an existing column.

DML A Data Definition Language or also known as DDL is a


standard command that define the different structures in a
database. DDL statements is used to create, modify, and
remove database objects such as tables, indexes, and users.
The common DDL statements are CREATE, ALTER, and
DROP.

After completing this lesson, the student should be able to:


• Categorize differences between database objects.
• Review and analyze the structure of the table.
• Lists and identify the usage of different data types.
• Create a simple table.
• Modify, drop or delete a column after the table is
created.

Database Objects:
A database objects is composed of the following:

Database Management System 1 1


Week 3 Data Definition Language

1. Synonym – is used to gives an alternative name to an


object.

2. Index – this help improve the performance of some queries.


3. Sequence – generate numeric values when the table has been
created.
4. View – Logically represents subsets of data from one or more
table or used to show a portion of data from based table.
5. Table – is also known as basic storage composed of rows and
columns

Table Structure:
 Tables can be created at any time, even if the users are
using the database at the same time while creating a new
table.
 There is no need to specify the size of a table. The size is
ultimately defined by the amount of space allocated to
the database as a whole. As a database administrator, it is
important to estimate and know how much space a table
will use over time. Sometimes it depends on the data type
size and the amount of data stored in the table.

Table Naming Rule


 The name of the Table and column must not begin with
digit instead it must begin with a letter and be 1–30
characters long. However shorter the name is easy to
remember as long the name of the table is easier to
understand.
 Names must contain only the characters A–Z, a–z, 0–9,
and special character like _ (underscore), $, and # .
 Names must not duplicate the name of another object

_____________________________________________________________________________________
2
MODULE OF INSTRUCTION
owned by the same Oracle server user. Meaning using
oracle reserved word like for example, table, view
database is not allowed, as well table name that has been
created by the other users.
 Names must not be an Oracle server–reserved word.

CREATE TABLE statement


To create a table a user must have
 The CREATE TABLE privilege
 A storage area
 Syntax:
CREATE TABLE tbl_name
(Column_lists datatype (size) [default expression] ;
 Where:
o Tbl_name - is the name of the table
o Column_lists – the lists of columns
o Expression – constraint added on each column (if
any).
 Example:
CREATE TABLE STUDENTS
(USN_ID NUMBER (6) PRIMARY KEY,
LASTNAME VARCHAR (15) NOT NULL,
FIRSTNAME VARCHAR (15),
COURSE CHAR (4),
YR_LVL CHAR (5));
 In the example: the name the table is STUDENTS with 5
column names (USN_ID, LASTNAME, FIRSTNAME,
COURSE and YR_LVL), for the column USN_ID it has a
constraint assigned to it name as PRIMARY KEY which
means that this column will restrict the user to enter a

Database Management System 1 3


Week 3 Data Definition Language

redundant values or this column while LASTNAME


column is set to not null which means this column can
accept redundant values as long as no NULL values
inserted to this column.
 To know the structure of the table create, you may use
the DESC or DESCRIBE command.
 Example:

 Using the DESC command will easily check the


structure of the table like constraints enforce in
each column, data type used and size.

Data type
1. VARCHAR- Variable-length character data
2. CHAR - Fixed-length character data
3. NUMBER - Variable-length numeric data
4. DATE - Date and time values
5. LONG - Variable-length character data (up to 2 GB
6. CLOB - Character data (up to 4 GB)
7. RAW and LONG RAW - Raw binary data
8. BLOB - Binary data (up to 4 GB)
9. BFILE - Binary data stored in an external file (up to
4 GB)
10. ROWID - A base-64 number system representing the
unique address of a row in its table

_____________________________________________________________________________________
4
MODULE OF INSTRUCTION

After the table has been created, by any chance that a user
might need to change the table structure for any of the
following reasons:
• You omitted a column.
• Your column definition or its name needs to be
changed.
• You need to remove columns.
• You want to put the table into the read-only mode

To do this uses the ALTER TABLE statement.

Use the ALTER TABLE statement to:


• Add a new column after the table has been created
• Modify an existing column definition
• Define a default value for the new column
• Drop existing column
• Rename a column
• Change table to read-only status

Three (3) types of ALTER statement


1. Alter to ADD – add new column after the table
has been created
2. Alter to DROP – delete specific column
3. Alter to MODIFY – modify an existing column
either change the data type size and data type.

Database Management System 1 5


Week 3 Data Definition Language

ALTER to ADD
 Syntax:
ALTER TABLE tbl_name
ADD column_name datatype(size);

 Suppose that in STUDENTS table it is composed of 3


values as shown in the figure above, then a user need to
add a new column named as ADDRESS to add a new
column without deleting the table afterwards create again
you may use the ALTER to ADD.

 Example:
ALTER TABLE STUDENTS
ADD ADDRESS VARCHAR(15);
Use again DESC command to confirm that the
ADDRESS column is added in the column. From 5
columns it is now compose of 6 columns because of
the ALTER statement. Note the since the table is alter
form 5 to 6 column this only means that when a user
will insert or add a new values to this table, user must
provide now a data for the column ADDRESS.
 Example of Insert:

_____________________________________________________________________________________
6
MODULE OF INSTRUCTION
INSERT INTO STUDENTS VALUES
(400,'ALMAZAN','MARY','BSIM','2','PASIG'
)
 Text in underline is the values for the column
ADDRESS.
 Notice that when a user try to view the whole
values of STUDENTS table the address of the
students who are insert before the user altered the
table are set to NULL.

 The address of the students (SALAMAT,


SUBION, LEE and ALMAZAN) are set to NULL
because during the insertion of their data table
STUDENTS only have 5 columns without the
ADDRESS.

ALTER to MODIFY
 Syntax:
ALTER TABLE tbl_name
MODIFY column_name [new]datatype[new](size);
 Supposed that a user wanted to add additional value for
the STUDENTS table but it so happen that the values
trying to insert in column lastname is too large. See
figure below:

Database Management System 1 7


Week 3 Data Definition Language

 As shown in the output the column lastname only accept


up to 15 characters long. In order to extend the number of
character that this column may accept, you may use the
ALTER to MODIFY statement.

 Example:
ALTER TABLE STUDENTS
MODIFY LASTNAME VARCHAR(20);

 Notice that the size of data type of column LASTNAME


is now modified form 15 to 20. In this case, you may now
add the values of DEL ROSARIO SUR III.

 Since the size of column has been resize to 20 the values


of DELROSARIO SUR III was now successfully
inserted into the STUDENTS table.

_____________________________________________________________________________________
8
MODULE OF INSTRUCTION
ALTER to DROP
 Syntax:
ALTER TABLE tbl_name
DROP COLUMN column_name;
 Supposed that the column address is no longer used and
to save space you may use the ALTER to DROP
statement.
 Example:
ALTER TABLE STUDENTS
DROP COLUMN ADDRESS;
 To view and confirm that the column ADDRESS has
been deleted you may use the DESC command.

 Notice that from 6 columns STUDENTS table


have now 5 columns without the address column.

Rename the Table


 To rename the table or change the existing name
of the table use the RENAME statement;
 Syntax:
RENAME old_tbl_name TO new_tbl_name;
 Example:
RENAME STUDENTS TO STUDYANTE;
 This means whenever a SELECT statement is
used FROM clause must call the new name of the

Database Management System 1 9


Week 3 Data Definition Language

table:
 Example:

TRUNCATE statement
 To delete the values in the STUDENTS but
leaving it structure you may use the TRUNCATE
statement.
 Syntax:
TRUNCATE TABLE tbl_name;
 Example:
TRUNCATE TABLE STUDYANTE;

 Using the TRUNCATE statement will delete the


values in the STUDYANTE table.

 As shown above no rows are selected when


SELECT stamen is issued while when DESC
command is issued the structure of STUDYANTE

_____________________________________________________________________________________
10
MODULE OF INSTRUCTION
table is still intact.

Dropping a Table
 All records in the table will be deleted as well as
it structure when you drop table has been issued,
 A rollback statement will also help retrieve the
record after the DROP statement is issued if
PURGE statement has been applied.
 Syntax
DROP TABLE table
 In the syntax, table is the name of the table.

Guidelines
• All the data is deleted from the table.
• Any views and synonyms remain, but are invalid.
• Any pending transactions are committed.
• Only the creator of the table or a user with the DROP
ANY TABLE privilege can remove a table.
• Example:
DROP TABLE STUDENTS;
 Using this will delete permanently the
STUDYANTE table as shown below.

Database Management System 1 11


Week 3 Data Definition Language

Lesson Summary:
In this lesson you should have learned how to:
 Create new table by using the CREATE table
statement.
 Add, modify or drop exiting column using the
ALTER statement.
 Change the name of the table using the RENAME
statement.
 Delete the table using the DROP statement
 Remove all rows in the table using the
TRUNCATE statement.

Terms to Remember!
BFILE - Binary data stored in an external file (up to 4 GB)
BLOB - Binary data (up to 4 GB)
CHAR - Fixed-length character data
CLOB - Character data (up to 4 GB)
DATE - Date and time values
DROP TABLE - it is a statement that moves a table to the
recycle bin
Index – improves the performance of some queries.
LONG - Variable-length character data (up to 2 GB
NUMBER - Variable-length numeric data
RAW and LONG RAW - Raw binary data
ROWID - A base-64 number system representing the unique
address of a row in its table
Sequence – generate numeric values.
Synonym – Gives alternative name to an object.
Table – basic unit of storage composed of rows and columns
VARCHAR- Variable-length character data
View – logically represents subsets of data from one or more
_____________________________________________________________________________________
12
MODULE OF INSTRUCTION
table.

Textbook:
References  Oracle Press (2010). Applied Oracle Security

References:
 Pratt, Philip J. (2010). Database management systems
 Rob, Peter & Coronel, Carlo (2009). Database
Management Systems
 Schwalbe, Kathy (2011). Management of Information
Technology Projects
 Wheeler, Evan (2011). Security Risk Management :
Building an Information Security Risk Management
Program from the Ground Up
Supplementary Reading and Video Link

Supplementary Reading
https://www.w3schools.in/mysql/ddl-dml-dcl/
http://www.oracle-dba-
online.com/sql/oracle_data_definition_language.htm
https://www.tutorialspoint.com/sql_certificate/using_ddl_statem
ents.htm

Supplementary Video
https://www.youtube.com/watch?v=XIhAhXda6EE
https://www.youtube.com/watch?v=UvymdJ5IjZA
https://www.youtube.com/watch?v=5dszS8TxTJ4

Suggested Reading
 SQL Tutorial. In ws3schools, Retrieved from
http://www.w3schools.com/sql/default.asp
 Database management system. In Encyclopedia
Britannica, Retrieved from
http://www.britannica.com/EBchecked/topic/152201/
database-management-system-DBMS.

Database Management System 1 13


Week 3 Data Definition Language

 SQL. In Encyclopedia Britannica, Retrieved from


http://www.britannica.com/EBchecked/topic/569684/
SQL
 Database Administration. In Encyclopedia.com,
Retrieved from
http://www.encyclopedia.com/topic/Database_admini
stration.aspx
 SQL. In Encyclopedia.com, Retrieved from
http://www.encyclopedia.com/topic/SQL.aspx
 Tutorialspoint.com
 oracle.com
 apex.oracle.com

_____________________________________________________________________________________
14
MODULE OF INSTRUCTION

Data Manipulation Language


Welcome to the fourth module of this course Database
Management System 1! For this lesson, we will discuss the
Data Manipulation Language or also known as DML.

Data Manipulation Language is used to insert update and


delete value in the table.

DML Data manipulation language (DML) is a core part of SQL.


When you want to add, update, or delete data in the database,
you execute a DML statement. A collection of DML
statements that form a logical unit of work is called a
transaction.

After completing this lesson, the student should be able


to:
 Insert new values in the table using the INSERT
statement.
 Modify existing values in the table using the
UPDATE statement
 Delete existing row using DELETE statement.

Data Manipulation Language


A DML statement is executed when you:
 Add new rows to a table using INSERT statement

Database Management System 1 1


Week 3 Data Manipulation Language

 Modify existing rows in a table suing UPDATE


statement
 Remove existing rows from a table using DELETE
statement

A transaction consists of a collection of DML statements


that form a logical unit of work.
 Consider an enrollment database. When a student
already took the subject, the status of this subject
should be updated from enrolled to pass, as well a the
year level of the student must also change.

INSERT statement
 Insert a new row containing values for each column.
 List values in the default order of the columns in the
table.
 Optionally, list the columns in the INSERT clause.
 Enclose character and date values within single
quotation marks.
 Add new rows to a table by using the INSERT
statement:
 Syntax:
INSERT INTO tbl_name values (column_list);
 In the syntax:
o TBL_NAME - Is the name of the table
o COLUMN_LIST - Is the name of the column
in the table to populate
o VALUES - Is the corresponding value for the
column

_____________________________________________________________________________________
2
MODULE OF INSTRUCTION

 Old Table: with three values

 Suppose that the STUDENTS table is composed of 3


rows and a user wanted to add a new student record:
 Example:
INSERT INTO STUDENTS VALUES
(500,'REYES','ANNA','BSIS','1');
 To confirm that ANNA was successfully added used
the SELECT statement:

 As shown in the image above notice that Anna is now


one of the students recorded in STUDENTS table.

Inserting Rows with Null Values


 Implicit method: Omit the column from the
column list.
 Example:
INSERT INTO STUDENTS
(USN_ID,LASTNAME)
VALUES (502,'CUBAO');

Database Management System 1 3


Week 3 Data Manipulation Language

 Output:

 As you notice, in the implicit method specific


columns are specified during the insertion before the
values are added in the VALUES clause using this
method will automatically set the column to NULL to
those columns which are not called in the INSERT
INTO statement.

 Explicit method: Specify the NULL keyword in the


VALUES clause.
 EXAMPLE:
INSERT INTO STUDENTS VALUES
(505,'ABIOG','SHIELA',NULL,NULL);
 Output:

 As shown in the example, using the implicit method


this method is used to insert all values according to its
order in the column lists, however, notice that to

_____________________________________________________________________________________
4
MODULE OF INSTRUCTION
those values with no inputs this is set to NULL in the
INSERT INTO statement. By using this method
automatically column with values set to NULL will
automatically have NULL values.

Changing Data in a Table


 Modify existing values in a table with the UPDATE
statement:
 Syntax:
UPDATE TBL_NAME
SET COLUMN = NEW VALUES
[WHERE CONDITION];
 In the syntax:
Tbl_name - Is the name of the table
set column - Is the name of the column in the table to
populate
new_value - Is the corresponding value or subquery
for the column
condition - Identifies the rows to be updated by using
comparison operator, logical condition
and or adding subqueries.

 As shown in the table supposed that we wanted to


update the firstname to ‘MARVIN’ of students with
USN_ID equal to 502. To do that we may need to use

Database Management System 1 5


Week 3 Data Manipulation Language

the UPDATE statement.


 Example:
UPDATE STUDENTS
SET FIRSTNAME = 'MARVIN'
WHERE USN_ID=502;
 Output:

 As you notice in the output the firstname of student


with USN_ID equal to 502 is not updated to
MARVIN.
 Where condition identifies into which specific
column the user wanted to make the changes given in
the SET clause.

Updating two columns in one UPDATE statement.


 To update to or more columns in one UPDATE
statement put a comma (,) after each column called in
the SET clause.
 Example:
UPDATE STUDENTS
SET YR_LVL='IRREG', LASTNAME = 'ABIOG'
WHERE USN_ID = 505;

_____________________________________________________________________________________
6
MODULE OF INSTRUCTION
 Output: Old table

 Output: New table

 Compare the Old and new table after the Update


statement is issued as you notice the LASTNAME
and YR_LVL of the student of USN_ID equal to 505
were updated by using 1 UPDATE statement.

DELETE Statement
 You can remove existing rows from a table by using
the DELETE statement:
 Syntax:
DELETE FROM TBL_NAME
WHERE CONDITION;
 In the syntax:
Tbl_name - Is the name of the table
Where condition - Identifies the rows to be deleted,
and is composed of column names, expressions,
constants, subqueries, and comparison operators.

Database Management System 1 7


Week 3 Data Manipulation Language

 If WHERE condition is added on the statement,


specific rows will be deleted
 Example:
DELETE FROM STUDENTS
WHERE YR_LVL='1';
 Output: Old table

 Output: New table

 As by comparing old and new output notice that 2


rows with YR_LCL equal to 1 are deleted as shown
in the new output.
 All rows in the table are deleted if you omit the
WHERE clause:
 Example:
DELETE FROM STUDENTS;
 Output:

_____________________________________________________________________________________
8
MODULE OF INSTRUCTION
 As in the output all rows are deleted if WHERE
clause is omitted.

Lesson Summary:
In this lesson, you should have learned how to use the
following statements:

 Insert into to add new rows in a table

 Update to modify existing values is a table

 Delete to remove specific rows in a table

Terms to Remember!
 DELETE – a statement use to remove existing rows
in a table.
 DML – stand for Data Manipulation Language.
 Explicit method - an Insert statement that Specifies
the NULL keyword in the VALUES clause.
 Implicit method - an Insert statement that Omits the
column from the column list.
 INSERT - a statement used to add new rows in a
table.
 Transaction - consists of a collection of DML
statements that form a logical unit of work.
 UPDATE - a statement used to update existing rows
in a table.

References Textbook:
 Oracle Press (2010). Applied Oracle Security

References:
 Pratt, Philip J. (2010). Database management systems

Database Management System 1 9


Week 3 Data Manipulation Language

 Rob, Peter & Coronel, Carlo (2009). Database


Management Systems
 Schwalbe, Kathy (2011). Management of Information
Technology Projects
 Wheeler, Evan (2011). Security Risk Management :
Building an Information Security Risk Management
Program from the Ground Up

Supplementary Reading and Video Link


Supplementary Reading
https://docs.microsoft.com/en-us/sql/t-sql/queries/queries
https://dev.mysql.com/doc/refman/5.7/en/sql-syntax-data-
manipulation.html
https://docs.oracle.com/database/121/TDDDG/tdddg_dml.htm#T
DDDG99941

Supplementary Video
https://www.youtube.com/watch?v=S54W4oSqp7s
https://www.youtube.com/watch?v=vnFu6sBfcSs
https://www.youtube.com/watch?v=0EmMIUvjPbA

Suggested Reading
 SQL Tutorial. In ws3schools, Retrieved from
http://www.w3schools.com/sql/default.asp
 Database management system. In Encyclopedia
Britannica, Retrieved from
http://www.britannica.com/EBchecked/topic/152201/
database-management-system-DBMS.
 SQL. In Encyclopedia Britannica, Retrieved from
http://www.britannica.com/EBchecked/topic/569684/
SQL
 Database Administration. In Encyclopedia.com,
Retrieved from
http://www.encyclopedia.com/topic/Database_admini

_____________________________________________________________________________________
10
MODULE OF INSTRUCTION
stration.aspx
 SQL. In Encyclopedia.com, Retrieved from
http://www.encyclopedia.com/topic/SQL.aspx
 Tutorialspoint.com
 oracle.com
 apex.oracle.com

Database Management System 1 11

You might also like