Database Administration, Integrity and Performance.

Slides:



Advertisements
Similar presentations
1 Constraints, Triggers and Active Databases Chapter 9.
Advertisements

Relational Database Design UNIT II 1. 2 Advantages of Using Database Systems Centralized control of a firm’s data Redundancy can be reduced (avoid keeping.
Relational Database. Relational database: a set of relations Relation: made up of 2 parts: − Schema : specifies the name of relations, plus name and type.
Database Management Systems, R. Ramakrishnan and J. Gehrke1 The Relational Model Chapter 3.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 5 More SQL: Complex Queries, Triggers, Views, and Schema Modification.
Monday, 08 June 2015Dr. Mohamed Osman1 What is Database Administration A high level function (technical Function) that is responsible for ► physical DB.
Chapter 3 The Relational Model Transparencies © Pearson Education Limited 1995, 2005.
Database Systems: A Practical Approach to Design, Implementation and Management International Computer Science S. Carolyn Begg, Thomas Connolly Lecture.
Introduction to Structured Query Language (SQL)
Chapter 3. 2 Chapter 3 - Objectives Terminology of relational model. Terminology of relational model. How tables are used to represent data. How tables.
©Silberschatz, Korth and Sudarshan12.1Database System Concepts Chapter 12: Part A Part A:  Index Definition in SQL  Ordered Indices  Index Sequential.
1 Relational Model. 2 Relational Database: Definitions  Relational database: a set of relations  Relation: made up of 2 parts: – Instance : a table,
Introduction to Structured Query Language (SQL)
A Guide to SQL, Seventh Edition. Objectives Understand, create, and drop views Recognize the benefits of using views Grant and revoke user’s database.
10/3/2000SIMS 257: Database Management -- Ray Larson Relational Algebra and Calculus University of California, Berkeley School of Information Management.
Chapter 17 Methodology – Physical Database Design for Relational Databases Transparencies © Pearson Education Limited 1995, 2005.
Team Dosen UMN Physical DB Design Connolly Book Chapter 18.
Chapter 7 Constraints and Triggers Spring 2011 Instructor: Hassan Khosravi.
Chapter 14 & 15 Conceptual & Logical Database Design Methodology
Data Definition, Relational Manipulation and Data Control Using SQL.
CSC271 Database Systems Lecture # 6. Summary: Previous Lecture  Relational model terminology  Mathematical relations  Database relations  Properties.
Chapter 6: Integrity and Security Thomas Nikl 19 October, 2004 CS157B.
©Silberschatz, Korth and Sudarshan6.1Database System Concepts Chapter 6: Integrity and Security Domain Constraints Referential Integrity Assertions Triggers.
Lecture 2 The Relational Model. Objectives Terminology of relational model. How tables are used to represent data. Connection between mathematical relations.
Chapters 17 & 18 Physical Database Design Methodology.
An Investigation of Oracle and SQL Server with respect to Integrity, and SQL Language standards Presented by: Paul Tarwireyi Supervisor: John Ebden Date:
Switch off your Mobiles Phones or Change Profile to Silent Mode.
Lecture 9 Methodology – Physical Database Design for Relational Databases.
Chapter 9 Integrity. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.9-2 Topics in this Chapter Predicates and Propositions Internal vs.
1 Introduction to Database Systems. 2 Database and Database System / A database is a shared collection of logically related data designed to meet the.
Physical Database Design Chapter 6. Physical Design and implementation 1.Translate global logical data model for target DBMS  1.1Design base relations.
Chapter 16 Methodology – Physical Database Design for Relational Databases.
SQL Server 7.0 Maintaining Referential Integrity.
CpSc 462/662: Database Management Systems (DBMS) (TEXNH Approach) Constraints, Triggers and Index James Wang.
DATABASE MGMT SYSTEM (BCS 1423) Chapter 5: Methodology – Conceptual Database Design.
Chapter 6 Database Administration
1 The Relational Model. 2 Why Study the Relational Model? v Most widely used model. – Vendors: IBM, Informix, Microsoft, Oracle, Sybase, etc. v “Legacy.
FALL 2004CENG 351 File Structures and Data Management1 Relational Model Chapter 3.
7 1 Chapter 7 Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
10/10/2012ISC239 Isabelle Bichindaritz1 Physical Database Design.
Physical Database Design Transparencies. ©Pearson Education 2009 Chapter 11 - Objectives Purpose of physical database design. How to map the logical database.
6 1 Lecture 8: Introduction to Structured Query Language (SQL) J. S. Chou, P.E., Ph.D.
1 Chapter 6 Database Administration. 2 Introduction Database administration The process of managing a database Database administrator A person or an entire.
Methodology – Physical Database Design for Relational Databases.
Chapter 9 Constraints. Chapter Objectives  Explain the purpose of constraints in a table  Distinguish among PRIMARY KEY, FOREIGN KEY, UNIQUE, CHECK,
Oracle 11g: SQL Chapter 4 Constraints.
Chapter 4 Constraints Oracle 10g: SQL. Oracle 10g: SQL 2 Objectives Explain the purpose of constraints in a table Distinguish among PRIMARY KEY, FOREIGN.
Constraints and Triggers. What’s IC? Integrity Constraints define the valid states of SQL-data by constraining the values in the base tables. –Restrictions.
Physical Database Design Purpose- translate the logical description of data into the technical specifications for storing and retrieving data Goal - create.
Academic Year 2014 Spring Academic Year 2014 Spring.
Constraints Lesson 8. Skills Matrix Constraints Domain Integrity: A domain refers to a column in a table. Domain integrity includes data types, rules,
Chapter 5 : Integrity And Security  Domain Constraints  Referential Integrity  Security  Triggers  Authorization  Authorization in SQL  Views 
The Relational Model. 2 Relational Model Terminology u A relation is a table with columns and rows. –Only applies to logical structure of the database,
Session 1 Module 1: Introduction to Data Integrity
CS34311 The Relational Model. cs34312 Why Relational Model? Currently the most widely used Vendors: Oracle, Microsoft, IBM Older models still used IBM’s.
Integrity Prof. Yin-Fu Huang CSIE, NYUST Chapter 9.
Lecture 03 Constraints. Example Schema CONSTRAINTS.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 4: Intermediate.
LECTURE TWO Introduction to Databases: Data models Relational database concepts Introduction to DDL & DML.
SQL Basics Review Reviewing what we’ve learned so far…….
CENG 351 File Structures and Data Management1 Relational Model Chapter 3.
1 Constraints and Triggers in SQL. 2 Constraints are conditions that must hold on all valid relation instances SQL2 provides a variety of techniques for.
Data Integrity & Indexes / Session 1/ 1 of 37 Session 1 Module 1: Introduction to Data Integrity Module 2: Introduction to Indexes.
Chapter 6: Integrity (and Security)
Record Storage, File Organization, and Indexes
Methodology – Physical Database Design for Relational Databases
國立臺北科技大學 課程:資料庫系統 fall Chapter 18
File organization and Indexing
Chapter 4 The Relational Model Pearson Education © 2009.
Chapter 4 The Relational Model Pearson Education © 2009.
Presentation transcript:

Database Administration, Integrity and Performance

Objectives b Define the roles of database administrator b Describe the term integrity b Define the term security b Define the basic performance measures

The Database Administrator The Database Administrator b Data Administrator(DA) makes the strategies and policies decisions regarding the data of the enterprise. b Database Administrator(DBA) implements those decisions technically.

Functions of DBA b Creating the conceptual schema (logical or conceptual database design) b Creating the internal schema (physical database design)

Functions of DBA b Defining security and integrity constraints b Defining backup and recovery policies b Monitoring performance and responding to changing environments.

SECURITY b Protecting the data against unauthorised disclosure, alteration or destruction.

Security is enforced by b DBMS’s security subsystem b Checking access requests to security constraints stored in system catalog b Giving certain privileges in a relation to certain users

What are views for? b Automatic Security for hidden data b Short hand capability b Same data to be seen by different users in a different way at the same time b May provide logical data independence immunity of users and user programs to changes in the logical structure of a databaseimmunity of users and user programs to changes in the logical structure of a database GrowthGrowth – new attributes may be added – new relations may be added

SQL FACILITIES FOR VIEWS CREATE VIEW AS CREATE VIEW AS [ WITH [ ] CHECK OPTION ] b With check option means that INSERT and UPDATE on the view will be rejected if they violate any integrity constraint implied by the view defining expression b Qualifier is CASCADED { Default } or LOCAL

Examples of views CREATE VIEW Bestsupplier AS SELECT S.S#, S.STATUS, S.CITY AS SELECT S.S#, S.STATUS, S.CITY FROM SUPPLIER FROM SUPPLIER WHERE SUPPLIER.STATUS > 15 WHERE SUPPLIER.STATUS > 15 WITH CHECK OPTION ;

Examples of views CREATE VIEW GREENPART AS SELECT PART.P#, PART.NAME, PART.WEIGHT AS WT, PART.CITY SELECT PART.P#, PART.NAME, PART.WEIGHT AS WT, PART.CITY FROM PART FROM PART WHERE PART.Color = ‘Green’ WHERE PART.Color = ‘Green’ WITH CHECK OPTION;

Examples of views CREATE VIEW HEAVY_GREENPART AS SELECT GP.P#, GP.NAME, GP.WT, GP.CITY SELECT GP.P#, GP.NAME, GP.WT, GP.CITY FROM GREENPART AS GP FROM GREENPART AS GP WHERE GP.WT > 12.0 WHERE GP.WT > 12.0 WITH CHECK OPTION;

Views and Security GRANT SELECT, UPDATE (NAME,WT), DELETE ON GREENPART DELETE ON GREENPART TO user1, user2; TO user1, user2; b Privileges can be USAGE, SELECT, INSERT, UPDATE, DELETE and REFERENCES b Can be provided WITH GRANT OPTION

REVOKE REVOKE DELETE ON GREENPART FROM user1 RESTRICT b Revoke can be done for GRANT OPTION FOR also b RESTRICT is needed if a privilege is granted further

What is Integrity? b Accuracy or correctness of data in a database b Mostly RDBMS provide two kind of Integrity support: Declarative Integrity supportDeclarative Integrity support Procedural Integrity supportProcedural Integrity support

Declarative Support b In the form of constraint definitions b If a new constraint is declared then the system ensures that current state of database satisfies it, otherwise, the new constraint is rejected b If a DBMS provides declarative support, then about 90% of typical database definition would consist of constraints.

Declarative Support Contd.. A system providing such support relieve application programmers of the burden, thus, increases productivity

Golden Rule b No update operation must ever be allowed to leave any relation in a state that violates its own predicate. No update transaction must ever be allowed to leave database in a state that violates its own predicate.

State Vs Transition Constraints b Concerned with the correct state of database b Constraints on legal transitions Not married to marriedNot married to married No student class should ever deceaseNo student class should ever decease

FOREIGN KEYS. b Let R2 be a relation, then a foreign key in R2 is a set of attributes of R2, say FK, such that : There exists a relation R1 ( R1 & R2 not necessarily distinct) with a candidate key CK; andThere exists a relation R1 ( R1 & R2 not necessarily distinct) with a candidate key CK; and For all times, each value of FK in the current value of R2 is identical to the value of CK in some tuple in the current value of R1.For all times, each value of FK in the current value of R2 is identical to the value of CK in some tuple in the current value of R1.

. Foreign Key contd... b Definition requires that every value of given foreign key appears as a value of matching candidate key - Converse is not a requirement b A foreign key is simple or composite b Each attribute of a given foreign key must have a same name and type as the corresponding component of matching candidate key

Referential Integrity b Foreign key is a Reference b Matching candidate key tuple is Referenced b Referential constraint : A value of foreign key must match the referenced candidate key b Referencing Relation : Have foreign key b Referenced Relation : Have candidate key

Referential Diagrams. b A given relation can be both referenced and referencing at the same line R3 R2 R1 R3 R2 R1 b R1 & R2 are not necessarily distinct Example : (Employee, Mgr.) Self-referencing relation b Foreign to candidate key match is the glue that holds database together

SQL Facilities b A candidate key definition b A foreign key definition b A check constraint definition We may assign a name to constraint We may assign a name to constraint

Candidate Key UNIQUE ( ) OR PRIMARY KEY ( ) b At most one Primary key definition b Any number of UNIQUE specifications b NOT NULL is by default

Foreign Key FOREIGN KEY ( ) References References [( )] [ ON DELETE [ ON DELETE ON UPDATE ] ON UPDATE ] b No action{default} or CASCADE or SET DEFAULT or SET NULL b Second Comma list, if foreign key references a candidate key that is not primary key.The foreign to candidate key matching is done on column position ( left to right)

Example of constraints CREATE TABLE SupPart ( S# S# NOT NULL, P# P# NOT NULL, P# P# NOT NULL, QTY QTY NOTNULL, QTY QTY NOTNULL, PRIMARY KEY( S#, P# ), PRIMARY KEY( S#, P# ), FOREIGN KEY ( S#) REFERENCES SUP ON DELETE CASCADE, ON DELETE CASCADE, ON UPDATE CASCADE, ON UPDATE CASCADE, FOREIGN KEY ( P#) REFERENCES PART FOREIGN KEY ( P#) REFERENCES PART ON DELETE CASCADE ON DELETE CASCADE ON UPDATE CASCADE, ON UPDATE CASCADE, CHECK ( QTY > 0 and QTY 0 and QTY < 5000) );

TRIGGERED PROCEDURES b Procedures invoked automatically on occurrence of a specified exception or a specified interval of time b CASCADE referential action is a simple example of a triggered procedure-declaratively specified

Assertions b General constraints Cerate ASSERTION Cerate ASSERTION check ( ); check ( ); DROP ASSERTIONS ; b Assertions are always satisfied by database. b On creation validity of an assertion is checked b Any change in database may result in checking by an creation =>High overheads

Example b The sum of all loans of a branch should be less than total account balances Create assertion sum-constraint check ( not exists (select * from branch where (select sum (amount) from loan where (select sum (amount) from loan where loan.branch-name = where loan.branch-name = branch.branch-name ) branch.branch-name ) >=(select sum (amount) from account where loan.branch-name = where loan.branch-name = branch.branch-name))) branch.branch-name)))

