Addbase - Prelim: Slide 1 - Review of Theory of Databases

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 6

ADDBASE – PRELIM  Relations

 Composed of rows and columns of data, can


also be called tables.
SLIDE 1 – REVIEW OF THEORY OF DATABASES
 Attribute
 Database  In relational database, the table columns
 A collection of logically related data correspond to attributes.

 Schema/Database Schema  Domain


 Overall design of a Database  Refers to a set of valid atomic values for a
given attribute.
 Database System
 Is an automated system that enables users  Primary Key
to define, create, maintain and control  Refers to an attribute or field that serves as
access to databases. a unique identifier for a particular record
within a relation.
 Components of the DBMS Environment.
 Data  SQL
 Hardware  Structured Query Language is the standard
 Software language used to define, query, and update
 End users and maintain relational databases.
 Procedure
 Main Categories of SQL
 Different facilities that DBMS provide  Data Definition Language – DDL
 DDL (Data Definition Language) – define  Data Manipulation Language – DML
database  Data Query Language – DQL
 DML (Data Manipulation Language)-  Data Control Language – DCL
manipulate data  Transactional Control Command
 DCL (Data Control Language) – Provides
security and access for the database  Data Definition Language- DDL
 Provide Security System  The DDL allows the user to create and
 Provide Integrity System restructure database objects.
 Provide Concurrency Control System  DDL Commands:
 Provide Recovery Control System  CREATE TABLE
 ALTER TABLE
 Entity Relationships  DROP TABLE
 One to One  CREATE INDEX
 One to Many  ALTER INDEX
 Many to One  DROP INDEX
 Many to Many  CREATE VIEW
 DROP VIEW
 Relational Database  Data Control Language – DCL
 Divided into logical units called table which  DML allows the user to manipulate data
is composed of rows and columns of data within objects of a relational database.
 DML commands
 INSERT
 UPDATE
 DELETE
 Data Query Language -DQL SLIDE 2 – RETRIEVING DATA FROM
 DQL allows the user to select a data or a SEVERAL TABLES
group of data.
 The base command is SELECT  Join
 Data Control Language – DCL  Collection of data from multiple
 The DCL allows the user to create object tables
related to user access and also control the  It combines two or more tables to
distribution of privileges among users. retrieve data from multiple tables
 DCL commands  Primary keys and foreign keys are to
 ALTER PASSWORD join related tables to one another
 GRANT
 REVOKE  Equijoins or Inner Joins
 CREATE SYNONYM  Combines two tables with a common
 Transactional Control Commands – TCC column which is usually the primary
 The TCC allow the user to manage database key.
transactions.  Syntax:
 Some commands are as follows:
 COMMIT
 ROLLBACK
 SAVEPOINT
 SET TRANSACTION

 Integrity Constraint
 Use to ensure accuracy and consistency of
data in a relational database.
 Types of Integrity Constraints
 Primary Key Constraints
 Unique Constraints
 Foreign Key Constraints
 Not Null Constraints
 Check Constraints

 Normalization
 Process of reducing data redundancy in a
database
 Levels of Normal Forms  Natural Joins
 First Normal Form (1NF)  Removes duplicate columns in the
 Second Normal Form (2NF) joining columns
 Third Normal Form (3RD)

 Advantage of Normalization
 Better overall database organization
 Reduction of redundant data
 Data consistency within the database
 Flexible database design
 Efficient database security handling
 Enforces concept of referential integrity
 Non-Equijoins  Self Joins
 It combines two or more tables based  Combines tables to itself
on a specified column value not
equaling a specified column value in
another table

 Cross Joins
 It returns all possible combinations
 Outer Joins of rows from the two tables
 It produces all rows that exist in one
table, even if there are
corresponding rows do not exist in
the joined table
 Left Outer Join
 Preserves every row in the left-hand
table
 Right Outer Join
 Preserves every row in the right-hand
table
 Full Outer Join
 Preserves all row from both sides
SLIDE 3 – COMMON TABLE EXPRESSION
 Common Table Expression (CTE)
 Are temporary result set that are
known only within the scope of a
single SELECT, INSERT, UPDATE,
DELETE or CREATE VIEW statement
 Common table expressions are
generally useful in a query that
involves multiple aggregate
functions.

Application of Common Table Expressions


 Common table expressions are useful whenever
multiple levels of aggregation must occur within
a single query
 Views within a procedure that must contain a
reference to a program variable
 Queries that use temporary result set to store a
set of values
What is Recursive Common Table Expressions
 Recursive Common Table Expressions
 Allow you to query tables that represent
hierarchical information
 A recursive common table expression is
composed of an initial subquery or seed and
a recursive subquery.
Restrictions on Recursive Common Table
Expressions
SLIDE 4 – OLAP
 The recursive common table expressions cannot
be mutually recursive  Online Analytical Processing (OLAP) is a process
 The only set operator permitted between the of data analysis for information stored in a
initial subquery and the recursive subquery is relational database.
UNION ALL.  OLAP is based on facts and facts are numbers.
 Within the definition of a recursive subquery, a The number in the OLAP spreadsheet are called
self-reference to the recursive table expression facts
can appear only within the FROM clause of the  Sales Quality
recursive subquery.  Sales Count
 The recursive subquery cannot contain  Profit
DISCTINCT, or a GROUP BY or an ORDER BY  Hours of Work
clause
 The recursive subquery can not make use of any  Three Prominent Architecture of OLAP systems
aggregate function  Multimedia Online Analytical Processing
 To prevent runaway recursive queries, an error (MOLAP)
is generated if the number of levels of recursion  Relational Online Analytical Processing
exceeds the current setting of the (ROLAP)
MAX_RECURSIVE_ITERATIONS option.  Hybrid Online Analytical Processing (HOLAP)

 Advantages of Using OLAP


 Multidimensional
 Consistently Fast
 Intuitive Interface
 Complex Calculations

Using Rollup Operation


 ROLLUP operation
 Used when you want to get a result set
showing totals and subtotals
USING GROUPING SETS OPERATION
 GROUPING SETS
 Allows you to compute groups on several
different sets of grouping in the same query
 It is useful if you would like to return only
part of the multidimensional result set of a
cube

USING CUBE OPERATION


 CUBE Operation
 Produces subtotals for all possible OLAP FUNCTIONS
combinations of the columns listed in the  OLAP functions provide the capability to
group by clause perform analytic task on data.
 Like ROLLUP, the CUBE operator provides  OLAP functions:
subtotals of aggregate values in the result  Windows Aggregate Functions
set.  AVG
 MAX
 MIN
 SUM
 Window ranking functions
 CUME_DIST
 DENSE_RANK
 PERCENT_RANK
 RANK
 Row Numbering Functions
 ROW_NUMBER

You might also like