Field Multiple related characters are combined to form a field. For example, if we are processing
employees data of a company, we may have an employee-code field, an employee-name field, an
hours-worked field, an hourly-pay-rate filed and a tax-rate-deduction field etc.
Record Multiple related fields are combined to form a record. For example, an employee record will
contain the fields containing the data of an employee, such as the employees code, name, hours-
worked, pay-rate, tax-rate deduction and so forth.
File Multiple related records are combined to form a file. For example, a collection of all the
employee records of a company would be an employee file.
Database Multiple related files are integrated to form a database. For example, an employee
database of an organization may integrate the records of multiple employee files, such as employee
salary files containing details of salary and taxation information of all employees, employee personnel
information file containing details of personnel information of all employees and employee skill-set
file containing details of various types of skills of all employees.
A.N.M. Bazlur Rashid, Assistant Professor (Computer) & Head, Department of Allied Engineering, Bangladesh University of Textiles / Page 2 of 28
Application of Computer in Yarn/Fabric/Wet/Apparel/Management Lecture # Database Management System
those requests. The DBMS hides much of the databases internal complexity from the application programs
and users.
The different advantages of DBMS are as follows.
Improved data sharing - The DBMS helps create an environment in which end users have better
access to more and better-managed data. Such access makes it possible for end users to respond
quickly to changes in their environment.
Improved data security - The more users access the data, the greater the risks of data security
breaches. Corporations invest considerable amounts of time, effort, and money to ensure that
corporate data are used properly. A DBMS provides a framework for better enforcement of data
privacy and security policies.
Better data integration - Wider access to well-managed data promotes an integrated view of the
organizations operations and a clearer view of the big picture. It becomes much easier to see how
actions in one segment of the company affect other segments.
Minimized data inconsistency - Data inconsistency exists when different versions of the same data
appear in different places. For example, data inconsistency exists when a companys sales department
stores a sales representatives name as Bill Brown and the companys personnel department stores
that same persons name as William G. Brown, or when the companys regional sales office shows
the price of a product as $45.95 and its national sales office shows the same products price as $43.95.
The probability of data inconsistency is greatly reduced in a properly designed database.
Improved data access - The DBMS makes it possible to produce quick answers to ad hoc queries. From
a database perspective, a query is a specific request issued to the DBMS for data manipulationfor
example, to read or update the data. Simply put, a query is a question, and an ad hoc query is a spur-
of-the-moment question. The DBMS sends back an answer (called the query result set) to the
application. For example, end users, when dealing with large amounts of sales data, might want quick
answers to questions (ad hoc queries) such as:
What was the dollar volume of sales by product during the past six months?
What is the sales bonus figure for each of our salespeople during the past three months?
How many of our customers have credit balances of $3,000 or more?
Improved decision making - Better-managed data and improved data access make it possible to
generate better-quality information, on which better decisions are based. The quality of the
information generated depends on the quality of the underlying data. Data quality is a comprehensive
approach to promoting the accuracy, validity, and timeliness of the data. While the DBMS does not
guarantee data quality, it provides a framework to facilitate data quality initiatives.
Increased end-user productivity - The availability of data, combined with the tools that transform
data into usable information, empowers end users to make quick, informed decisions that can make
the difference between success and failure in the global economy.
Limitations of DBMS
Although the database system yields considerable advantages over previous data management approaches,
database systems do carry significant disadvantages. For example:
Increased costs - Database systems require sophisticated hardware and software and highly skilled
personnel. The cost of maintaining the hardware, software, and personnel required to operate and
manage a database system can be substantial. Training, licensing, and regulation compliance costs are
often overlooked when database systems are implemented.
Management complexity - Database systems interface with many different technologies and have a
significant impact on a companys resources and culture. The changes introduced by the adoption of a
database system must be properly managed to ensure that they help advance the companys
A.N.M. Bazlur Rashid, Assistant Professor (Computer) & Head, Department of Allied Engineering, Bangladesh University of Textiles / Page 3 of 28
Application of Computer in Yarn/Fabric/Wet/Apparel/Management Lecture # Database Management System
objectives. Given the fact that database systems hold crucial company data that are accessed from
multiple sources, security issues must be assessed constantly.
Maintaining currency - To maximize the efficiency of the database system, you must keep your
system current. Therefore, you must perform frequent updates and apply the latest patches and
security measures to all components. Because database technology advances rapidly, personnel
training costs tend to be significant. Vendor dependence. Given the heavy investment in technology
and personnel training, companies might be reluctant to change database vendors. As a consequence,
vendors are less likely to offer pricing point advantages to existing customers, and those customers
might be limited in their choice of database system components.
Frequent upgrade/replacement cycles - DBMS vendors frequently upgrade their products by adding
new functionality. Such new features often come bundled in new upgrade versions of the software.
Some of these versions require hardware upgrades. Not only do the upgrades themselves cost money,
but it also costs money to train database users and administrators to properly use and manage the
new features.
Levels of Abstraction
Physical level: describes how a record (e.g., customer) is stored.
Logical level: describes data stored in database, and the relationships among the data.
o type customer = record
customer_id : string;
customer_name : string;
customer_street : string;
customer_city : string;
end;
View level: application programs hide details of data types. Views can also hide information (such as
an employees salary) for security purposes.
A.N.M. Bazlur Rashid, Assistant Professor (Computer) & Head, Department of Allied Engineering, Bangladesh University of Textiles / Page 4 of 28
Application of Computer in Yarn/Fabric/Wet/Apparel/Management Lecture # Database Management System
Database Design
The process of designing the general structure of the database:
Logical Design Deciding on the database schema. Database design requires that we find a good
collection of relation schemas.
o Business decision What attributes should we record in the database?
o Computer Science decision What relation schemas should we have and how should the
attributes be distributed among the various relation schemas?
Physical Design Deciding on the physical layout of the database
Data Models
A collection of tools for describing
o Data
o Data relationships
o Data semantics
o Data constraints
Relational model
Entity-Relationship data model (mainly for database design)
Object-based data models (Object-oriented and Object-relational)
Semistructured data model (XML)
Other older models:
o Network model
o Hierarchical model
A.N.M. Bazlur Rashid, Assistant Professor (Computer) & Head, Department of Allied Engineering, Bangladesh University of Textiles / Page 5 of 28
Application of Computer in Yarn/Fabric/Wet/Apparel/Manag
Apparel/Management Lecture # Database Management System
Relational Model
Example of tabular data in the relational model
A.N.M. Bazlur Rashid, Assistant Professor (Computer) & Head, Department of Allied Engineering, Bangladesh University of Textiles / Page 6 of 28
Application of Computer in Yarn/Fabric/Wet/Apparel/Management Lecture # Database Management System
A.N.M. Bazlur Rashid, Assistant Professor (Computer) & Head, Department of Allied Engineering, Bangladesh University of Textiles / Page 7 of 28
Application of Computer in Yarn/Fabric/Wet/Apparel/Management Lecture # Database Management System
Transaction Management
A transaction is a collection of operations that performs a single logical function in a database
application
Transaction-management component ensures that the database remains in a consistent (correct)
state despite system failures (e.g., power failures and operating system crashes) and transaction
failures.
Concurrency-control manager controls the interaction among the concurrent transactions, to ensure
the consistency of the database.
Database Administrator
Coordinates all the activities of the database system; the database administrator has a good
understanding of the enterprises information resources and needs.
Database administrator's duties include:
o Schema definition
o Storage structure and access method definition
o Schema and physical organization modification
o Granting user authority to access the database
o Specifying integrity constraints
o Acting as liaison with users
o Monitoring performance and responding to changes in requirements
A.N.M. Bazlur Rashid, Assistant Professor (Computer) & Head, Department of Allied Engineering, Bangladesh University of Textiles / Page 8 of 28
Application of Computer in Yarn/Fabric/Wet/Apparel/Management Lecture # Database Management System
A.N.M. Bazlur Rashid, Assistant Professor (Computer) & Head, Department of Allied Engineering, Bangladesh University of Textiles / Page 9 of 28
Application of Computer in Yarn/Fabric/Wet/Apparel/Management Lecture # Database Management System
SQL Statements
A.N.M. Bazlur Rashid, Assistant Professor (Computer) & Head, Department of Allied Engineering, Bangladesh University of Textiles / Page 10 of 28
Application of Computer in Yarn/Fabric/Wet/Apparel/Management Lecture # Database Management System
Naming Rules
Table names and column names:
Must begin with a letter
Must be 130 characters long
Must contain only AZ, az, 09, _, $, and #
Must not duplicate the name of another object owned by the same user
Must not be an Oracle server reserved word
Creating Tables
DESC[RIBE] tablename;
DESCRIBE employees;
DESC employees;
A.N.M. Bazlur Rashid, Assistant Professor (Computer) & Head, Department of Allied Engineering, Bangladesh University of Textiles / Page 11 of 28
Application of Computer in Yarn/Fabric/Wet/Apparel/Management Lecture # Database Management System
DESCRIBE dept;
Dropping a Table
All data and structure in the table is deleted.
Any pending transactions are committed.
All indexes are dropped.
You cannot roll back the DROP TABLE statement.
Arithmetic Expressions
Create expressions with number and date data by using arithmetic operators.
A.N.M. Bazlur Rashid, Assistant Professor (Computer) & Head, Department of Allied Engineering, Bangladesh University of Textiles / Page 13 of 28
Application of Computer in Yarn/Fabric/Wet/Apparel/Management Lecture # Database Management System
Operator Precedence
Operator Precedence
SELECT last_name, salary, 12*salary+100
FROM employees;
Using Parentheses
SELECT last_name, salary, 12*(salary+100)
FROM employees;
A.N.M. Bazlur Rashid, Assistant Professor (Computer) & Head, Department of Allied Engineering, Bangladesh University of Textiles / Page 14 of 28
Application of Computer in Yarn/Fabric/Wet/Apparel/Management Lecture # Database Management System
Concatenation Operator
A concatenation operator:
Concatenates columns or character strings to other columns
Is represented by two vertical bars (||)
Creates a resultant column that is a character expression
Duplicate Rows
The default display of queries is all rows, including duplicate rows.
SELECT department_id
FROM employees;
A.N.M. Bazlur Rashid, Assistant Professor (Computer) & Head, Department of Allied Engineering, Bangladesh University of Textiles / Page 15 of 28
Application of Computer in Yarn/Fabric/Wet/Apparel/Management Lecture # Database Management System
A.N.M. Bazlur Rashid, Assistant Professor (Computer) & Head, Department of Allied Engineering, Bangladesh University of Textiles / Page 16 of 28
Application of Computer in Yarn/Fabric/Wet/Apparel/Management Lecture # Database Management System
Comparison Conditions
A.N.M. Bazlur Rashid, Assistant Professor (Computer) & Head, Department of Allied Engineering, Bangladesh University of Textiles / Page 17 of 28
Application of Computer in Yarn/Fabric/Wet/Apparel/Management Lecture # Database Management System
SELECT first_name
FROM employees
WHERE first_name LIKE 'S%';
SELECT last_name
FROM employees
WHERE last_name LIKE '_o%';
You can use the ESCAPE identifier to search for the actual % and _ symbols.
The ESCAPE option identifies the backslash (\) as the escape character. In the pattern, the escape character
precedes the underscore (_). This causes the Oracle Server to interpret the underscore literally.
A.N.M. Bazlur Rashid, Assistant Professor (Computer) & Head, Department of Allied Engineering, Bangladesh University of Textiles / Page 18 of 28
Application of Computer in Yarn/Fabric/Wet/Apparel/Management Lecture # Database Management System
Logical Conditions
Rules of Precedence
SELECT last_name, job_id, salary
FROM employees
WHERE job_id = 'SA_REP'
OR job_id = 'AD_PRES'
AND salary > 15000;
A.N.M. Bazlur Rashid, Assistant Professor (Computer) & Head, Department of Allied Engineering, Bangladesh University of Textiles / Page 19 of 28
Application of Computer in Yarn/Fabric/Wet/Apparel/Management Lecture # Database Management System
ORDER BY Clause
Sort rows with the ORDER BY clause
ASC: ascending order, default
DESC: descending order
The ORDER BY clause comes last in the SELECT statement.
A.N.M. Bazlur Rashid, Assistant Professor (Computer) & Head, Department of Allied Engineering, Bangladesh University of Textiles / Page 20 of 28
Application of Computer in Yarn/Fabric/Wet/Apparel/Management Lecture # Database Management System
Manipulating Data
Data Manipulation Language
A DML statement is executed when you:
Add new rows to a table
Modify existing rows in a table
Remove existing rows from a table
A transaction consists of a collection of DML statements that form a logical unit of work.
A.N.M. Bazlur Rashid, Assistant Professor (Computer) & Head, Department of Allied Engineering, Bangladesh University of Textiles / Page 21 of 28
Application of Computer in Yarn/Fabric/Wet/Apparel/Management Lecture # Database Management System
UPDATE table
SET column = value [, column = value, ...]
[WHERE condition];
Specific row or rows are modified if you specify the WHERE clause.
UPDATE employees
SET department_id = 70
WHERE employee_id = 113;
A.N.M. Bazlur Rashid, Assistant Professor (Computer) & Head, Department of Allied Engineering, Bangladesh University of Textiles / Page 22 of 28
Application of Computer in Yarn/Fabric/Wet/Apparel/Management Lecture # Database Management System
All rows in the table are modified if you omit the WHERE clause.
UPDATE copy_emp
SET department_id = 110;
All rows in the table are deleted if you omit the WHERE clause.
DELETE FROM employees;
Database Transactions
A database transaction consists of one of the following:
DML statements which constitute one consistent change to the data
One DDL statement
One DCL statement
Database Transactions
Begin when the first DML SQL statement is executed
End with one of the following events:
A COMMIT or ROLLBACK statement is issued
A DDL or DCL statement executes (automatic commit)
The user exits iSQL*Plus
The system crashes
A.N.M. Bazlur Rashid, Assistant Professor (Computer) & Head, Department of Allied Engineering, Bangladesh University of Textiles / Page 23 of 28
Application of Computer in Yarn/Fabric/Wet/Apparel/Management Lecture # Database Management System
UPDATE...
SAVEPOINT update_done;
Savepoint created.
INSERT...
ROLLBACK TO update_done;
Rollback complete.
A.N.M. Bazlur Rashid, Assistant Professor (Computer) & Head, Department of Allied Engineering, Bangladesh University of Textiles / Page 24 of 28
Application of Computer in Yarn/Fabric/Wet/Apparel/Management Lecture # Database Management System
Committing Data
Make the changes.
COMMIT;
Commit complete.
ROLLBACK;
Rollback complete.
Statement-Level Rollback
If a single DML statement fails during execution, only that statement is rolled back.
The Oracle server implements an implicit save point.
All other changes are retained.
The user should terminate transactions explicitly by executing a COMMIT or ROLLBACK statement.
Read Consistency
Read consistency guarantees a consistent view of the data at all times.
Changes made by one user do not conflict with changes made by another user.
Read consistency ensures that on the same data:
Readers do not wait for writers.
Writers do not wait for readers.
A.N.M. Bazlur Rashid, Assistant Professor (Computer) & Head, Department of Allied Engineering, Bangladesh University of Textiles / Page 25 of 28
Application of Computer in Yarn/Fabric/Wet/Apparel/Management Lecture # Database Management System
Database Connectivity
Oracle provides Oracle Net Services which is a suite of components that provides a connectivity solution.
Oracle Net Service consist of
Oracle Net - software component that initiates, establishes and maintains connections between client
and servers, it contains two components
o oracle network foundation layer - responsible for establishing and maintaining connections
o oracle support protocol - responsible for mapping Transparent Network Substrate (TNS)
Oracle Net Listener - Listens for incoming requests from users
Oracle Connection Manager - GUI based utility
Oracle Net Configuration Assistant - GUI based utility , configure network components
Oracle Net Manager - GUI based utility, configures various naming methods and listeners
Oracle Enterprise Manager - can do everything
Connection
You need two pieces of information to connect to a database
Name of the database server - name of the service that oracle is supplying
Location of the address - need to supply the protocol type (default TCP) , hostname and the port
number (default 1521)
Oracle supports a number of protocols TCP, SDP, TCP with secure sockets and named pipes. There are two
ways to connect to oracle dedicated or Shared Server, both could be running at the same time on the same
server. There are 4 connection types
Dedicated - direct handoff (client and server are on the same computer)
Dedicated - redirect (client and server are on different computers)
Shared server - direct handoff (client and server are on the same computer)
Shared server - redirect (client and server are on different computers)
Listener
Oracle listener only runs on the server and listens for incoming client connections, a utility called lsnrctl is used
to manage the listener process. The listeners role is
The database registers information about the services, instances and service handlers with the listener
The client makes the initial connection with the listener
The listener receives and verifies the connection and forwards it to the service handler, once the
listener hands off the request, the listener is out of the picture.
A.N.M. Bazlur Rashid, Assistant Professor (Computer) & Head, Department of Allied Engineering, Bangladesh University of Textiles / Page 26 of 28
Application of Computer in Yarn/Fabric/Wet/Apparel/Management Lecture # Database Management System
The listener.ora file contains the listener configuration details, with oracle 10g the listener can automatically register
itself with the database, The PMON process updates the listener.ora file with any new databases.
A.N.M. Bazlur Rashid, Assistant Professor (Computer) & Head, Department of Allied Engineering, Bangladesh University of Textiles / Page 27 of 28
Application of Computer in Yarn/Fabric/Wet/Apparel/Management Lecture # Database Management System
The sqlnet.ora file specifies which order to try (bit like the nsswitch.conf file in unix)
NAMES.DIRECTORY_PATH=(TNSNAMES,EZCONNECT,HOSTNAME)
sqlnet.ora
NAMES.DEFAULT_DOMAIN=DATADISK.CO.UK
File locations
adaptors $oracle_home/bin/adapters
listener $oracle_home/network/admin/listener.ora
tnsnames $oracle_home/network/admin/tnsnames.ora
sqlnet $oracle_home/network/admin/sqlnet.ora
listener log $oracle_home/network/log.listener.log
server tracing $oracle_home/network/trace/listener.trc
A.N.M. Bazlur Rashid, Assistant Professor (Computer) & Head, Department of Allied Engineering, Bangladesh University of Textiles / Page 28 of 28