SlideShare a Scribd company logo
1 of 94
Database Overview
At a Glance
• Terminology and Characteristics of Database
• Introduction to RDBMS
• Types of DBMS
• Database Security and Recovery
• Data Mining, Data Warehousing & Data Marts
• SQL Overview
• JDBC
• Indexes
• Clustered & Non-Clustered Indexes
• Failure Management with DB2 Cluster Services
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
2 of 94
Database Terminology (1/7)
• Data vs. Information
– Data are chunks of information about a particular system.
• E.g. Normal temperature of human body is 98.4°F and No. of
subjects studied by a student are data.
– Data by itself does not have any meaning (Raw data).
– Information is the interpretation and understanding of data.
• Data Handling
– Process to obtain facts include:
• Data Collection + Data Organization + Data Analysis + Depiction
of facts (graphs, charts, etc.)
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
4 of 94
Database Terminology (2/7)
• Data Organization
– Method of classifying and organizing data sets to make them
more useful.
• Need of Organization – Case Study
– Consider the marks scored by 25 students out of 50 in a
Computer exam are arranged as follows:
26, 15, 40, 18, 26, 24, 48, 40, 39, 26, 23, 37, 38, 40, 45, 48.
– Discussion:
• The above form of data representation becomes confusing if the
number of students increases to 1000.
• If the above data can be organized in form of a table, then this
form of representation is easy to interpret and to analyze the
data (E.g. Finding students with >90% marks).
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
5 of 94
Database Terminology (3/7)
• Need of Organization (contd.)
– Volume of data increases with time.
– Data organization may initially take some time. But once data
is organized, in future it would help us to search and retrieve
the required information in minimal time.
– Data organization can be of various types, depending on the
requirement of the user. For example:
• The repeated values in the data are collected together to know
the mode of the data.
• The data is organized in increasing or decreasing order, to find
the median of the given set of data.
– Organizing data would reduce data loss and errors.
– Helps us understand the purpose of data collection and
provides insight about the proper use of it.
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
6 of 94
Database Terminology (4/7)
• Methods of Data Organization (1/3)
– Characters
• Basic elements/symbols (Digit, Letter, special character) of data.
– Fields
• Data Items (Attributes of an Entity) composed with characters or
related words.
• Natural and Artificial (fact-less) Attributes
– Record
• Collection of fields (tuple) related to an entity.
– Database File or Table (relations)
• Collection of related records.
• Classification
– Based on purpose or intended application. E.g. Inventory File.
– Based on Degree of permanence (Temporary/Permanent).
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
7 of 94
Database Terminology (5/7)
• Methods of Data Organization (2/3)
– Key
• Unique Identifier to a particular record on each table. Such keys
are called primary keys.
• Primary key should always have a constant value. Number types
are preferred over text type.
– It is better to have artificial attribute serve as primary key (surrogate
key) rather than natural attribute.
• A composite primary key is a key made up of two or more
attributes
• Primary keys within a database are used to define relationships
among the tables. Rows in a table can be linked to rows in other
tables by adding a column for the unique key of the linked row.
Such columns are known as foreign keys (A field in a relational
table that matches the primary key column of another table).
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
8 of 94
Database Terminology (6/7)
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
• “Person” table with primary key “PersonID”
• “Order” table with primary key “OrderID” and foreign key
“PersonID"
PersonID LastName FirstName Age
1 Hansen Ola 30
2 Svendson Tod 23
3 Pettersen Kat 20
OrderID OrderNumber PersonID
1 77895 3
2 44678 3
3 22456 2
4 24562 1
9 of 94
Database Terminology (7/7)
• Methods of Data Organization (3/3)
– Database
• Collection of related files/tables that are consolidated, organized,
linked or cross-referenced to one another and stored together.
• Databases are usually customized to suit a particular application.
No two customized applications are alike, and hence, no two
database are alike.
• Computerized databases are more useful than manila folders and
filing cabinets.
– Database Management System (DBMS)
• Specialized database management software or Database
manager used to organize and retrieve data and records
contained in database files.
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
10 of 94
Characteristics of Databases (1/2)
• Small vs. Large Databases
– Small Databases are stored in a desktop computer.
• DBMS used:
– Microsoft Access, Paradox, dBASE 5
– Large Databases are specialized public databases stored on
network servers or powerful mainframe computers.
• Provides online access (Information Utilities or Online services)
for a fee
• DBMS used:
– Oracle RDBMS, Microsoft SQL Server, IBM DB2, Teradata (VLDB),
SAP ASE (Sybase), PostgreSQL (ORDBMS), MariaDB Enterprise,
MySQL, MongoDB (NoSQL)
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
11 of 94
Characteristics of Databases (2/2)
• Database Access
• Database Attributes for Effective use
– Keep some tables separate?
• More efficient & effective search/retrieval from smaller data sets.
• Only the required data sets can be accessible to certain groups of
people to maintain some degree of security and personal privacy.
• Multiple Sources
– Minimal redundancy between the files in a database.
– Linking together data from multiple sources to accomplish a
specific task.
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
12 of 94
Fundamentals (1/3)
• Computerized File Management systems (File Managers) are
not considered as true DBMS.
– Files are independent & cannot be linked.
– Used for storing information in files.
– E.g. Mailing List, Address Book
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
14 of 94
Fundamentals (2/3)
• Advantages
– Improved availability to different users
– Minimized redundancy and more concise
• Contrast: Data fields
– Accuracy
• Integrity => Accurate + Consistent + Up-to-date
– Program and File Consistency
• Easier to maintain multiple types of data
• Easier to manage data, even with multiple programmers
– User-friendly
• Ease to access & manipulate
– Improved security
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
15 of 94
Fundamentals (2/3)
• Disadvantages
– Cost
• Expensive & Time consuming – Includes implementation &
training requirements.
– Security
• Degree if breach & Threat to privacy
• Need of Backups
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
16 of 94
Database Models (1/7)
• Hierarchical Database Model (1/3)
– Developed by IBM in 1960 as a Tree-like structure commonly
used on mainframe computers.
– Schema has single root & hence functions top to bottom.
– Each record has one parent record and many children
– Links (from child) are used to connect the Records & the
relationships between Records should be defined prior
• Parent-Child Relationships are of type 1:N. For relationships of
type M:N duplication of child record is required.
• Higher & Lower level records, Parent/Root & Child records
– Examples
• IBM Information Management System (IMS), MUMPS
– Applications
• File Systems, GIS, Banking and Telecommunication
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
17 of 94
Database Models (2/7)
• Hierarchical Database Model (2/3)
– Example for Hierarchical Data represented as Relational tables
– Advantages: High performance.
– Disadvantages:
• Relationships/linkages between children are not permitted
• Rigid/Inflexible Design
• Designed in advance
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
18 of 94
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
Hierarchical Schema
Hierarchical Occurrence Tree
19 of 127
Database Models (4/7)
• Network Database Model (1/2)
– Invented by Charles Bachman, and it was developed into a
standard specification published in 1969 by the Conference on
Data Systems Languages (CODASYL) Consortium
– Has Hierarchical generalized graph structure with few
variations used on mainframe computers
• Depicted as interconnected network of records.
• Each record can have multiple parents (owners) and child records
(Members)
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
20 of 94
Database Models (5/7)
• Network Database Model (2/2)
– Requires user to pass down through a hierarchy in order to
access data.
– Example
• Integrated Data Store (IDS), Integrated DBMS, TurboIMAGE
– Advantage: Flexible
– Disadvantages
• Limited no. of connections between records.
• Designed in advance.
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
21 of 94
Database Models (6/7)
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
• Relational Database Model
– 1970, Invented by Edgar Frank Codd (of IBM).
– Consists of cross-linked (relational) files/tables.
• Use of common data elements or key field.
– Example
• IBM DB2, IBM Informix, Oracle, Microsoft SQL Server.
– Advantage
• More Flexible thane Network and Hierarchical Models.
• Can be used with little/no training.
• Database entries can be modified without redefining the entire
structures.
– Disadvantage: Searching can take more time comparatively.
22 of 94
Database Models (7/7)
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
• Object Oriented Database Model
– Combines database capabilities with OOP language capability
by representing information as Objects, which consist of data
& instructions to handle data (methods).
– Used to handle structured data and new multimedia data
types (Audio, Video, Pictures, etc.).
– Disadvantages
• Costly to develop, Migration to OODBMS is mostly debated.
– Application: Healthcare
23 of 94
Database Security & Recovery
• Database Security
– Protection from unauthorized use and sabotage.
– Degree of Access
• Privileges to view, retrieve, and modify.
– Physical Protection
– Threats to data security
• Human error, hardware/software/DB failure, theft and fraud, loss
of personal/corporate data, loss of data/corporate integrity, loss
of availability, loss of backups, etc.
• Data Recovery
– Backup & Recovery includes
• Journalizing facility, DB change logs, Transactions logs,
checkpoint facility, etc.
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
25 of 94
Strategies of Data Recovery
• Mirroring
– Making frequent simultaneous copies of a DB in different
locations.
– Expensive
– Used by Ticketing systems
• Reprocessing
– Reverting back to a known point of DB activity prior to
failure/problem
– Time consuming & incur delay till DB is made available.
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
26 of 94
Data Warehousing (1/5)
• Conceptualized by Bill Inmon, 1990
• Data repository which mostly includes historical data and
data from several diverse sources.
• Organizations mostly have Evaluational & Operational
databases.
– OLAP tools can be used to provide business intelligence
(analyze business) and OLTP tools provide data entry and
retrieval transaction processing (run business).
• Features of Data warehouses
– Constructed by integrating data from heterogenous sources
– Provides information of a particular time period.
– Non-volatile and separated from operational DB.
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
28 of 94
Data Warehousing (2/5)
• Like a database a data warehouse also requires to maintain a
logical description (Schema)
– Operational databases is based on ER Model
– Data warehouse (Evaluational database) is based on Schema
– Types of Schema
• Star Schema
• Snowflake Schema
• Fact constellation or Galaxy Schema
– Data warehouse Schema can be defined using DMQL.
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
29 of 94
Data Warehousing (3/5)
• Example: Star Schema
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
30 of 94
Data Warehousing (4/5)
• Example: Snowflake Schema
– Redundancy is reduced by splitting the dimension tables.
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
31 of 94
Data Warehousing (5/5)
• Example: Fact Constellation or Galaxy Schema
– Consists of more number of Fact tables.
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
32 of 94
Data Mining
• Patented by HNC Software Inc., San Diago in 1980s
• Knowledge Discovery from a Data warehouse
– Finding patterns, trends & correlations ease understanding and
decision making.
– Knowledge can be used for prediction (as in Businesses).
• Applications (Discussion)
– Online and Retail store
– Telecommunication
– Hospitals
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
33 of 94
Data Marts (1/5)
• Groups related data sets for specific sets of customers.
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
34 of 94
Data Marts (2/5)
• Why Data Mart?
– Maintain temporary copy of data from few fact tables which
does not change frequently for analysis. It is discarded after
analysis.
– Decrease load on a Data warehouse by making a copy of fact
tables in separate server. Refreshed periodically.
– Simulation of new scenarios by changing data.
• Data in a Data warehouse cannot be changed without affecting
performance.
• Star schema offers ease of design
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
35 of 94
Data Marts (3/5)
• Type-1: Dependent data mart
– Data from Data warehouse are
aggregated, restructured &
summarized with Enterprise context.
– Built to achieve improved
performance and availability, better
control, & lower telecommunication
costs resulting from local access of
data relevant to a specific
department.
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
36 of 94
Data Marts (4/5)
• Type-2: Independent data mart
– No centralized data warehouse.
– Number of sources are few.
– All aspects of the ETT process
(Extract, transform, transfer) should
be dealt.
– Preferred when a solution is required
within a shorter time.
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
37 of 94
Data Marts (5/5)
• Type-3: Hybrid data mart
– Combine input from sources
other than a data warehouse
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
38 of 94
Introduction (1/5)
• Developed by Donald D. Chamberlin & Raymond Boyce in
IBM, early 1970s.
• SQL (earlier SEQUEL) is a high level language which provides
practical implementation of Codd’s relational model.
– i.e. Store, manipulate and retrieval of data stored in a
relational database.
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
40 of 94
Introduction (2/5)
• ANSI standard (1986) & ISO standard (1987).
• Since standardization SQL standards have been updated 6
times. Version 5.1 is the latest update in Nov. 2008.
• Note:
– 1979, Larry Ellison, Bob Miner and Ed Oates developed SQL-
based RDBMS named Oracle in Relational Software Inc. (now
Oracle Corp.).
• Versions: Oracle 12c/11g/10g/9i/8i, etc.
– Versions and Editions of MS SQL Server.
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
41 of 94
Introduction (3/5)
• SQL Architecture
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
42 of 94
Introduction (4/5)
• SQL Commands can be classified into 4 groups based on
functionality
– DDL: Deals with schemas and descriptions of how data should
reside in a DB.
• E.g. Create, Alter, Drop, Truncate, Rename, etc.
– DML: Deals with reading and modifying of data.
• E.g. Select, Insert, Update, Delete, etc.
– DCL: Concerned with rights, permissions and other controls.
• E.g. Grant, Revoke
– DCL: Deals with transactions within a database.
• E.g. Commit, Rollback, Savepoint, etc.
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
43 of 94
Introduction (5/5)
• Database Normalization
– Efficiently organizing data in DB without redundancy and with
required data dependencies.
– Consists of series of guidelines (known as forms). i.e. 1NF, 2NF,
etc.
• SQL-RDMS Concepts
– Table
– Field, Column and Records.
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
44 of 94
SQL Data Types (1/7)
• Specifies the type of data of any object.
• Categories
– Exact and Approximate Numeric
– Date and Time
– Unicode and Non-Unicode Character Strings
– Binary
– Miscellaneous
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
45 of 94
SQL Data Types (2/7)
• Exact Numeric Data Types
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
46 of 94
SQL Data Types (3/7)
• Approximate Numeric Data Type
• Date and Time Data Type
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
47 of 94
SQL Data Types (4/7)
• Character String Data Type
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
48 of 94
SQL Data Types (5/7)
• Unicode Character String Data Type
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
49 of 94
SQL Data Types (6/7)
• Binary Data Type
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
50 of 94
SQL Data Types (7/7)
• Miscellaneous Data Type
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
51 of 94
SQL Operators (1/5)
• Operators
– Reserved word/character that specify conditions or serve as
conjunctions to multiple conditions in a SQL statement's
WHERE clause to perform operation(s).
– Categories
• Arithmetic Operators & Comparison Operators
• Logical Operators: ALL, AND, ANY, BETWEEN, EXISTS, IN, LIKE,
NOT, OR, IS NULL, UNIQUE, Negation
• String Manipulation: CONCATENATE, LENGTH, SUBSTRING
• Grouping: COUNT
– Can be used with GROUP BY statement.
– Performs on 2/more rows and provides a summarized result set.
• Aggregate: COUNT, SUM, AVERAGE, MINIMUM, MAXIMUM.
– Can be used with GROUP BY statement.
– Performs on 2/more tuples/rows and returns a scalar result set.25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
52 of 94
SQL Operators (2/5)
• Wild Card operators
– Percentage (%) - 0/1/more characters
– Underscore ( _ ) represents single number/character.
• Miscellaneous operators: DISTINCT
• SQL Expressions
– Combination of one or more values, operators or SQL
functions that evaluate to a value.
– Types: Boolean (Single value matching), Numeric, Date
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
53 of 94
SQL Operators (3/5)
• Union Operator
– Join two data sets having same column definitions in the same
order. Removes duplicate rows from resulting data set.
– UNION ALL can be used to return all data sets with duplicates
in the result set.
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
54 of 94
SQL Operators (4/5)
• Intersection (INTERSECT) Operator
– Returns a result set common to both data sets. Common data
sets are listed only once even if there are multiple duplicate
rows in either of the table.
– INTERSECT ALL can be used to return all data sets with
duplicates in the result set.
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
55 of 94
• Difference (EXCEPT) Operator
– Returns the result set that exists only in the left table but not
in right table. Common data sets are listed only once even if
there are multiple duplicate rows in left table.
– EXCEPT ALL can be used to return all data sets with duplicates
in the result set.
SQL Operators (5/5)
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
56 of 94
SQL Syntax
• SQL statements
– Start with keyword and End with semi-colon.
– Not case-sensitive.
• Clauses
– Distinct, where, and/or, in, between, like, order by, group by,
count, having
• Refer the Word Doc for the Discussion on SQL commands
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
57 of 94
SQL Constraints (1/5)
• Constraints enforce certain rules to limit the type of data
inserted into a table so as to ensure accuracy and reliability
of data in DB.
– Column level Constraints & Table level Constraints.
• Constraints can be specified during table creation and can be
altered after creation.
• DEFAULT constraint
– Auto-repeat the same specified default value for all records in
a column.
– Used to insert system values, by using functions like GETDATE()
• Auto-increment fields
– IDENTITY property auto generates values for all records in a
column. These values are not guaranteed to be unique.
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
58 of 94
SQL Constraints (2/5)
• NOT NULL constraint
– A field which can be left blank during record creation is
considered to take a NULL value (default).
– In certain cases tables are created with mandatory (NOT NULL)
fields which should take a value while record creation or
updation.
• CHECK constraint
– Ensures that the concerned field can take only those values
which satisfy the rules specified.
– New constraint can be defined to evaluate values of multiple
columns.
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
59 of 94
SQL Constraints (3/5)
• UNIQUE constraint
– Ensures that all values in a column(s) are unique/different (no
repetition).
– NULL is also a part of UNIQUE data values domain.
• PRIMARY KEY constraint
– Can take unique values and cannot take NULL value.
– Has an index associated with it, using which, it uniquely
identifies each record in a table.
– A new Primary key constraint can be defined using one or
multiple columns.
– Automatically has a UNIQUE constraint.
• Note: A table can have multiple UNIQUE constraints, but
only one PRIMARY KEY constraint.
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
60 of 94
SQL Constraints (4/5)
• FOREIGN Key constraint
– Foreign key is a field(s) in one table (i.e. child) that refers to
the primary key in another table (i.e parent).
– Used to link two tables together.
– Handling deletion and updation on linked tables.
• Options
– Delete Action: Cascade, Set null, No Action, Restrict
– Update Action: No Action, Restrict
• CASCADE
– Operation is cascaded to all rows in the child tables that reference
the row/value to be modified/deleted in parent table.
• SET NULL
– All referring cells in child tables are set to NULL.
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
61 of 94
SQL Constraints (5/5)
• INDEX constraint
– Column(s) of a table can be indexed for fast data retrieval and
speedy searches.
• Create indexes on column(s) which are frequently searched as
updating a table with indexes takes more time than updating a
table without indexes (because the indexes also need an update).
– Indexes can be made unique (with UNIQUE constraint).
– Indexes are invisible to the users.
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
62 of 94
Sub-Queries (1/2)
• Queries can be nested.
– Outer query is referred as Main/Parent Query & the inner
query is referred as Sub-Query.
• Sub-Queries are executed first.
• Correlated sub-query
– Sub-Query is executed for each row of parent table instead of
once.
• Sub-Query can also be used in FROM clause.
• Sub-Queries may return Scalar value
– Returns single value of any attribute.
– Example
• SQL> SELECT name FROM student_enrollment WHERE age =
(SELECT min(age) FROM students);
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
63 of 94
Sub-Queries (2/2)
• Sub-Queries may return Vector values
– Returns data set representing multiple values for a column or
array of values for multiple columns.
– Example
• SQL> SELECT name FROM students WHERE course_enrolled IN
(SELECT distinct course_name FROM courses WHERE
department_name = ‘CSE’);
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
64 of 94
Views & Cursors
• Views
– A view is a virtual table (contains rows and columns) based on
the result-set of an SQL statement.
• The fields in a view are fields from one/more real tables in DB.
• Cursors
– It is a result set holding the result of a SELECT statement
– Widely used for fetching multiple rows from a table and
processing them inside applications.
– Syntax
– DECLARE <cursor_name> CURSOR [WITH RETURN <return target>]
<SELECT statement>;
– OPEN <cursor_name>;
– FETCH <cursor_name> INTO <variables>;
– CLOSE <cursor_name>;
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
65 of 94
Table Joins (1/6)
• JOIN clause combines rows from 2 or more tables based on a
related column between them.
• Types of Join
– (INNER) JOIN: Returns records that have matching values in
both tables
– LEFT (OUTER) JOIN: Return all records from the left table, and
the matched records from the right table
– RIGHT (OUTER) JOIN: Return all records from the right table,
and the matched records from the left table
– FULL (OUTER) JOIN: Return all records when there is a match in
either left or right table
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
66 of 94
Table Joins (2/6)
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
67 of 94
Table Joins (3/6)
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
68 of 94
Table Joins (4/6)
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
69 of 94
Table Joins (5/6)
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
70 of 94
Table Joins (6/6)
• Types of Inner Join
– Equi-join
• Based on equality of specified columns.
– Natural join
• Joining column does not require specification. System
automatically selects the column with same name in tables and
applies equality operation on it.
• Removes all duplicate attributes
– Cross join
• Cartesian product of tables to be joined.
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
71 of 94
Mapping of OO & Relational concepts
• Examples
– Hibernate
• Provides ORM (Object-Relational Mapping) libraries for Java.
– IBM pureQuery
• Eclipse IDE based, pluggable component that provide the design
& runtime means for managing relational data as objects.25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
72 of 94
What is JDBC?
• Std. Java API for DB independent connectivity between Java
based Executables & wide range of Databases.
– Executables include Applications, Applets, Servlets, JSPs, EJBs
• JDBC library includes APIs for the tasks associated with DB
usage
– DB connectivity
– Creating SQL/MySQL statements
– Execution of Queries in DB
– View & Modify resulting records
• Provides same capability as ODBC allowing Java programs to
contain DB-independent code.
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
74 of 94
JDBC Architecture
• Supports both 2-tier & 3-tier processing
models. In general has 2 layers
– JDBC API
– JDBC Driver API
• Supports multiple concurrent drivers
connected to heterogeneous DBs.
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
75 of 94
JDBC Components
• JDBC API provides following interfaces and classes
– DriverManager (Class)
• Manages list of DB drivers & provides DB connection
– Driver (Interface)
• Handles communication with DB Server. Driver objects are rarely
used directly. Instead DriverManager objects are used.
– Connection (Interface)
• Consists of methods for using the DB. These are accessed using
Connection object.
– Statement (Interface)
• Statement objects are used to submit Queries to DB.
– ResultSet (Object)
• Object holds the data retrieved from DB
– SQLException (Class)
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
76 of 94
Database APIs (1/4)
• Set of APIs that gives application developers a mechanism to
interact with DB from within the application dynamically.
• DB vendors provide different APIs wrt Languages.
• APIs are developed independent of DB and do not require
pre-compilation.
– Applications can be developed independently of target DBs
without need of DB connection at compilation phase.
• DB Connectivity Driver
– Serves as intermediate layer between Application & DB server.
– Driver libraries are linked with source code libraries, code is
compiled and later executed.
– E.g. ODBC & IBM Data Server CLI Driver
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
77 of 94
Database APIs (2/4)
• Callable SQL Interface
– DB vendors could provide connectivity drivers which are not
compatible with other DBs.
– Some level of standardization is required for increased
application portability.
– Few Standard Callable SQL Interface
• X/Open CLI, ODBC, IBM Data Server CLI Driver
• X/Open CLI (Call Level Interface)
– Developed by X/Open Company & SQL Access Group
– ISO CLI International Standard (ISO/IEC 9075-3: 1995 SQL/CLI)
• ODBC
– Developed by Microsoft based on preliminary draft of X/Open
CLI.
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
78 of 94
Database APIs (3/4)
• IBM Data Server CLI Driver
– DB2 CLI based on Microsoft ODBC spec. & SQL/CLI International
standard which includes DB2 specific extensions to exploit DB2
features.
– Conforms to ODBC 3.51 standard.
• i.e. Works equivalent to ODBC driver when loaded by an ODBC
Driver Manager.
– DB2 CLI is a C/C++ API for Relational DB access which uses fn.
call to pass dynamic SQL statements as function arguments.
• E.g. Callable Interfaces include SQLPrepare(), SQLConnect(),
SQLFetch(), SQLExecute()
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
79 of 94
Database APIs (4/4)
• Environments of Microsoft ODBC & IBM DB2 CLI
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
80 of 94
What is Index? (1/2)
• An Index is a set of pointers logically ordered by the value of
one/more keys.
– Columns in an index are known as keys.
– Keys can be unique or non-unique. But a table should have at
least one unique key.
• Why to Index?
– Improve Performance with quick data access.
– Ensure Uniqueness in identifying rows (records).
– Sequencing rows according to the values in column.
• Index can refers to rows in a table, block in a Cluster table,
XML data in an XML storage object
– Cluster table indexes & XML indexes are system generated.
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
82 of 94
What is Index? (2/2)
• Relationship between an index and a table
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
83 of 94
Database partitioning (1/3)
• Relationships among selected database objects
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
84 of 94
Database partitioning (2/3)
• DB partition group
– Set of one/more DB partitions that belong to a database.
• Table spaces (1/2)
– Specifies where data in a DB is physically stored on a system.
• Data includes tables, Indexes, Large objects (LOB: 8-128TB)
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
85 of 94
Database partitioning (3/3)
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
• Table spaces (2/2)
– Defines how data for a table is distributed across DB partitions
in a DB partition group.
– Single table can span several containers (disk).
– DB manager balances the data load across containers.
• Extent Size: No. of pages that DB manager writes to a container
before using a different container. 86 of 94
Types of Indexes (1/3)
• Indexes on Partitioned Tables within a database partition
– Indexes are non-partitioned & exists in a single table space.
– Indexes are partitioned & exists across one/more table spaces.
– Combination of the above.
• Commands to handle Indexes (Create/Modify/Remove)
– CREATE INDEX statement, ALTER INDEX command, DROP
statement, IBM db2advis Design Advisor commands.
• Classification of Index Architecture
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
Index
Architecture
Clustered
Index
Architecture
Non-Clustered
Index
Architecture
87 of 94
Types of Indexes (2/3)
• Clustered Indexes
– Defines the order in which data is physically stored in a table.
– There can be only one clustered index per table.
• In SQL Server, the primary key constraint automatically creates a
clustered index on that particular column in ascending order.
• Only one index in table has high degree of clustering.
– Data Manager keeps the data in data pages in the same order
as the corresponding keys in index page.
– Reorganizing a table with a chosen index will re-cluster data.
– Clustered index allows better sequential access of data as rows
with similar index key values are stored together.
– Statements
• CREATE INDEX statement with CLUSTER option specified.
• ALTER TABLE statement – add primary key that corresponds to
clustering index.
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
88 of 94
Types of Indexes (3/3)
• Non-Clustered Indexes
– Resembles the words index at the back of a book. i.e.
Structured in a way that does not correspond to the order of
the actual data records.
– Many non-clustered indexes can exist per table.
– Data Manager does not maintain any order of the data when
compared to the order of the corresponding keys.
– Non-clustered indexes are slower than clustered indexes.
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
89 of 94
DB2® cluster services
• Provides auto heartbeat failure detection & auto initiation of
recovery options after a failure is detected.
• Provides cluster file system that provides each host in DB2
pureScale® instance access to a common file system.
• Includes technology from following IBM® softwares:
– Tivoli® System Automation for Multi-platforms (Tivoli SA MP)
– Reliable Scalable Clustering Technology (RSCT)
– General Parallel File System (GPFS ™) Software
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
91 of 94
Failure Management
• Automated cluster caching facility (CF) failover
– When Primary cluster CF fails, DB2 cluster services
automatically attempts to restart it while Secondary cluster CF
takes over.
• Automated restart
– DB2 cluster services detects Software and Hardware failure,
and initiates a member/group restart depending on the type
of failure.
• Manual intervention in failure situations
– DB2 cluster services automatically initiates the required type
of restart or crash recovery. However, human intervention is
required at times to restart or crash recovery and take steps to
complete group crash recovery.
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
92 of 94
Peep into the next Module
• Storage Overview
– Storage Networking Technology
– Types of Storage System
– Fiber Channel Arbitrated Loop
– Fabric
– SANs
– Zoning
– Storage Virtualization
25-Aug-2017
CSIT1002
Instructor: Mr.S.Christalin Nelson|SoCSE|UPES
93 of 94
Database overview