Deferred Checking b SQL constraints can be: DEFERABLE (Initially Immediate OR initially deferrable )DEFERABLE (Initially Immediate OR initially deferrable ) NOT DEFERABLENOT DEFERABLE b SET CONSTRAINT ; statement switches on or off the deferrable constraint b Option is IMMEDIATE or DEFERRED

Performance Tuning involves b Tuning of hardware resources b Reducing I/O operations

Reducing Disk Accesses b Indexing is one major technique used to reduce disk accesses

Ordered indices b Based on based on sorted ordering of values b Index involve Access timeAccess time Insertion timeInsertion time Deletion timeDeletion time Space overheadsSpace overheads

Ordered indices b Index Structure is associated with a 'Search Key' Primary index- on a sequentially sorted file. (index on primary key- not correct)Primary index- on a sequentially sorted file. (index on primary key- not correct) Indices whose search key specifies an order different from the sequential order of the file are called secondary or non clustering indices.Indices whose search key specifies an order different from the sequential order of the file are called secondary or non clustering indices.

Dense Index b An index record/ entry appears for every search key 'value' in the file & a pointer to first data record with that search key value

Sparse Index b Entry only for some of the values and a pointer to first value of that type. Take less spaceTake less space A sparse index with one index entry per block may be a good choice.A sparse index with one index entry per block may be a good choice.

Multilevel Indices b Are useful when size of index is very large

Secondary Indices b It contains pointers to all records b It should not be sparse b Improve performance b Overheads on modification of databases b Tradeoff : Frequency of Queries versus Modifications

B Tree b Is one of the major method of implementing index b B tree adds performance overheads for insertion and deletion and adds apace overheads. b This performance overhead is acceptable even for files with high frequency of modification- no cost of reorganization