









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Database Design, Relational Calculi, Domain Relational Calculus, Nonprocedural, Safety, Recursion in SQL, Query-by-example, QBE, Structure, Graphical, Two dimensional Syntax, Skeleton, Modification, Deletion, Insertion, Updates, Microsoft Access QBE, Aggregation, Entity-Relationship Model, Modeling, Entities, Relationship, Attributes, Properties, Relationship Sets, Relational Database Design, Schemas, Smaller Schemas, Decompose, Functional Dependency, Candidate Key, Lossy Decomposition, First No
Typology: Slides
1 / 17
This page cannot be seen from the preview
Don't miss anything!










Computing & Information Sciences CIS 560: Database System Concepts Wednesday, 20 Sep 2006 Kansas State University
KSOL course page: http://snipurl.com/va Course web site: http://www.kddresearch.org/Courses/Fall-2006/CIS Instructor home page: http://www.cis.ksu.edu/~bhsu
Reading for Next Class: Section 6.1 – 6.2, Silberschatz et al. , 5th^ edition
Computing & Information Sciences CIS 560: Database System Concepts Wednesday, 20 Sep 2006 Kansas State University
x 1 , x 2 , …, xn represent domain variables P represents a formula similar to that of the predicate calculus
Computing & Information Sciences CIS 560: Database System Concepts Wednesday, 20 Sep 2006 Kansas State University
Example Queries Example Queries
Find the names of all customers who have a loan from the Perryridge branch and the loan amount: f {< c, a > | ∃ l (< c, l > ∈ borrower ∧ ∃ b (< l, b, a > ∈ loan ∧ b = “Perryridge”))} f {< c, a > | ∃ l (< c, l > ∈ borrower ∧ < l, “ Perryridge ”, a > ∈ loan )}
{< c > | ∃ l, b, a (< c, l > ∈ borrower ∧ < l, b, a > ∈ loan ∧ a > 1200)}
Find the names of all customers who have a loan of over $
{< l , b, a > | < l , b, a > ∈ loan ∧ a > 1200}
Computing & Information Sciences CIS 560: Database System Concepts Wednesday, 20 Sep 2006 Kansas State University
Example Queries Example Queries
{< c > | ∃ s, n (< c, s, n > ∈ customer) ∧ ∀ x,y,z (< x, y, z > ∈ branch ∧ y = “Brooklyn”) ⇒ ∃ a,b (< x, y, z > ∈ account ∧ < c,a > ∈ depositor )}
Find the names of all customers who have an account at all branches located in Brooklyn:
{< c > | ∃ l ( < c, l > ∈ borrower ∧ ∃ b,a (< l, b, a > ∈ loan ∧ b = “Perryridge”)) ∨ ∃ a (< c, a > ∈ depositor ∧ ∃ b,n (< a, b, n > ∈ account ∧ b = “Perryridge”))}
Computing & Information Sciences CIS 560: Database System Concepts Wednesday, 20 Sep 2006 Kansas State University
Query-by-Example (QBE) Query-by-Example (QBE)
Computing & Information Sciences CIS 560: Database System Concepts Wednesday, 20 Sep 2006 Kansas State University
QBE — Basic Structure QBE — Basic Structure
Computing & Information Sciences CIS 560: Database System Concepts Wednesday, 20 Sep 2006 Kansas State University
QBE Skeleton Tables for the Bank ExampleQBE Skeleton Tables for the Bank Example
Computing & Information Sciences CIS 560: Database System Concepts Wednesday, 20 Sep 2006 Kansas State University
Query Example Query Example
Approach: for each customer, find the number of branches in Brooklyn at which they have accounts, and compare with total number of branches in Brooklyn QBE does not provide subquery functionality, so both above tasks have to be combined in a single query. Ö Can be done for this query, but there are queries that require subqueries and cannot always be expressed in QBE.
In the query on the next page f CNT.UNQ.ALL._ w specifies the number of distinct branches in Brooklyn. Note: The variable _ w is not connected to other variables in the query f CNT.UNQ.ALL._ z specifies the number of distinct branches in Brooklyn at which customer x has an account.
Computing & Information Sciences CIS 560: Database System Concepts Wednesday, 20 Sep 2006 Kansas State University
Deletion Query ExamplesDeletion Query Examples
For consistency, we have to delete information from loan and borrower tables
Computing & Information Sciences CIS 560: Database System Concepts Wednesday, 20 Sep 2006 Kansas State University
Deletion Query Examples (Cont.) Deletion Query Examples (Cont.)
Computing & Information Sciences CIS 560: Database System Concepts Wednesday, 20 Sep 2006 Kansas State University
Modification of the Database – InsertionModification of the Database – Insertion
Computing & Information Sciences CIS 560: Database System Concepts Wednesday, 20 Sep 2006 Kansas State University
Modification of the Database – Insertion (Cont.) Modification of the Database – Insertion (Cont.)
Provide as a gift for all loan customers of the Perryridge branch, a new $200 savings account for every loan account they have, with the loan number serving as the account number for the new savings account.
Computing & Information Sciences CIS 560: Database System Concepts Wednesday, 20 Sep 2006 Kansas State University
An Example Query in Microsoft Access QBE An Example Query in Microsoft Access QBE
Example query: Find the customer_name , account_number and balance for all accounts at the Perryridge branch
Computing & Information Sciences CIS 560: Database System Concepts Wednesday, 20 Sep 2006 Kansas State University
An Aggregation Query in Access QBE An Aggregation Query in Access QBE
Find the name, street and city of all customers who have more than one account at the bank
Computing & Information Sciences CIS 560: Database System Concepts Wednesday, 20 Sep 2006 Kansas State University
Aggregation in Access QBE Aggregation in Access QBE
which attributes are group by attributes which attributes are to be aggregated upon (and the aggregate function). For attributes that are neither group by nor aggregated, we can still specify conditions by selecting where in the Total row and listing the conditions below
Computing & Information Sciences CIS 560: Database System Concepts Wednesday, 20 Sep 2006 Kansas State University
Banking ExampleBanking Example
Computing & Information Sciences CIS 560: Database System Concepts Wednesday, 20 Sep 2006 Kansas State University
Entity SetsEntity Sets^ customercustomer^ andand loanloan customer_id customer_ customer_ customer_ loan_ amount name street city number
Computing & Information Sciences CIS 560: Database System Concepts Wednesday, 20 Sep 2006 Kansas State University
Relationship Sets Relationship Sets
Example: (Hayes, A-102) ∈ depositor
Computing & Information Sciences CIS 560: Database System Concepts Wednesday, 20 Sep 2006 Kansas State University
Relationship SetRelationship Set borrowerborrower
Computing & Information Sciences CIS 560: Database System Concepts Wednesday, 20 Sep 2006 Kansas State University
Relational Database DesignRelational Database Design
Computing & Information Sciences CIS 560: Database System Concepts Wednesday, 20 Sep 2006 Kansas State University
A Combined Schema Without RepetitionA Combined Schema Without Repetition
loan_amt_br = ( loan_number , amount , branch_name )
Computing & Information Sciences CIS 560: Database System Concepts Wednesday, 20 Sep 2006 Kansas State University
What About Smaller Schemas?What About Smaller Schemas?
z Suppose we had started with bor_loan. How would we know to split up ( decompose ) it into borrower and loan? z Write a rule “if there were a schema ( loan_number, amount ), then loan_number would be a candidate key” z Denote as a functional dependency : loan_number → amount z In bor_loan , because loan_number is not a candidate key, the amount of a loan may have to be repeated. This indicates the need to decompose bor_loan. z Not all decompositions are good. Suppose we decompose employee into employee1 = ( employee_id , employee_name ) employee2 = ( employee_name , telephone_number , start_date ) z The next slide shows how we lose information -- we cannot reconstruct the original employee relation -- and so, this is a lossy decomposition.
Computing & Information Sciences CIS 560: Database System Concepts Wednesday, 20 Sep 2006 Kansas State University
A Lossy Decomposition A Lossy Decomposition
Computing & Information Sciences CIS 560: Database System Concepts Wednesday, 20 Sep 2006 Kansas State University
First Normal Form First Normal Form
Examples of non-atomic domains: Ö Set of names, composite attributes Ö Identification numbers like CS101 that can be broken up into parts
Example: Set of accounts stored with each customer, and set of owners stored with each account We assume all relations are in first normal form (and revisit this in Chapter 9)