More Related Content

What's hot

Data Modeling - Enhanced ER diagrams & Mapping.pdf
Data Modeling - Enhanced ER diagrams & Mapping.pdfData Modeling - Enhanced ER diagrams & Mapping.pdf
Data Modeling - Enhanced ER diagrams & Mapping.pdfChristalin Nelson
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management systemChristalin Nelson
 
Database administration and security
Database administration and securityDatabase administration and security
Database administration and securityDhani Ahmad
 
Advanced data modeling
Advanced data modelingAdvanced data modeling
Advanced data modelingDhani Ahmad
 
Chapter – 4 Normalization and Relational Algebra.pdf
Chapter – 4 Normalization and Relational Algebra.pdfChapter – 4 Normalization and Relational Algebra.pdf
Chapter – 4 Normalization and Relational Algebra.pdfTamiratDejene1
 
Introduction to structured query language (sql)
Introduction to structured query language (sql)Introduction to structured query language (sql)
Introduction to structured query language (sql)Dhani Ahmad
 
Database systems - Chapter 1
Database systems - Chapter 1Database systems - Chapter 1
Database systems - Chapter 1shahab3
 
Advance database systems (part 1)
Advance database systems (part 1)Advance database systems (part 1)
Advance database systems (part 1)Abdullah Khosa
 
