Indexes (continued) Customer table with record numbers. Source: Concepts of Database Management
|
|
- Brittney Harmon
- 6 years ago
- Views:
Transcription
1 12 Advanced Topics
2 Objectives Use indexes to improve database performance Examine the security features of a DBMS Discuss entity, referential, and legal-values integrity Make changes to the structure of a relational database Define and use the system catalog Discuss stored procedures and triggers 2
3 Indexes Conceptually similar to book index Increase data retrieval efficiency Record numbers automatically assigned and used by DBMS Index key: field or combination of fields on which index is built Advantages Makes some data retrieval more efficient Disadvantages Occupies space on disk DBMS must update index whenever corresponding data are updated 3
4 Indexes (continued) Customer table with record numbers Source: Concepts of Database Management 4
5 Indexes (continued) ROWNUM pseudocolumn in Oracle Index for the Customer table on the CustomerNum field Source: Concepts of Database Management 5
6 B-Tree Index 6
7 B*-tree index 7
8 Bitmap index CREATE BITMAP INDEX Parts_color_idx ON Parts (color); 8
9 Indexes (continued) Create an index on a field (or fields) when: Field is the primary key of the table Field is the foreign key in a relationship Field will be frequently used as a sort field Need to frequently locate a record based on a value in this field SQL command to create an index: CREATE INDEX CustomerName_idx ON Customer (CustomerName); Guidelines to creating an index Do not create an index if The table is small The columns are not often used as a condition in a query Most queries are expected to retrieve more than 2~4% of the rows The table is updated frequently 9
10 CREATE INDEX Command Examples Single-field index Key is a single field Also called a single-column index Multiple-field index More than one key field Also called a multiple-column index Source: A Guide to SQL 10
11 Function-Based Indexes Index Organized Tables An IOT stores table contents in a B-tree index structure Use the ORGANIZATION INDEX option in a CREATE TABLE statement to build an IOT 11
12 Verifying an Index Use the USER_INDEXES data dictionary view to determine that the index exists Use the USER_IND_COLUMNS data dictionary view to determine the column index information Source: A Guide to SQL 12
13 USER_IND_COLUMNS Source: A Guide to SQL 13
14 Removing an Index Use the DROP INDEX command to remove an index Source: A Guide to SQL 14
15 Security Prevention of unauthorized access to database Database administrator determines types of access various users can have SQL security mechanisms GRANT: provides privileges to users GRANT SELECT ON Customer TO Jones ; REVOKE: removes privileges from users REVOKE SELECT ON Customer FROM Jones ; 15
16 Integrity Rules Two integrity rules must be enforced by a relational DBMS Integrity rules defined by Dr. E.F. Codd Entity integrity Referential integrity 16
17 Entity Integrity No field that is part of primary key may accept null values To specify primary key in SQL: Enter a PRIMARY KEY clause in either an ALTER TABLE or a CREATE TABLE command SQL command to specify a primary key: PRIMARY KEY (CustomerNum) SQL command when more than one field included: PRIMARY KEY (OrderNum, PartNum) 17
18 Referential Integrity Foreign key: field(s) whose value is required to match the value of the primary key for a second table Referential integrity: if table A contains a foreign key that matches the primary key of table B, the values of this foreign key must match the value of the primary key for some row in table B or be null To specify referential integrity in SQL: FOREIGN KEY clause in either the CREATE TABLE or ALTER TABLE commands To specify a foreign key, must specify both: Field that is a foreign key Table whose primary key the field is to match Example: FOREIGN KEY (RepNum) REFERENCES Rep(RepNum) 18
19 Legal-Values Integrity Legal values: set of values allowable in a field Legal-values integrity: no record can exist with a value in the field other than one of the legal values SQL CHECK clause enforces legal-values integrity Example: CHECK (CreditLimit IN (5000, 7500, 10000, 15000)) 19
20 Constraints Rules used to enforce business rules, practices, and policies Rules used to ensure accuracy and integrity of data Source: A Guide to SQL 20
21 Creating Constraints Use the optional CONSTRAINT keyword during creation to assign a name Let the server name the constraint using the default format SYS_Cn Informative names can assist in debugging When During table creation After table creation, by modifying the existing table How Column level approach Table level approach 21
22 Creating Constraints at the Column Level If a constraint is being created at the column level, the constraint applies to the column specified at the Table Level Approach can be used to create any constraint type except NOT NULL Required if constraint is based on multiple columns Enforcement of Constraints All constraints are enforced at the table level If a data value violates a constraint, the entire row is rejected 22
23 Including Constraints during Table Creation Column Level Include in column definition Table Level Include at end of column list 23
24 Multiple Constraints on a Single Column A column may be included in multiple constraints The order# column is included in a primary key and a foreign key constraint 24
25 Structure Changes Examples of changes to database structure Adding and removing tables and fields Changing characteristics of existing fields Creating and dropping indexes SQL ALTER TABLE command changes table s structure To add a new field to the Customer table: ALTER TABLE Customer ADD CustType CHAR(1); Changing properties of existing fields ALTER TABLE Customer CHANGE COLUMN CustomerName TO CHAR(40); Deleting a field from a table ALTER TABLE Part DELETE Warehouse; DROP TABLE command deletes a table DROP TABLE SmallCust; 25
26 Making Complex Changes Some changes might not be allowed by your DBMS In these situations, you can: Use CREATE TABLE command to describe the new table Insert values into it using INSERT command combined with a SELECT clause INSERT INTO emp_log SELECT * FROM emp WHERE empno = 7900; SELECT INTO command can create the new table in a single operation works in mysql only, not in Oracle SELECT * INTO backup_orders -- new table name FROM orders; -- source table name SELECT order_num, order_date INTO backup_orders FROM orders; -- source table name 26
27 Adding Constraints to Existing Tables Constraints are added to an existing table with the ALTER TABLE command Add a NOT NULL constraint using MODIFY clause All other constraints are added using ADD clause Using the PRIMARY KEY Constraint Ensures that columns do not contain duplicate or NULL values Only one per table is allowed PRIMARY KEY Constraint for Composite Key List column names within parentheses separated by commas Source: A Guide to SQL 27
28 Constraint Checked with Data Input Source: A Guide to SQL 28
29 Using the FOREIGN KEY Constraint Requires a value to exist in the referenced column of another table NULL values are allowed Enforces referential integrity Maps to the PRIMARY KEY in parent table Source: A Guide to SQL 29
30 Deletion of Foreign Key Values You cannot delete a value in a parent table referenced by a row in a child table: default ON DELETE RESTRICT or ON DELETE NO ACTION ON DELETE CASCADE keywords when creating FOREIGN KEY constraint it automatically deletes the dependent rows in the child table when a row in the parent table is deleted CREATE TABLE parent ( id INT NOT NULL, PRIMARY KEY (id) ); CREATE TABLE child ( id INT, parent_id INT, INDEX par_ind (parent_id), FOREIGN KEY (parent_id) REFERENCES parent(id) ON DELETE CASCADE ) ; 30
31 Deletion of Foreign Key Values CREATE TABLE customer ( customer_id INT NOT NULL, PRIMARY KEY (id) ); CREATE TABLE orders ( order_no INT NOT NULL, order_date DATE NOT NULL, customer_id INT NOT NULL, PRIMARY KEY(order_no) ); ON DELETE SET NULL ALTER TABLE orders ADD CONSTRAINT orders_customer_fk FOREIGN KEY (customer_id) REFERENCES customer(customer_id) ON DELETE SET NULL; ON DELETE SET DEFAULT Assume the column has the default value ALTER TABLE emp ADD CONSTRAINT emp_dept_fk FOREIGN KEY (dept_id) REFERENCES dept(dept_id) ON DELETE SET DEFAULT; 31
32 Using the UNIQUE Constraint No duplicates are allowed in the referenced column NULL values are permitted Source: A Guide to SQL 32
33 Using the CHECK Constraint Updates and additions must meet specified condition Source: A Guide to SQL 33
34 Using the NOT NULL Constraint The NOT NULL constraint is a special CHECK constraint with IS NOT NULL condition Can only be created at column level Included in output of DESCRIBE command Can only be added to an existing table using ALTER TABLE MODIFY command Source: A Guide to SQL 34
35 Using DISABLE/ENABLE Use DISABLE or ENABLE clause of ALTER TABLE command 35
36 Dropping Constraints Constraints cannot be modified; must be dropped and recreated Actual syntax depends on type of constraint PRIMARY KEY just list type of constraint UNIQUE include column name All others reference constraint name Source: A Guide to SQL 36
37 Drop Constraint Example Error Source: A Guide to SQL 37
38 System Catalog/Data Dictionary System catalog (or catalog) Contains information about tables in the database Maintained automatically by DBMS Example catalog has two tables Systables: information about the tables known to SQL Syscolumns: information about the columns within these tables Other possible tables Sysindexes: information about indexes Sysviews: information about views used to determine information about the structure of the DB Documenter: allows user to print detailed documentation about any table, query, report, form, or other object in the database Oracle uses SHOW DBA_TABLES, SHOW DBA_TAB_COLUMNS, and SHOW DBA_VIEWS commands 38
39 Viewing Constraints USER_CONSTRAINTS Display constraint listing for a specific table Source: A Guide to SQL 39
40 Viewing Constraints USER_CONS_COLUMNS Display constraint listing by column Source: A Guide to SQL 40
41 Client/server system Stored Procedures Database resides on a computer called the server Users access database through clients Client Computer connected to a network Has access through server to the database Stored procedure Special file used to store a query that is run often Placed on the server Improves overall performance Convenience 41
42 MySQL Stored Procedures (continued) Delimiter: semicolon at the end of a MySQL command Need to temporarily change the delimiter for a stored procedure To use a stored procedure: CALL followed by the procedure name Access does not support stored procedures Use a parameter query instead 42
43 Stored Procedures (Oracle) 43
44 Stored Procedures (Oracle) 44
45 Stored Procedures Logic 45
46 Stored Procedures (Oracle) CREATE OR REPLACE Procedure p_dept_insert ( v_deptno in number, v_dname in varchar2, v_loc in varchar2, v_result out varchar2) IS cnt number := 0; BEGIN SELECT COUNT(*) INTO CNT FROM DEPT WHERE DEPTNO = v_deptno AND ROWNUM = 1; if cnt > 0 then v_result := ' 이미등록된부서번호이다 '; else INSERT INTO DEPT (DEPTNO, DNAME, LOC) VALUES (v_deptno, v_dname, v_loc); COMMIT; v_result := ' 입력완료!!'; end if; EXCEPTION WHEN OTHERS THEN ROLLBACK; v_result := 'ERROR 발생 '; END; 46
47 Triggers Action that occurs automatically in response to an associated database operation such as an INSERT, UPDATE, or DELETE command Stored and compiled on the server Need to temporarily change the delimiter Access does not support triggers Access 2010 has data macros that have similar functionality 47
48 Triggers (Oracle) Oracle CREATE TABLE ORDER_LIST ( ORDER_DATE CHAR(8) NOT NULL, PRODUCT VARCHAR2(10) NOT NULL, QTY NUMBER NOT NULL, AMOUNT NUMBER NOT NULL); CREATE TABLE SALES_PER_DATE ( SALE_DATE CHAR(8) NOT NULL, PRODUCT VARCHAR2(10) NOT NULL, QTY NUMBER NOT NULL, AMOUNT NUMBER NOT NULL); 48
49 Triggers (Oracle) CREATE OR REPLACE Trigger SUMMARY_SALES AFTER INSERT ON ORDER_LIST FOR EACH ROW DECLARE o_date ORDER_LIST.order_date%TYPE; o_prod ORDER_LIST.product%TYPE; BEGIN o_date := :NEW.order_date; o_prod := :NEW.product; UPDATE SALES_PER_DATE SET qty = qty + :NEW.qty, amount = amount + :NEW.amount WHERE sale_date = o_date AND product = o_prod; if SQL%NOTFOUND then INSERT INTO SALES_PER_DATE VALUES (o_date, o_prod, :NEW.qty, :NEW.amount); end if; END; 49
50 Procedure 와 Trigger 의차이점 50
51 Summary Indexes facilitate data retrieval from the database Security is provided in SQL systems using the GRANT and REVOKE commands Entity integrity: no field that is part of the primary key can accept null values Referential integrity: value in any foreign key field must be null or must match an actual value in the primary key field of another table Legal-values integrity: value entered in a field must be one of the legal values that satisfies some particular condition 51
52 Summary (continued) ALTER TABLE command allows you to add fields to a table, delete fields, or change the characteristics of fields DROP TABLE command lets you delete a table from a database System catalog stores information about the structure of a database Stored procedure: query saved in a file that users can execute later Trigger: action that occurs automatically in response to an associated database operation such as an INSERT, UPDATE, or DELETE 52
Concepts of Database Management Seventh Edition. Chapter 4 The Relational Model 3: Advanced Topics
Concepts of Database Management Seventh Edition Chapter 4 The Relational Model 3: Advanced Topics Views View: application program s or individual user s picture of the database Less involved than full
More informationTHE RELATIONAL MODEL 3: ADVANCED TOPICS
CHAPTER4 THE RELATIONAL MODEL 3: ADVANCED TOPICS LEARNING OBJECTIVES Define, describe, and use views Use indexes to improve database performance Examine the security features of a DBMS Discuss entity,
More informationUsing DDL Statements to Create and Manage Tables. Copyright 2004, Oracle. All rights reserved.
Using DDL Statements to Create and Manage Tables Copyright 2004, Oracle. All rights reserved. Objectives After completing this lesson, you should be able to do the following: Categorize the main database
More informationChapter 1 SQL and Data
Chapter 1 SQL and Data What is SQL? Structured Query Language An industry-standard language used to access & manipulate data stored in a relational database E. F. Codd, 1970 s IBM 2 What is Oracle? A relational
More informationCHAPTER4 CONSTRAINTS
CHAPTER4 CONSTRAINTS LEARNING OBJECTIVES After completing this chapter, you should be able to do the following: Explain the purpose of constraints in a table Distinguish among PRIMARY KEY, FOREIGN KEY,
More informationUsing DDL Statements to Create and Manage Tables. Copyright 2004, Oracle. All rights reserved.
Using DDL Statements to Create and Manage Tables Copyright 2004, Oracle. All rights reserved. Objectives After completing this lesson, you should be able to do the following: Categorize the main database
More informationUsing DDL Statements to Create and Manage Tables. Copyright 2006, Oracle. All rights reserved.
Using DDL Statements to Create and Manage Tables Objectives After completing this lesson, you should be able to do the following: Categorize the main database objects Review the table structure List the
More informationCreating and Managing Tables Schedule: Timing Topic
9 Creating and Managing Tables Schedule: Timing Topic 30 minutes Lecture 20 minutes Practice 50 minutes Total Objectives After completing this lesson, you should be able to do the following: Describe the
More informationModule 9: Managing Schema Objects
Module 9: Managing Schema Objects Overview Naming guidelines for identifiers in schema object definitions Storage and structure of schema objects Implementing data integrity using constraints Implementing
More informationFull file at
SQL for SQL Server 1 True/False Questions Chapter 2 Creating Tables and Indexes 1. In order to create a table, three pieces of information must be determined: (1) the table name, (2) the column names,
More informationChapter 7. Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel
Chapter 7 Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel 1 In this chapter, you will learn: The basic commands
More informationChapter 2. DB2 concepts
4960ch02qxd 10/6/2000 7:20 AM Page 37 DB2 concepts Chapter 2 Structured query language 38 DB2 data structures 40 Enforcing business rules 49 DB2 system structures 52 Application processes and transactions
More informationDatabase Foundations. 6-3 Data Definition Language (DDL) Copyright 2015, Oracle and/or its affiliates. All rights reserved.
Database Foundations 6-3 Roadmap You are here Introduction to Oracle Application Express Structured Query Language (SQL) Data Definition Language (DDL) Data Manipulation Language (DML) Transaction Control
More informationProgramming the Database
Programming the Database Today s Lecture 1. Stored Procedures 2. Functions BBM471 Database Management Systems Dr. Fuat Akal akal@hacettepe.edu.tr 3. Cursors 4. Triggers 5. Dynamic SQL 2 Stored Procedures
More informationCSC 261/461 Database Systems Lecture 6. Fall 2017
CSC 261/461 Database Systems Lecture 6 Fall 2017 Use of WITH The WITH clause allows a user to define a table that will only be used in a particular query (not available in all SQL implementations) Used
More informationOracle Create Table Foreign Key On Delete No
Oracle Create Table Foreign Key On Delete No Action Can I create a foreign key against only part of a composite primary key? For example, if you delete a row from the ProductSubcategory table, it could
More informationSQL Interview Questions
SQL Interview Questions SQL stands for Structured Query Language. It is used as a programming language for querying Relational Database Management Systems. In this tutorial, we shall go through the basic
More informationEGCI 321: Database Systems. Dr. Tanasanee Phienthrakul
1 EGCI 321: Database Systems Dr. Tanasanee Phienthrakul 2 Chapter 10 Data Definition Language (DDL) 3 Basic SQL SQL language Considered one of the major reasons for the commercial success of relational
More informationWhere Are We? Next Few Lectures. Integrity Constraints Motivation. Constraints in E/R Diagrams. Keys in E/R Diagrams
Where Are We? Introduction to Data Management CSE 344 Lecture 15: Constraints We know quite a bit about using a DBMS Start with real-world problem, design ER diagram From ER diagram to relations -> conceptual
More informationEE221 Databases Practicals Manual
EE221 Databases Practicals Manual Lab 1 An Introduction to SQL Lab 2 Database Creation and Querying using SQL Assignment Data Analysis, Database Design, Implementation and Relation Normalisation School
More informationORACLE VIEWS ORACLE VIEWS. Techgoeasy.com
ORACLE VIEWS ORACLE VIEWS Techgoeasy.com 1 Oracle VIEWS WHAT IS ORACLE VIEWS? -A view is a representation of data from one or more tables or views. -A view is a named and validated SQL query which is stored
More informationChapter 4. Basic SQL. Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley
Chapter 4 Basic SQL Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 4 Outline SQL Data Definition and Data Types Specifying Constraints in SQL Basic Retrieval Queries
More informationSolved MCQ on fundamental of DBMS. Set-1
Solved MCQ on fundamental of DBMS Set-1 1) Which of the following is not a characteristic of a relational database model? A. Table B. Tree like structure C. Complex logical relationship D. Records 2) Field
More informationChapter # 7 Introduction to Structured Query Language (SQL) Part I
Chapter # 7 Introduction to Structured Query Language (SQL) Part I Introduction to SQL SQL functions fit into two broad categories: Data definition language Data manipulation language Basic command set
More informationCS6312 DATABASE MANAGEMENT SYSTEMS LABORATORY L T P C
CS6312 DATABASE MANAGEMENT SYSTEMS LABORATORY L T P C 0 0 3 2 LIST OF EXPERIMENTS: 1. Creation of a database and writing SQL queries to retrieve information from the database. 2. Performing Insertion,
More informationDatabase Systems: Design, Implementation, and Management Tenth Edition. Chapter 7 Introduction to Structured Query Language (SQL)
Database Systems: Design, Implementation, and Management Tenth Edition Chapter 7 Introduction to Structured Query Language (SQL) Objectives In this chapter, students will learn: The basic commands and
More information5 Integrity Constraints and Triggers
5 Integrity Constraints and Triggers 5.1 Integrity Constraints In Section 1 we have discussed three types of integrity constraints: not null constraints, primary keys, and unique constraints. In this section
More informationENHANCING DATABASE PERFORMANCE
ENHANCING DATABASE PERFORMANCE Performance Topics Monitoring Load Balancing Defragmenting Free Space Striping Tables Using Clusters Using Efficient Table Structures Using Indexing Optimizing Queries Supplying
More informationCSE 530A. Inheritance and Partitioning. Washington University Fall 2013
CSE 530A Inheritance and Partitioning Washington University Fall 2013 Inheritance PostgreSQL provides table inheritance SQL defines type inheritance, PostgreSQL's table inheritance is different A table
More informationChapter 17: Table & Integrity Contraints. Informatics Practices Class XII. By- Rajesh Kumar Mishra. KV No.1, AFS, Suratgarh
Chapter 17: Table & Integrity Contraints Informatics Practices Class XII By- Rajesh Kumar Mishra PGT (Comp.Sc.) KV No.1, AFS, Suratgarh e-mail : rkmalld@gmail.com Integrity Constraints One of the major
More informationLecture 07. Spring 2018 Borough of Manhattan Community College
Lecture 07 Spring 2018 Borough of Manhattan Community College 1 SQL Identifiers SQL identifiers are used to identify objects in the database, such as table names, view names, and columns. The ISO standard
More informationTable of Contents. PDF created with FinePrint pdffactory Pro trial version
Table of Contents Course Description The SQL Course covers relational database principles and Oracle concepts, writing basic SQL statements, restricting and sorting data, and using single-row functions.
More informationDatabase Management Systems
Database Management Systems Associate Professor Dr. Raed Ibraheem Hamed University of Human Development, College of Science and Technology Computer Science Department 2015 2016 Department of Computer Science
More informationSQL functions fit into two broad categories: Data definition language Data manipulation language
Database Principles: Fundamentals of Design, Implementation, and Management Tenth Edition Chapter 7 Beginning Structured Query Language (SQL) MDM NUR RAZIA BINTI MOHD SURADI 019-3932846 razia@unisel.edu.my
More informationSQL language. Jaroslav Porubän, Miroslav Biňas, Milan Nosáľ (c)
SQL language Jaroslav Porubän, Miroslav Biňas, Milan Nosáľ (c) 2011-2016 SQL - Structured Query Language SQL is a computer language for communicating with DBSM Nonprocedural (declarative) language What
More informationOracle Syllabus Course code-r10605 SQL
Oracle Syllabus Course code-r10605 SQL Writing Basic SQL SELECT Statements Basic SELECT Statement Selecting All Columns Selecting Specific Columns Writing SQL Statements Column Heading Defaults Arithmetic
More informationB.H.GARDI COLLEGE OF MASTER OF COMPUTER APPLICATION. Ch. 1 :- Introduction Database Management System - 1
Basic Concepts :- 1. What is Data? Data is a collection of facts from which conclusion may be drawn. In computer science, data is anything in a form suitable for use with a computer. Data is often distinguished
More informationCourse Outline and Objectives: Database Programming with SQL
Introduction to Computer Science and Business Course Outline and Objectives: Database Programming with SQL This is the second portion of the Database Design and Programming with SQL course. In this portion,
More informationInterview Questions on DBMS and SQL [Compiled by M V Kamal, Associate Professor, CSE Dept]
Interview Questions on DBMS and SQL [Compiled by M V Kamal, Associate Professor, CSE Dept] 1. What is DBMS? A Database Management System (DBMS) is a program that controls creation, maintenance and use
More informationIBM DB2 UDB V7.1 Family Fundamentals.
IBM 000-512 DB2 UDB V7.1 Family Fundamentals http://killexams.com/exam-detail/000-512 Answer: E QUESTION: 98 Given the following: A table containing a list of all seats on an airplane. A seat consists
More informationD B M G. SQL language: basics. Managing tables. Creating a table Modifying table structure Deleting a table The data dictionary Data integrity
SQL language: basics Creating a table Modifying table structure Deleting a table The data dictionary Data integrity 2013 Politecnico di Torino 1 Creating a table Creating a table (1/3) The following SQL
More informationAssorted Topics Stored Procedures and Triggers Pg 1
Assorted Topics Stored Procedures and Triggers Pg 1 Stored Procedures and Triggers Ray Lockwood Points: A Stored Procedure is a user-written program stored in the database. A Trigger is a stored procedure
More informationData about data is database Select correct option: True False Partially True None of the Above
Within a table, each primary key value. is a minimal super key is always the first field in each table must be numeric must be unique Foreign Key is A field in a table that matches a key field in another
More informationBasic SQL. Basic SQL. Basic SQL
Basic SQL Dr Fawaz Alarfaj Al Imam Mohammed Ibn Saud Islamic University ACKNOWLEDGEMENT Slides are adopted from: Elmasri & Navathe, Fundamentals of Database Systems MySQL Documentation Basic SQL Structured
More informationOracle Tables TECHGOEASY.COM
Oracle Tables TECHGOEASY.COM 1 Oracle Tables WHAT IS ORACLE DATABASE TABLE? -Tables are the basic unit of data storage in an Oracle Database. Data is stored in rows and columns. -A table holds all the
More informationDatabase Programming - Section 10. Instructor Guide
Database Programming - Section 10 Instructor Guide Table of Contents...1 Lesson 1 - Defining NOT NULL and UNIQUE Constraints...1 What Will I Learn?...2 Why Learn It?...3...4 Try It / Solve It...13 Lesson
More informationRelational Data Structure and Concepts. Structured Query Language (Part 1) The Entity Integrity Rules. Relational Data Structure and Concepts
Relational Data Structure and Concepts Structured Query Language (Part 1) Two-dimensional tables whose attributes values are atomic. At every row-and-column position within the table, there always exists
More informationTo understand the concept of candidate and primary keys and their application in table creation.
CM0719: Database Modelling Seminar 5 (b): Candidate and Primary Keys Exercise Aims: To understand the concept of candidate and primary keys and their application in table creation. Outline of Activity:
More informationComp 5311 Database Management Systems. 4b. Structured Query Language 3
Comp 5311 Database Management Systems 4b. Structured Query Language 3 1 SQL as Data Definition Language Creates the Students relation. The type (domain) of each field is specified, and enforced by the
More informationCS2300: File Structures and Introduction to Database Systems
CS2300: File Structures and Introduction to Database Systems Lecture 14: SQL Doug McGeehan From Theory to Practice The Entity-Relationship Model: a convenient way of representing the world. The Relational
More informationIntroduction to Computer Science and Business
Introduction to Computer Science and Business This is the second portion of the Database Design and Programming with SQL course. In this portion, students implement their database design by creating a
More informationCOSC 304 Introduction to Database Systems SQL DDL. Dr. Ramon Lawrence University of British Columbia Okanagan
COSC 304 Introduction to Database Systems SQL DDL Dr. Ramon Lawrence University of British Columbia Okanagan ramon.lawrence@ubc.ca SQL Overview Structured Query Language or SQL is the standard query language
More informationChapter 4. Basic SQL. SQL Data Definition and Data Types. Basic SQL. SQL language SQL. Terminology: CREATE statement
Chapter 4 Basic SQL Basic SQL SQL language Considered one of the major reasons for the commercial success of relational databases SQL Structured Query Language Statements for data definitions, queries,
More informationLecture7: SQL Overview, Oracle Data Type, DDL and Constraints Part #2
IS220 : Database Fundamentals College of Computer and Information Sciences - Information Systems Dept. Lecture7: SQL Overview, Oracle Data Type, DDL and Constraints Part #2 Ref. Chapter6 Prepared by L.
More informationExample 1 - Create Horizontal View. Example 2 - Create Vertical View. Views. Views
Views Views RECALLS: View Dynamic result of one or more relational operations operating on the base relations to produce another relation. o Virtual relation that does not actually exist in the database
More information3.1. Keys: Super Key, Candidate Key, Primary Key, Alternate Key, Foreign Key
Unit 3: Types of Keys & Data Integrity 3.1. Keys: Super Key, Candidate Key, Primary Key, Alternate Key, Foreign Key Different Types of SQL Keys A key is a single or combination of multiple fields in a
More informationDownloaded from
Lesson 16: Table and Integrity Constraints Integrity Constraints are the rules that a database must follow at all times. Various Integrity constraints are as follows:- 1. Not Null: It ensures that we cannot
More informationDatabase Management System 9
Database Management System 9 School of Computer Engineering, KIIT University 9.1 Relational data model is the primary data model for commercial data- processing applications A relational database consists
More informationIBM EXAM QUESTIONS & ANSWERS
IBM 000-730 EXAM QUESTIONS & ANSWERS Number: 000-730 Passing Score: 800 Time Limit: 120 min File Version: 69.9 http://www.gratisexam.com/ IBM 000-730 EXAM QUESTIONS & ANSWERS Exam Name: DB2 9 Fundamentals
More information(ADVANCED) DATABASE SYSTEMS (DATABASE MANAGEMENTS) PROF. DR. HASAN HÜSEYİN BALIK (6 TH WEEK)
(ADVANCED) DATABASE SYSTEMS (DATABASE MANAGEMENTS) PROF. DR. HASAN HÜSEYİN BALIK (6 TH WEEK) 4. OUTLINE 4. Implementation 4.1 Introduction to SQL 4.2 Advanced SQL 4.3 Database Application Development 4.4
More informationOverview. Data Integrity. Three basic types of data integrity. Integrity implementation and enforcement. Database constraints Transaction Trigger
Data Integrity IT 4153 Advanced Database J.G. Zheng Spring 2012 Overview Three basic types of data integrity Integrity implementation and enforcement Database constraints Transaction Trigger 2 1 Data Integrity
More informationPASS4TEST. IT Certification Guaranteed, The Easy Way! We offer free update service for one year
PASS4TEST \ We offer free update service for one year Exam : 1z0-071 Title : Oracle Database 12c SQL Vendor : Oracle Version : DEMO Get Latest & Valid 1z0-071 Exam's Question and Answers 1 from Pass4test.
More informationFundamentals, Design, and Implementation, 9/e Copyright 2004 Database Processing: Fundamentals, Design, and Implementation, 9/e by David M.
Chapter 5 Database Design Elements of Database Design Fundamentals, Design, and Implementation, 9/e Chapter 5/2 The Database Design Process Create tables and columns from entities and attributes Select
More informationTranslation of ER-diagram into Relational Schema. Dr. Sunnie S. Chung CIS430/530
Translation of ER-diagram into Relational Schema Dr. Sunnie S. Chung CIS430/530 Learning Objectives Define each of the following database terms Relation Primary key Foreign key Referential integrity Field
More informationA <column constraint> is a constraint that applies to a single column.
Lab 7 Aim: Creating Simple tables in SQL Basic Syntax for create table command is given below: CREATE TABLE ( [DEFAULT ] [], {
More informationSlides by: Ms. Shree Jaswal
Slides by: Ms. Shree Jaswal A trigger is a statement that is executed automatically by the system as a side effect of a modification to the database. To design a trigger mechanism, we must: Specify the
More informationCreating Tables, Defining Constraints. Rose-Hulman Institute of Technology Curt Clifton
Creating Tables, Defining Constraints Rose-Hulman Institute of Technology Curt Clifton Outline Data Types Creating and Altering Tables Constraints Primary and Foreign Key Constraints Row and Tuple Checks
More informationConstraints. Primary Key Foreign Key General table constraints Domain constraints Assertions Triggers. John Edgar 2
CMPT 354 Constraints Primary Key Foreign Key General table constraints Domain constraints Assertions Triggers John Edgar 2 firstname type balance city customerid lastname accnumber rate branchname phone
More informationCPS 510 Data Base I. Query: find all SNRs whose scodes are greater than some SNRs whose name is CB.
11. ANY Query: find all SNRs whose scodes are greater than some SNRs whose name is CB. SQL: SELECT snr FROM s x WHERE scodes > ANY ( SELECT scode FROM s y WHERE y.sname= CB ); snr S2 S4 S5 12. ALL Query:
More information5. Single-row function
1. 2. Introduction Oracle 11g Oracle 11g Application Server Oracle database Relational and Object Relational Database Management system Oracle internet platform System Development Life cycle 3. Writing
More informationDatabase Technology. Topic 6: Triggers and Stored Procedures
Topic 6: Triggers and Stored Procedures Olaf Hartig olaf.hartig@liu.se Triggers What are Triggers? Specify actions to be performed by the DBMS when certain events and conditions occur Used to monitor the
More informationIndex. NOTE: Boldface numbers indicate illustrations or code listing; t indicates a table. 341
A access paths, 31 optimizing SQL and, 135, 135 access types, restricting SQL statements, JDBC setup and, 36-37, 37 accessing iseries data from a PC, 280-287, 280 accumulate running totals, 192-197, 193,
More informationDatabase Management System Dr. S. Srinath Department of Computer Science & Engineering Indian Institute of Technology, Madras Lecture No.
Database Management System Dr. S. Srinath Department of Computer Science & Engineering Indian Institute of Technology, Madras Lecture No. # 13 Constraints & Triggers Hello and welcome to another session
More information3ISY402 DATABASE SYSTEMS
3ISY402 DATABASE SYSTEMS - SQL: Data Definition 1 Leena Gulabivala Material from essential text: T CONNOLLY & C BEGG. Database Systems A Practical Approach to Design, Implementation and Management, 4th
More informationSample Question Paper
Sample Question Paper Marks : 70 Time:3 Hour Q.1) Attempt any FIVE of the following. a) List any four applications of DBMS. b) State the four database users. c) Define normalization. Enlist its type. d)
More informationChapter 8: Working With Databases & Tables
Chapter 8: Working With Databases & Tables o Working with Databases & Tables DDL Component of SQL Databases CREATE DATABASE class; o Represented as directories in MySQL s data storage area o Can t have
More information! Define terms. ! Interpret history and role of SQL. ! Write single table queries using SQL. ! Establish referential integrity using SQL
OBJECTIVES CHAPTER 6: INTRODUCTION TO SQL Modern Database Management 11 th Edition Jeffrey A. Hoffer, V. Ramesh, Heikki Topi! Define terms! Interpret history and role of SQL! Define a database using SQL
More informationHandout 6 CS-605 Spring 18 Page 1 of 7. Handout 6. Physical Database Modeling
Handout 6 CS-605 Spring 18 Page 1 of 7 Handout 6 Physical Database Modeling Purpose- translate the logical description of data into the technical specifications for storing and retrieving data Goal - create
More informationData Modelling and Databases. Exercise Session 7: Integrity Constraints
Data Modelling and Databases Exercise Session 7: Integrity Constraints 1 Database Design Textual Description Complete Design ER Diagram Relational Schema Conceptual Modeling Logical Modeling Physical Modeling
More informationPL/SQL. Exception. When the PL/SQL engine cannot execute the PLSQL block it raise an error. Every Oracle error has an error number
PL/SQL Exception When the PL/SQL engine cannot execute the PLSQL block it raise an error. Every Oracle error has an error number Exceptions must be handled by name. PL/SQL predefines some common Oracle
More informationMore SQL: Complex Queries, Triggers, Views, and Schema Modification
Chapter 5 More SQL: Complex Queries, Triggers, Views, and Schema Modification Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 5 Outline More Complex SQL Retrieval Queries
More informationDATA CONSTRAINT. Prepared By: Dr. Vipul Vekariya
DATA CONSTRAINT Prepared By: Dr. Vipul Vekariya What is constraint? Constraints enforce rules at the table level. Constraints prevent the deletion of a table if there are dependencies. There are two types
More informationCMP-3440 Database Systems
CMP-3440 Database Systems Logical Design Lecture 03 zain 1 Database Design Process Application 1 Conceptual requirements Application 1 External Model Application 2 Application 3 Application 4 External
More informationStandard Query Language. SQL: Data Definition Transparencies
Standard Query Language SQL: Data Definition Transparencies Chapter 6 - Objectives Data types supported by SQL standard. Purpose of integrity enhancement feature of SQL. How to define integrity constraints
More informationSQL Fundamentals. Chapter 3. Class 03: SQL Fundamentals 1
SQL Fundamentals Chapter 3 Class 03: SQL Fundamentals 1 Class 03: SQL Fundamentals 2 SQL SQL (Structured Query Language): A language that is used in relational databases to build and query tables. Earlier
More informationOracle Database: Introduction to SQL/PLSQL Accelerated
Oracle University Contact Us: Landline: +91 80 67863899 Toll Free: 0008004401672 Oracle Database: Introduction to SQL/PLSQL Accelerated Duration: 5 Days What you will learn This Introduction to SQL/PLSQL
More informationLab # 2. Data Definition Language (DDL) Eng. Alaa O Shama
The Islamic University of Gaza Faculty of Engineering Department of Computer Engineering ECOM 4113: Database Lab Lab # 2 Data Definition Language (DDL) Eng. Alaa O Shama October, 2015 Objective To be familiar
More informationUNIT-IV (Relational Database Language, PL/SQL)
UNIT-IV (Relational Database Language, PL/SQL) Section-A (2 Marks) Important questions 1. Define (i) Primary Key (ii) Foreign Key (iii) unique key. (i)primary key:a primary key can consist of one or more
More information1 Writing Basic SQL SELECT Statements 2 Restricting and Sorting Data
1 Writing Basic SQL SELECT Statements Objectives 1-2 Capabilities of SQL SELECT Statements 1-3 Basic SELECT Statement 1-4 Selecting All Columns 1-5 Selecting Specific Columns 1-6 Writing SQL Statements
More informationDATABASE DEVELOPMENT (H4)
IMIS HIGHER DIPLOMA QUALIFICATIONS DATABASE DEVELOPMENT (H4) Friday 3 rd June 2016 10:00hrs 13:00hrs DURATION: 3 HOURS Candidates should answer ALL the questions in Part A and THREE of the five questions
More informationLecture7: SQL Overview, Oracle Data Type, DDL and Constraints Part #2
Lecture7: SQL Overview, Oracle Data Type, DDL and Constraints Part #2 Ref. Chapter6 Prepared by L. Nouf Almujally & Aisha AlArfaj& L.Fatima Alhayan Colleg Comp Informa Scien Informa Syst D 1 IS220 : Database
More information: ADMINISTRATION I EXAM OBJECTIVES COVERED IN THIS CHAPTER:
4367c01.fm Page 1 Wednesday, April 6, 2005 8:14 AM Chapter 1 Oracle Database 10g Components and Architecture ORACLE DATABASE 10G: ADMINISTRATION I EXAM OBJECTIVES COVERED IN THIS CHAPTER: Installing Oracle
More informationE-R Diagram to Relational Schema. Translating Entity-Relationship to Relational Tables. Representing Weak Entity Sets. Representing Strong Entity Sets
E-R Diagram to Relational Schema Translating Entity-Relationship to Relational Tables Fall 2015 David Toman School of Computer Science University of Waterloo Main ideas: Each entity set maps to a new table
More informationCopyright 2016 Ramez Elmasri and Shamkant B. Navathe
CHAPTER 6 Basic SQL Slide 6-2 Chapter 6 Outline SQL Data Definition and Data Types Specifying Constraints in SQL Basic Retrieval Queries in SQL INSERT, DELETE, and UPDATE Statements in SQL Additional Features
More informationSQL Structured Query Language Introduction
SQL Structured Query Language Introduction Rifat Shahriyar Dept of CSE, BUET Tables In relational database systems data are represented using tables (relations). A query issued against the database also
More informationIntroduction to the Structured Query Language [ SQL ] (Significant Concepts)
Introduction to the Structured Query Language [ SQL ] (Significant Concepts) Learning Objectives This topic is intended to introduce the Structured Query Language (SQL). At the end of the topic it is desired
More informationOracle Database 10g: SQL Fundamentals I. Oracle Internal & Oracle Academy Use Only. Student Guide Volume 2. D17108GC30 Edition 3.0 January 2009 D57871
D17108GC30 Edition 3.0 January 2009 D57871 Oracle Database 10g: SQL Fundamentals I Student Guide Volume 2 Authors Salome Clement Chaitanya Koratamaddi Nancy Greenberg Technical Contributors and Reviewers
More information1 Prepared By Heena Patel (Asst. Prof)
Topic 1 1. What is difference between Physical and logical data 3 independence? 2. Define the term RDBMS. List out codd s law. Explain any three in detail. ( times) 3. What is RDBMS? Explain any tow Codd
More informationOracle EXAM - 1Z Oracle Database SQL Expert. Buy Full Product.
Oracle EXAM - 1Z0-047 Oracle Database SQL Expert Buy Full Product http://www.examskey.com/1z0-047.html Examskey Oracle 1Z0-047 exam demo product is here for you to test the quality of the product. This
More informationThe Relational Model
The Relational Model What is the Relational Model Relations Domain Constraints SQL Integrity Constraints Translating an ER diagram to the Relational Model and SQL Views A relational database consists
More information