Data Warehouse Fundamentals
Data Warehouse FundamentalsData Warehouse Fundamentals
Data Warehouse FundamentalsRashmi Bhat
 
Basic oracle-database-administration
Basic oracle-database-administrationBasic oracle-database-administration
Basic oracle-database-administrationsreehari orienit
 
Introduction To Database Management System
Introduction To Database Management SystemIntroduction To Database Management System
Introduction To Database Management Systemcpjcollege
 
Database Systems
Database SystemsDatabase Systems
Database SystemsUsman Tariq
 

What's hot (20)

Data Modeling - Enhanced ER diagrams & Mapping.pdf
Data Modeling - Enhanced ER diagrams & Mapping.pdfData Modeling - Enhanced ER diagrams & Mapping.pdf
Data Modeling - Enhanced ER diagrams & Mapping.pdf
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management system
 
Storage system architecture
Storage system architectureStorage system architecture
Storage system architecture
 
Sql commands
Sql commandsSql commands
Sql commands
 
Database administration and security
Database administration and securityDatabase administration and security
Database administration and security
 
Advanced data modeling
Advanced data modelingAdvanced data modeling
Advanced data modeling
 
normaliztion
normaliztionnormaliztion
normaliztion
 
Chapter – 4 Normalization and Relational Algebra.pdf
Chapter – 4 Normalization and Relational Algebra.pdfChapter – 4 Normalization and Relational Algebra.pdf
Chapter – 4 Normalization and Relational Algebra.pdf
 
DATA WAREHOUSING
DATA WAREHOUSINGDATA WAREHOUSING
DATA WAREHOUSING
 
Introduction to structured query language (sql)
Introduction to structured query language (sql)Introduction to structured query language (sql)
Introduction to structured query language (sql)
 
Database systems - Chapter 1
Database systems - Chapter 1Database systems - Chapter 1
Database systems - Chapter 1
 
Advance database systems (part 1)
Advance database systems (part 1)Advance database systems (part 1)
Advance database systems (part 1)
 
Data Warehouse Fundamentals
Data Warehouse FundamentalsData Warehouse Fundamentals
Data Warehouse Fundamentals
 
Basic oracle-database-administration
Basic oracle-database-administrationBasic oracle-database-administration
Basic oracle-database-administration
 
Introduction to Data Warehousing
Introduction to Data WarehousingIntroduction to Data Warehousing
Introduction to Data Warehousing
 
Directory services
Directory servicesDirectory services
Directory services
 
Introduction To Database Management System
Introduction To Database Management SystemIntroduction To Database Management System
Introduction To Database Management System
 
Data warehouse
Data warehouseData warehouse
Data warehouse
 
Database Systems
Database SystemsDatabase Systems
Database Systems
 
Data models
Data modelsData models
Data models
 

Similar to Database overview

Ch 2-introduction to dbms
Ch 2-introduction to dbmsCh 2-introduction to dbms
Ch 2-introduction to dbmsRupali Rana
 
Database Systems - Lecture Week 1
Database Systems - Lecture Week 1Database Systems - Lecture Week 1
Database Systems - Lecture Week 1Dios Kurniawan
 
Modern Database Systems - Lecture 00
Modern Database Systems - Lecture 00Modern Database Systems - Lecture 00
Modern Database Systems - Lecture 00Michael Mathioudakis
 
Database Management Systems 1
Database Management Systems 1Database Management Systems 1
Database Management Systems 1Nickkisha Farrell
 
Chapter 9 Data Design .pptxInformation Technology Project Management
Chapter 9 Data Design .pptxInformation Technology Project ManagementChapter 9 Data Design .pptxInformation Technology Project Management
Chapter 9 Data Design .pptxInformation Technology Project ManagementAxmedMaxamuudYoonis
 
Sql server ___________session_1-intro
Sql server  ___________session_1-introSql server  ___________session_1-intro
Sql server ___________session_1-introEhtisham Ali
 
2 introductory slides
2 introductory slides2 introductory slides
2 introductory slidestafosepsdfasg
 
3.1 Database structure - designing a system.ppt
3.1 Database structure - designing a system.ppt3.1 Database structure - designing a system.ppt
3.1 Database structure - designing a system.pptAghaSyedNaqvi
 
PPT-UEU-Basis-Data-Pertemuan-1.pptx
PPT-UEU-Basis-Data-Pertemuan-1.pptxPPT-UEU-Basis-Data-Pertemuan-1.pptx
PPT-UEU-Basis-Data-Pertemuan-1.pptxUbaidURRahman78
 
IS740 Chapter 05
IS740 Chapter 05IS740 Chapter 05
IS740 Chapter 05iDocs
 
vdocuments.mx_chapter-2-database-environment-thomas-connolly-carolyn-begg-dat...
vdocuments.mx_chapter-2-database-environment-thomas-connolly-carolyn-begg-dat...vdocuments.mx_chapter-2-database-environment-thomas-connolly-carolyn-begg-dat...
vdocuments.mx_chapter-2-database-environment-thomas-connolly-carolyn-begg-dat...adeel8937
 

Similar to Database overview (20)

Ch 2-introduction to dbms
Ch 2-introduction to dbmsCh 2-introduction to dbms
Ch 2-introduction to dbms
 
Introduction to Databases by Dr. Kamal Gulati
Introduction to Databases by Dr. Kamal GulatiIntroduction to Databases by Dr. Kamal Gulati
Introduction to Databases by Dr. Kamal Gulati
 
Rdbms
RdbmsRdbms
Rdbms
 
DBMS introduction
DBMS introductionDBMS introduction
DBMS introduction
 
Database Systems - Lecture Week 1
Database Systems - Lecture Week 1Database Systems - Lecture Week 1
Database Systems - Lecture Week 1
 
lecture 1.pdf
lecture 1.pdflecture 1.pdf
lecture 1.pdf
 
Modern Database Systems - Lecture 00
Modern Database Systems - Lecture 00Modern Database Systems - Lecture 00
Modern Database Systems - Lecture 00
 
Database Management Systems 1
Database Management Systems 1Database Management Systems 1
Database Management Systems 1
 
Data Structures.ppt
Data Structures.pptData Structures.ppt
Data Structures.ppt
 
Chapter 9 Data Design .pptxInformation Technology Project Management
Chapter 9 Data Design .pptxInformation Technology Project ManagementChapter 9 Data Design .pptxInformation Technology Project Management
Chapter 9 Data Design .pptxInformation Technology Project Management
 
Sql server ___________session_1-intro
Sql server  ___________session_1-introSql server  ___________session_1-intro
Sql server ___________session_1-intro
 
2 introductory slides
2 introductory slides2 introductory slides
2 introductory slides
 
3.1 Database structure - designing a system.ppt
3.1 Database structure - designing a system.ppt3.1 Database structure - designing a system.ppt
3.1 Database structure - designing a system.ppt
 
PPT-UEU-Basis-Data-Pertemuan-1.pptx
PPT-UEU-Basis-Data-Pertemuan-1.pptxPPT-UEU-Basis-Data-Pertemuan-1.pptx
PPT-UEU-Basis-Data-Pertemuan-1.pptx
 
1_DBMS_Introduction.pdf
1_DBMS_Introduction.pdf1_DBMS_Introduction.pdf
1_DBMS_Introduction.pdf
 
DBMS
DBMS DBMS
DBMS
 
database1.pdf
database1.pdfdatabase1.pdf
database1.pdf
 
IS740 Chapter 05
IS740 Chapter 05IS740 Chapter 05
IS740 Chapter 05
 
vdocuments.mx_chapter-2-database-environment-thomas-connolly-carolyn-begg-dat...
vdocuments.mx_chapter-2-database-environment-thomas-connolly-carolyn-begg-dat...vdocuments.mx_chapter-2-database-environment-thomas-connolly-carolyn-begg-dat...
vdocuments.mx_chapter-2-database-environment-thomas-connolly-carolyn-begg-dat...
 
6.2 software
6.2 software6.2 software
6.2 software
 

More from Christalin Nelson (17)

Packages and Subpackages in Java
Packages and Subpackages in JavaPackages and Subpackages in Java
Packages and Subpackages in Java
 
Bitwise complement operator
Bitwise complement operatorBitwise complement operator
Bitwise complement operator
 
Advanced Data Structures - Vol.2
Advanced Data Structures - Vol.2Advanced Data Structures - Vol.2
Advanced Data Structures - Vol.2
 
Deadlocks
DeadlocksDeadlocks
Deadlocks
 
CPU Scheduling
CPU SchedulingCPU Scheduling
CPU Scheduling
 
Process Synchronization
Process SynchronizationProcess Synchronization
Process Synchronization
 
Process Management
Process ManagementProcess Management
Process Management
 
Applications of Stack
Applications of StackApplications of Stack
Applications of Stack
 
Data Storage and Information Management
Data Storage and Information ManagementData Storage and Information Management
Data Storage and Information Management
 
Application Middleware Overview
Application Middleware OverviewApplication Middleware Overview
Application Middleware Overview
 
Network security
Network securityNetwork security
Network security
 
System overview
System overviewSystem overview
System overview
 
Storage overview
Storage overviewStorage overview
Storage overview
 
Computer Fundamentals-2
Computer Fundamentals-2Computer Fundamentals-2
Computer Fundamentals-2
 
Computer Fundamentals - 1
Computer Fundamentals - 1Computer Fundamentals - 1
Computer Fundamentals - 1
 
Advanced data structures vol. 1
Advanced data structures   vol. 1Advanced data structures   vol. 1
Advanced data structures vol. 1
 
Programming in c++
Programming in c++Programming in c++
Programming in c++
 

Recently uploaded

Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 

Recently uploaded (20)

Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 

Database overview

  • 2. At a Glance • Terminology and Characteristics of Database • Introduction to RDBMS • Types of DBMS • Database Security and Recovery • Data Mining, Data Warehousing & Data Marts • SQL Overview • JDBC • Indexes • Clustered & Non-Clustered Indexes • Failure Management with DB2 Cluster Services 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 2 of 94
  • 3.
  • 4. Database Terminology (1/7) • Data vs. Information – Data are chunks of information about a particular system. • E.g. Normal temperature of human body is 98.4°F and No. of subjects studied by a student are data. – Data by itself does not have any meaning (Raw data). – Information is the interpretation and understanding of data. • Data Handling – Process to obtain facts include: • Data Collection + Data Organization + Data Analysis + Depiction of facts (graphs, charts, etc.) 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 4 of 94
  • 5. Database Terminology (2/7) • Data Organization – Method of classifying and organizing data sets to make them more useful. • Need of Organization – Case Study – Consider the marks scored by 25 students out of 50 in a Computer exam are arranged as follows: 26, 15, 40, 18, 26, 24, 48, 40, 39, 26, 23, 37, 38, 40, 45, 48. – Discussion: • The above form of data representation becomes confusing if the number of students increases to 1000. • If the above data can be organized in form of a table, then this form of representation is easy to interpret and to analyze the data (E.g. Finding students with >90% marks). 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 5 of 94
  • 6. Database Terminology (3/7) • Need of Organization (contd.) – Volume of data increases with time. – Data organization may initially take some time. But once data is organized, in future it would help us to search and retrieve the required information in minimal time. – Data organization can be of various types, depending on the requirement of the user. For example: • The repeated values in the data are collected together to know the mode of the data. • The data is organized in increasing or decreasing order, to find the median of the given set of data. – Organizing data would reduce data loss and errors. – Helps us understand the purpose of data collection and provides insight about the proper use of it. 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 6 of 94
  • 7. Database Terminology (4/7) • Methods of Data Organization (1/3) – Characters • Basic elements/symbols (Digit, Letter, special character) of data. – Fields • Data Items (Attributes of an Entity) composed with characters or related words. • Natural and Artificial (fact-less) Attributes – Record • Collection of fields (tuple) related to an entity. – Database File or Table (relations) • Collection of related records. • Classification – Based on purpose or intended application. E.g. Inventory File. – Based on Degree of permanence (Temporary/Permanent). 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 7 of 94
  • 8. Database Terminology (5/7) • Methods of Data Organization (2/3) – Key • Unique Identifier to a particular record on each table. Such keys are called primary keys. • Primary key should always have a constant value. Number types are preferred over text type. – It is better to have artificial attribute serve as primary key (surrogate key) rather than natural attribute. • A composite primary key is a key made up of two or more attributes • Primary keys within a database are used to define relationships among the tables. Rows in a table can be linked to rows in other tables by adding a column for the unique key of the linked row. Such columns are known as foreign keys (A field in a relational table that matches the primary key column of another table). 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 8 of 94
  • 9. Database Terminology (6/7) 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES • “Person” table with primary key “PersonID” • “Order” table with primary key “OrderID” and foreign key “PersonID" PersonID LastName FirstName Age 1 Hansen Ola 30 2 Svendson Tod 23 3 Pettersen Kat 20 OrderID OrderNumber PersonID 1 77895 3 2 44678 3 3 22456 2 4 24562 1 9 of 94
  • 10. Database Terminology (7/7) • Methods of Data Organization (3/3) – Database • Collection of related files/tables that are consolidated, organized, linked or cross-referenced to one another and stored together. • Databases are usually customized to suit a particular application. No two customized applications are alike, and hence, no two database are alike. • Computerized databases are more useful than manila folders and filing cabinets. – Database Management System (DBMS) • Specialized database management software or Database manager used to organize and retrieve data and records contained in database files. 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 10 of 94
  • 11. Characteristics of Databases (1/2) • Small vs. Large Databases – Small Databases are stored in a desktop computer. • DBMS used: – Microsoft Access, Paradox, dBASE 5 – Large Databases are specialized public databases stored on network servers or powerful mainframe computers. • Provides online access (Information Utilities or Online services) for a fee • DBMS used: – Oracle RDBMS, Microsoft SQL Server, IBM DB2, Teradata (VLDB), SAP ASE (Sybase), PostgreSQL (ORDBMS), MariaDB Enterprise, MySQL, MongoDB (NoSQL) 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 11 of 94
  • 12. Characteristics of Databases (2/2) • Database Access • Database Attributes for Effective use – Keep some tables separate? • More efficient & effective search/retrieval from smaller data sets. • Only the required data sets can be accessible to certain groups of people to maintain some degree of security and personal privacy. • Multiple Sources – Minimal redundancy between the files in a database. – Linking together data from multiple sources to accomplish a specific task. 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 12 of 94
  • 13.
  • 14. Fundamentals (1/3) • Computerized File Management systems (File Managers) are not considered as true DBMS. – Files are independent & cannot be linked. – Used for storing information in files. – E.g. Mailing List, Address Book 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 14 of 94
  • 15. Fundamentals (2/3) • Advantages – Improved availability to different users – Minimized redundancy and more concise • Contrast: Data fields – Accuracy • Integrity => Accurate + Consistent + Up-to-date – Program and File Consistency • Easier to maintain multiple types of data • Easier to manage data, even with multiple programmers – User-friendly • Ease to access & manipulate – Improved security 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 15 of 94
  • 16. Fundamentals (2/3) • Disadvantages – Cost • Expensive & Time consuming – Includes implementation & training requirements. – Security • Degree if breach & Threat to privacy • Need of Backups 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 16 of 94
  • 17. Database Models (1/7) • Hierarchical Database Model (1/3) – Developed by IBM in 1960 as a Tree-like structure commonly used on mainframe computers. – Schema has single root & hence functions top to bottom. – Each record has one parent record and many children – Links (from child) are used to connect the Records & the relationships between Records should be defined prior • Parent-Child Relationships are of type 1:N. For relationships of type M:N duplication of child record is required. • Higher & Lower level records, Parent/Root & Child records – Examples • IBM Information Management System (IMS), MUMPS – Applications • File Systems, GIS, Banking and Telecommunication 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 17 of 94
  • 18. Database Models (2/7) • Hierarchical Database Model (2/3) – Example for Hierarchical Data represented as Relational tables – Advantages: High performance. – Disadvantages: • Relationships/linkages between children are not permitted • Rigid/Inflexible Design • Designed in advance 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 18 of 94
  • 20. Database Models (4/7) • Network Database Model (1/2) – Invented by Charles Bachman, and it was developed into a standard specification published in 1969 by the Conference on Data Systems Languages (CODASYL) Consortium – Has Hierarchical generalized graph structure with few variations used on mainframe computers • Depicted as interconnected network of records. • Each record can have multiple parents (owners) and child records (Members) 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 20 of 94
  • 21. Database Models (5/7) • Network Database Model (2/2) – Requires user to pass down through a hierarchy in order to access data. – Example • Integrated Data Store (IDS), Integrated DBMS, TurboIMAGE – Advantage: Flexible – Disadvantages • Limited no. of connections between records. • Designed in advance. 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 21 of 94
  • 22. Database Models (6/7) 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES • Relational Database Model – 1970, Invented by Edgar Frank Codd (of IBM). – Consists of cross-linked (relational) files/tables. • Use of common data elements or key field. – Example • IBM DB2, IBM Informix, Oracle, Microsoft SQL Server. – Advantage • More Flexible thane Network and Hierarchical Models. • Can be used with little/no training. • Database entries can be modified without redefining the entire structures. – Disadvantage: Searching can take more time comparatively. 22 of 94
  • 23. Database Models (7/7) 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES • Object Oriented Database Model – Combines database capabilities with OOP language capability by representing information as Objects, which consist of data & instructions to handle data (methods). – Used to handle structured data and new multimedia data types (Audio, Video, Pictures, etc.). – Disadvantages • Costly to develop, Migration to OODBMS is mostly debated. – Application: Healthcare 23 of 94
  • 24.
  • 25. Database Security & Recovery • Database Security – Protection from unauthorized use and sabotage. – Degree of Access • Privileges to view, retrieve, and modify. – Physical Protection – Threats to data security • Human error, hardware/software/DB failure, theft and fraud, loss of personal/corporate data, loss of data/corporate integrity, loss of availability, loss of backups, etc. • Data Recovery – Backup & Recovery includes • Journalizing facility, DB change logs, Transactions logs, checkpoint facility, etc. 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 25 of 94
  • 26. Strategies of Data Recovery • Mirroring – Making frequent simultaneous copies of a DB in different locations. – Expensive – Used by Ticketing systems • Reprocessing – Reverting back to a known point of DB activity prior to failure/problem – Time consuming & incur delay till DB is made available. 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 26 of 94
  • 27.
  • 28. Data Warehousing (1/5) • Conceptualized by Bill Inmon, 1990 • Data repository which mostly includes historical data and data from several diverse sources. • Organizations mostly have Evaluational & Operational databases. – OLAP tools can be used to provide business intelligence (analyze business) and OLTP tools provide data entry and retrieval transaction processing (run business). • Features of Data warehouses – Constructed by integrating data from heterogenous sources – Provides information of a particular time period. – Non-volatile and separated from operational DB. 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 28 of 94
  • 29. Data Warehousing (2/5) • Like a database a data warehouse also requires to maintain a logical description (Schema) – Operational databases is based on ER Model – Data warehouse (Evaluational database) is based on Schema – Types of Schema • Star Schema • Snowflake Schema • Fact constellation or Galaxy Schema – Data warehouse Schema can be defined using DMQL. 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 29 of 94
  • 30. Data Warehousing (3/5) • Example: Star Schema 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 30 of 94
  • 31. Data Warehousing (4/5) • Example: Snowflake Schema – Redundancy is reduced by splitting the dimension tables. 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 31 of 94
  • 32. Data Warehousing (5/5) • Example: Fact Constellation or Galaxy Schema – Consists of more number of Fact tables. 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 32 of 94
  • 33. Data Mining • Patented by HNC Software Inc., San Diago in 1980s • Knowledge Discovery from a Data warehouse – Finding patterns, trends & correlations ease understanding and decision making. – Knowledge can be used for prediction (as in Businesses). • Applications (Discussion) – Online and Retail store – Telecommunication – Hospitals 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 33 of 94
  • 34. Data Marts (1/5) • Groups related data sets for specific sets of customers. 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 34 of 94
  • 35. Data Marts (2/5) • Why Data Mart? – Maintain temporary copy of data from few fact tables which does not change frequently for analysis. It is discarded after analysis. – Decrease load on a Data warehouse by making a copy of fact tables in separate server. Refreshed periodically. – Simulation of new scenarios by changing data. • Data in a Data warehouse cannot be changed without affecting performance. • Star schema offers ease of design 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 35 of 94
  • 36. Data Marts (3/5) • Type-1: Dependent data mart – Data from Data warehouse are aggregated, restructured & summarized with Enterprise context. – Built to achieve improved performance and availability, better control, & lower telecommunication costs resulting from local access of data relevant to a specific department. 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 36 of 94
  • 37. Data Marts (4/5) • Type-2: Independent data mart – No centralized data warehouse. – Number of sources are few. – All aspects of the ETT process (Extract, transform, transfer) should be dealt. – Preferred when a solution is required within a shorter time. 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 37 of 94
  • 38. Data Marts (5/5) • Type-3: Hybrid data mart – Combine input from sources other than a data warehouse 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 38 of 94
  • 39.
  • 40. Introduction (1/5) • Developed by Donald D. Chamberlin & Raymond Boyce in IBM, early 1970s. • SQL (earlier SEQUEL) is a high level language which provides practical implementation of Codd’s relational model. – i.e. Store, manipulate and retrieval of data stored in a relational database. 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 40 of 94
  • 41. Introduction (2/5) • ANSI standard (1986) & ISO standard (1987). • Since standardization SQL standards have been updated 6 times. Version 5.1 is the latest update in Nov. 2008. • Note: – 1979, Larry Ellison, Bob Miner and Ed Oates developed SQL- based RDBMS named Oracle in Relational Software Inc. (now Oracle Corp.). • Versions: Oracle 12c/11g/10g/9i/8i, etc. – Versions and Editions of MS SQL Server. 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 41 of 94
  • 42. Introduction (3/5) • SQL Architecture 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 42 of 94
  • 43. Introduction (4/5) • SQL Commands can be classified into 4 groups based on functionality – DDL: Deals with schemas and descriptions of how data should reside in a DB. • E.g. Create, Alter, Drop, Truncate, Rename, etc. – DML: Deals with reading and modifying of data. • E.g. Select, Insert, Update, Delete, etc. – DCL: Concerned with rights, permissions and other controls. • E.g. Grant, Revoke – DCL: Deals with transactions within a database. • E.g. Commit, Rollback, Savepoint, etc. 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 43 of 94
  • 44. Introduction (5/5) • Database Normalization – Efficiently organizing data in DB without redundancy and with required data dependencies. – Consists of series of guidelines (known as forms). i.e. 1NF, 2NF, etc. • SQL-RDMS Concepts – Table – Field, Column and Records. 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 44 of 94
  • 45. SQL Data Types (1/7) • Specifies the type of data of any object. • Categories – Exact and Approximate Numeric – Date and Time – Unicode and Non-Unicode Character Strings – Binary – Miscellaneous 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 45 of 94
  • 46. SQL Data Types (2/7) • Exact Numeric Data Types 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 46 of 94
  • 47. SQL Data Types (3/7) • Approximate Numeric Data Type • Date and Time Data Type 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 47 of 94
  • 48. SQL Data Types (4/7) • Character String Data Type 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 48 of 94
  • 49. SQL Data Types (5/7) • Unicode Character String Data Type 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 49 of 94
  • 50. SQL Data Types (6/7) • Binary Data Type 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 50 of 94
  • 51. SQL Data Types (7/7) • Miscellaneous Data Type 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 51 of 94
  • 52. SQL Operators (1/5) • Operators – Reserved word/character that specify conditions or serve as conjunctions to multiple conditions in a SQL statement's WHERE clause to perform operation(s). – Categories • Arithmetic Operators & Comparison Operators • Logical Operators: ALL, AND, ANY, BETWEEN, EXISTS, IN, LIKE, NOT, OR, IS NULL, UNIQUE, Negation • String Manipulation: CONCATENATE, LENGTH, SUBSTRING • Grouping: COUNT – Can be used with GROUP BY statement. – Performs on 2/more rows and provides a summarized result set. • Aggregate: COUNT, SUM, AVERAGE, MINIMUM, MAXIMUM. – Can be used with GROUP BY statement. – Performs on 2/more tuples/rows and returns a scalar result set.25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 52 of 94
  • 53. SQL Operators (2/5) • Wild Card operators – Percentage (%) - 0/1/more characters – Underscore ( _ ) represents single number/character. • Miscellaneous operators: DISTINCT • SQL Expressions – Combination of one or more values, operators or SQL functions that evaluate to a value. – Types: Boolean (Single value matching), Numeric, Date 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 53 of 94
  • 54. SQL Operators (3/5) • Union Operator – Join two data sets having same column definitions in the same order. Removes duplicate rows from resulting data set. – UNION ALL can be used to return all data sets with duplicates in the result set. 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 54 of 94
  • 55. SQL Operators (4/5) • Intersection (INTERSECT) Operator – Returns a result set common to both data sets. Common data sets are listed only once even if there are multiple duplicate rows in either of the table. – INTERSECT ALL can be used to return all data sets with duplicates in the result set. 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 55 of 94
  • 56. • Difference (EXCEPT) Operator – Returns the result set that exists only in the left table but not in right table. Common data sets are listed only once even if there are multiple duplicate rows in left table. – EXCEPT ALL can be used to return all data sets with duplicates in the result set. SQL Operators (5/5) 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 56 of 94
  • 57. SQL Syntax • SQL statements – Start with keyword and End with semi-colon. – Not case-sensitive. • Clauses – Distinct, where, and/or, in, between, like, order by, group by, count, having • Refer the Word Doc for the Discussion on SQL commands 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 57 of 94
  • 58. SQL Constraints (1/5) • Constraints enforce certain rules to limit the type of data inserted into a table so as to ensure accuracy and reliability of data in DB. – Column level Constraints & Table level Constraints. • Constraints can be specified during table creation and can be altered after creation. • DEFAULT constraint – Auto-repeat the same specified default value for all records in a column. – Used to insert system values, by using functions like GETDATE() • Auto-increment fields – IDENTITY property auto generates values for all records in a column. These values are not guaranteed to be unique. 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 58 of 94
  • 59. SQL Constraints (2/5) • NOT NULL constraint – A field which can be left blank during record creation is considered to take a NULL value (default). – In certain cases tables are created with mandatory (NOT NULL) fields which should take a value while record creation or updation. • CHECK constraint – Ensures that the concerned field can take only those values which satisfy the rules specified. – New constraint can be defined to evaluate values of multiple columns. 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 59 of 94
  • 60. SQL Constraints (3/5) • UNIQUE constraint – Ensures that all values in a column(s) are unique/different (no repetition). – NULL is also a part of UNIQUE data values domain. • PRIMARY KEY constraint – Can take unique values and cannot take NULL value. – Has an index associated with it, using which, it uniquely identifies each record in a table. – A new Primary key constraint can be defined using one or multiple columns. – Automatically has a UNIQUE constraint. • Note: A table can have multiple UNIQUE constraints, but only one PRIMARY KEY constraint. 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 60 of 94
  • 61. SQL Constraints (4/5) • FOREIGN Key constraint – Foreign key is a field(s) in one table (i.e. child) that refers to the primary key in another table (i.e parent). – Used to link two tables together. – Handling deletion and updation on linked tables. • Options – Delete Action: Cascade, Set null, No Action, Restrict – Update Action: No Action, Restrict • CASCADE – Operation is cascaded to all rows in the child tables that reference the row/value to be modified/deleted in parent table. • SET NULL – All referring cells in child tables are set to NULL. 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 61 of 94
  • 62. SQL Constraints (5/5) • INDEX constraint – Column(s) of a table can be indexed for fast data retrieval and speedy searches. • Create indexes on column(s) which are frequently searched as updating a table with indexes takes more time than updating a table without indexes (because the indexes also need an update). – Indexes can be made unique (with UNIQUE constraint). – Indexes are invisible to the users. 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 62 of 94
  • 63. Sub-Queries (1/2) • Queries can be nested. – Outer query is referred as Main/Parent Query & the inner query is referred as Sub-Query. • Sub-Queries are executed first. • Correlated sub-query – Sub-Query is executed for each row of parent table instead of once. • Sub-Query can also be used in FROM clause. • Sub-Queries may return Scalar value – Returns single value of any attribute. – Example • SQL> SELECT name FROM student_enrollment WHERE age = (SELECT min(age) FROM students); 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 63 of 94
  • 64. Sub-Queries (2/2) • Sub-Queries may return Vector values – Returns data set representing multiple values for a column or array of values for multiple columns. – Example • SQL> SELECT name FROM students WHERE course_enrolled IN (SELECT distinct course_name FROM courses WHERE department_name = ‘CSE’); 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 64 of 94
  • 65. Views & Cursors • Views – A view is a virtual table (contains rows and columns) based on the result-set of an SQL statement. • The fields in a view are fields from one/more real tables in DB. • Cursors – It is a result set holding the result of a SELECT statement – Widely used for fetching multiple rows from a table and processing them inside applications. – Syntax – DECLARE <cursor_name> CURSOR [WITH RETURN <return target>] <SELECT statement>; – OPEN <cursor_name>; – FETCH <cursor_name> INTO <variables>; – CLOSE <cursor_name>; 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 65 of 94
  • 66. Table Joins (1/6) • JOIN clause combines rows from 2 or more tables based on a related column between them. • Types of Join – (INNER) JOIN: Returns records that have matching values in both tables – LEFT (OUTER) JOIN: Return all records from the left table, and the matched records from the right table – RIGHT (OUTER) JOIN: Return all records from the right table, and the matched records from the left table – FULL (OUTER) JOIN: Return all records when there is a match in either left or right table 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 66 of 94
  • 67. Table Joins (2/6) 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 67 of 94
  • 68. Table Joins (3/6) 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 68 of 94
  • 69. Table Joins (4/6) 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 69 of 94
  • 70. Table Joins (5/6) 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 70 of 94
  • 71. Table Joins (6/6) • Types of Inner Join – Equi-join • Based on equality of specified columns. – Natural join • Joining column does not require specification. System automatically selects the column with same name in tables and applies equality operation on it. • Removes all duplicate attributes – Cross join • Cartesian product of tables to be joined. 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 71 of 94
  • 72. Mapping of OO & Relational concepts • Examples – Hibernate • Provides ORM (Object-Relational Mapping) libraries for Java. – IBM pureQuery • Eclipse IDE based, pluggable component that provide the design & runtime means for managing relational data as objects.25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 72 of 94
  • 73.
  • 74. What is JDBC? • Std. Java API for DB independent connectivity between Java based Executables & wide range of Databases. – Executables include Applications, Applets, Servlets, JSPs, EJBs • JDBC library includes APIs for the tasks associated with DB usage – DB connectivity – Creating SQL/MySQL statements – Execution of Queries in DB – View & Modify resulting records • Provides same capability as ODBC allowing Java programs to contain DB-independent code. 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 74 of 94
  • 75. JDBC Architecture • Supports both 2-tier & 3-tier processing models. In general has 2 layers – JDBC API – JDBC Driver API • Supports multiple concurrent drivers connected to heterogeneous DBs. 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 75 of 94
  • 76. JDBC Components • JDBC API provides following interfaces and classes – DriverManager (Class) • Manages list of DB drivers & provides DB connection – Driver (Interface) • Handles communication with DB Server. Driver objects are rarely used directly. Instead DriverManager objects are used. – Connection (Interface) • Consists of methods for using the DB. These are accessed using Connection object. – Statement (Interface) • Statement objects are used to submit Queries to DB. – ResultSet (Object) • Object holds the data retrieved from DB – SQLException (Class) 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 76 of 94
  • 77. Database APIs (1/4) • Set of APIs that gives application developers a mechanism to interact with DB from within the application dynamically. • DB vendors provide different APIs wrt Languages. • APIs are developed independent of DB and do not require pre-compilation. – Applications can be developed independently of target DBs without need of DB connection at compilation phase. • DB Connectivity Driver – Serves as intermediate layer between Application & DB server. – Driver libraries are linked with source code libraries, code is compiled and later executed. – E.g. ODBC & IBM Data Server CLI Driver 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 77 of 94
  • 78. Database APIs (2/4) • Callable SQL Interface – DB vendors could provide connectivity drivers which are not compatible with other DBs. – Some level of standardization is required for increased application portability. – Few Standard Callable SQL Interface • X/Open CLI, ODBC, IBM Data Server CLI Driver • X/Open CLI (Call Level Interface) – Developed by X/Open Company & SQL Access Group – ISO CLI International Standard (ISO/IEC 9075-3: 1995 SQL/CLI) • ODBC – Developed by Microsoft based on preliminary draft of X/Open CLI. 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 78 of 94
  • 79. Database APIs (3/4) • IBM Data Server CLI Driver – DB2 CLI based on Microsoft ODBC spec. & SQL/CLI International standard which includes DB2 specific extensions to exploit DB2 features. – Conforms to ODBC 3.51 standard. • i.e. Works equivalent to ODBC driver when loaded by an ODBC Driver Manager. – DB2 CLI is a C/C++ API for Relational DB access which uses fn. call to pass dynamic SQL statements as function arguments. • E.g. Callable Interfaces include SQLPrepare(), SQLConnect(), SQLFetch(), SQLExecute() 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 79 of 94
  • 80. Database APIs (4/4) • Environments of Microsoft ODBC & IBM DB2 CLI 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 80 of 94
  • 81.
  • 82. What is Index? (1/2) • An Index is a set of pointers logically ordered by the value of one/more keys. – Columns in an index are known as keys. – Keys can be unique or non-unique. But a table should have at least one unique key. • Why to Index? – Improve Performance with quick data access. – Ensure Uniqueness in identifying rows (records). – Sequencing rows according to the values in column. • Index can refers to rows in a table, block in a Cluster table, XML data in an XML storage object – Cluster table indexes & XML indexes are system generated. 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 82 of 94
  • 83. What is Index? (2/2) • Relationship between an index and a table 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 83 of 94
  • 84. Database partitioning (1/3) • Relationships among selected database objects 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 84 of 94
  • 85. Database partitioning (2/3) • DB partition group – Set of one/more DB partitions that belong to a database. • Table spaces (1/2) – Specifies where data in a DB is physically stored on a system. • Data includes tables, Indexes, Large objects (LOB: 8-128TB) 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 85 of 94
  • 86. Database partitioning (3/3) 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES • Table spaces (2/2) – Defines how data for a table is distributed across DB partitions in a DB partition group. – Single table can span several containers (disk). – DB manager balances the data load across containers. • Extent Size: No. of pages that DB manager writes to a container before using a different container. 86 of 94
  • 87. Types of Indexes (1/3) • Indexes on Partitioned Tables within a database partition – Indexes are non-partitioned & exists in a single table space. – Indexes are partitioned & exists across one/more table spaces. – Combination of the above. • Commands to handle Indexes (Create/Modify/Remove) – CREATE INDEX statement, ALTER INDEX command, DROP statement, IBM db2advis Design Advisor commands. • Classification of Index Architecture 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES Index Architecture Clustered Index Architecture Non-Clustered Index Architecture 87 of 94
  • 88. Types of Indexes (2/3) • Clustered Indexes – Defines the order in which data is physically stored in a table. – There can be only one clustered index per table. • In SQL Server, the primary key constraint automatically creates a clustered index on that particular column in ascending order. • Only one index in table has high degree of clustering. – Data Manager keeps the data in data pages in the same order as the corresponding keys in index page. – Reorganizing a table with a chosen index will re-cluster data. – Clustered index allows better sequential access of data as rows with similar index key values are stored together. – Statements • CREATE INDEX statement with CLUSTER option specified. • ALTER TABLE statement – add primary key that corresponds to clustering index. 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 88 of 94
  • 89. Types of Indexes (3/3) • Non-Clustered Indexes – Resembles the words index at the back of a book. i.e. Structured in a way that does not correspond to the order of the actual data records. – Many non-clustered indexes can exist per table. – Data Manager does not maintain any order of the data when compared to the order of the corresponding keys. – Non-clustered indexes are slower than clustered indexes. 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 89 of 94
  • 90.
  • 91. DB2® cluster services • Provides auto heartbeat failure detection & auto initiation of recovery options after a failure is detected. • Provides cluster file system that provides each host in DB2 pureScale® instance access to a common file system. • Includes technology from following IBM® softwares: – Tivoli® System Automation for Multi-platforms (Tivoli SA MP) – Reliable Scalable Clustering Technology (RSCT) – General Parallel File System (GPFS ™) Software 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 91 of 94
  • 92. Failure Management • Automated cluster caching facility (CF) failover – When Primary cluster CF fails, DB2 cluster services automatically attempts to restart it while Secondary cluster CF takes over. • Automated restart – DB2 cluster services detects Software and Hardware failure, and initiates a member/group restart depending on the type of failure. • Manual intervention in failure situations – DB2 cluster services automatically initiates the required type of restart or crash recovery. However, human intervention is required at times to restart or crash recovery and take steps to complete group crash recovery. 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 92 of 94
  • 93. Peep into the next Module • Storage Overview – Storage Networking Technology – Types of Storage System – Fiber Channel Arbitrated Loop – Fabric – SANs – Zoning – Storage Virtualization 25-Aug-2017 CSIT1002 Instructor: Mr.S.Christalin Nelson|SoCSE|UPES 93 of 94