1. Explain the following concepts: (a) superkey (b) key

Slides:



Advertisements
Similar presentations
Exercise 2 Relational Calculus
Advertisements

Fundamentals of Database Systems Fourth Edition El Masri & Navathe
The Relational Calculus
Database System - Assignment #3 Sept. 2012Yangjun Chen ACS Assignment #3 due Wed., Nov. 14, (30) Exercise 7.17 on Page 235 Show the result.
Defined by Edgar Codd in 1970 Defined by Edgar Codd in 1970 Considered ingenious but impractical Considered ingenious but impractical Conceptually simple.
Copyright © 2004 Ramez Elmasri and Shamkant Navathe Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition Chapter 15-1 Query Processing and.
Relational Database. Relational database: a set of relations Relation: made up of 2 parts: − Schema : specifies the name of relations, plus name and type.
COMPANY schema EMPLOYEE
File Organizations Sept. 2012Yangjun Chen ACS Outline: Hashing (5.9, 5.10, 3 rd. ed.; 13.8, 4 th, 5 th ed.; 17.8, 6 th ed.) external hashing static.
OUTLINE OF THE LECTURE PART I GOAL: Understand the Data Definition Statements in Fig 4.1 Step1: Columns of the Tables and Data types. Step2: Single column.
1 CSE 480: Database Systems Lecture 22: Query Optimization Reference: Read Chapter 15.6 – 15.8 of the textbook.
The Relational Algebra
Database technology Lecture 2: Relational databases and SQL
Company Database. CREATE TABLE DEPARMENT ( DNAME VARCHAR(10) NOT NULL, DNUMBER INTEGER NOT NULL, MGRSSN CHAR(9), MGRSTARTDATE CHAR(9), PRIMARY KEY (DNUMBER),
Exploring Microsoft Access 2003 Chapter 4 Proficiency: Relational Databases, External Data, Charts, Pivot, and the Switchboard.
- relation schema, relations - database schema, database state
Review Database Application Development Access Database Development ER-diagram Forms Reports Queries.
Analysis of Midterm-Examination Jan. 2010ACS-7102 Yangjun Chen1 1.(15) Draw an ER-diagram to describe the following real world problem. (a)A university.
Jyh-haw Yeh Dept. of Computer Science Boise State University
Database: Review Sept. 2009Yangjun Chen ACS Database Introduction system architecture, Basic concepts, ER-model, Data modeling, B+-tree Hashing Relational.
Relational Data Model Sept. 2014Yangjun Chen ACS Outline: Relational Data Model Relational Data Model -relation schema, relations -database schema,
관계 연산자 & SQL. Selection SELECT * FROM r WHERE A=B AND D>5.
Review: Application of Database Systems
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Chapter 7 Relational Database Design by ER- Mapping.
Relational Algebra - Chapter (7th ed )
Query Processing and Optimization
Retrieve the names of all employees in department 5 who work more than 10 hours per week on the ‘ProductX’ project. p10ssn ← (Π essn (σ hours > 10 (works-on.
 Employee (fname, minit, lname, ssn, bdate, address, sex, salary, superssn, dno)  Department (dname, dnumber, mgrssn, mgrstartdate) 
Database Management Systems. NESTING OF QUERIES  Some queries require that existing values in the database be retrieved and then used in a comparison.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 340 Introduction to Database Systems.
Logical Design database design. Dr. Mohamed Osman Hegaz2 Conceptual Database Designing –Provides concepts that are close to the way many users perceive.
File Organizations Jan. 2008Yangjun Chen ACS Outline: Hashing (5.9, 5.10, 3 rd. ed.; 13.8, 4 th ed.) external hashing static hashing & dynamic hashing.
Analysis of Midterm-Examination Oct. 22, 2014ACS-7102 Yangjun Chen1 1.(15) Draw an ER-diagram to describe the following real world problem. (a)A university.
Review Database Application Development Access Database Development Theory Practice.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 340 Introduction to Database Systems.
603 Database Systems Senior Lecturer: Laurie Webster II, M.S.S.E.,M.S.E.E., M.S.BME, Ph.D., P.E. Lecture 11 A First Course in Database Systems.
Mapping ER Diagrams to Tables
603 Database Systems Senior Lecturer: Laurie Webster II, M.S.S.E.,M.S.E.E., M.S.BME, Ph.D., P.E. Lecture 16 A First Course in Database Systems.
Analysis of Midterm-Examination Oct. 21, 2013ACS-7102 Yangjun Chen1 1.(15) Draw an ER-diagram to describe the following real world problem. (a)A university.
Constraints and Views Chap. 3-5 continued (7 th ed. 5-7)
The SQL Database Grammar
CS580 Advanced Database Topics
Introduction to the database systems (1)
6/22/2018.
CS580 Advanced Database Topics
Database Design The Relational Model Text Ch5
Relational Database Design by ER- and EER-to-Relational Mapping
Chapter (9) ER and EER-to-Relational Mapping, and other Relational Languages Objectives How a relational database schema can be created from a conceptual.
Chapter (9) ER and EER-to-Relational Mapping, and other Relational Languages Objectives How a relational database schema can be created from a conceptual.
376a. Database Design Dept. of Computer Science Vassar College
Mapping ER Diagrams to Tables
Outline: Relational Data Model
Joining Tables ضم الجداول وإستخراج مناظر views منها الهدف : 1- استخراج المعلومات من جدولين أو اكثر بالإستفادة من الرابط بينهما وبإستخدام SQL 2- شروط قواعد.
Company Requirements.
Outline: Database Basics
CS4222 Principles of Database System
Foreign key (FK) is defined as follows:
static hashing & dynamic hashing hash function
(a) A university is organized into faculties.
Relational Database Design by ER- and EER-to-Relational Mapping
Review: Application of Database Systems
1.(5) Describe the working process with a database system.
ISC321 Database Systems I Chapter 4: SQL: Data definition, Constraints, and Basic Queries and Updates Fall 2015 Dr. Abdullah Almutairi.
Mapping an ERD to a Relational Database
(a) A university is organized into faculties.
1. Explain the following concepts of the ER data model:
Chapter (7) ER-to-Relational Mapping, and other Relational Languages
SQL: Set Operations & Nested Queries. Presented by: Dr. Samir Tartir
Answers to Midterm - Exam. Feb. 28, 2018
Answers to Midterm - Exam. Feb. 27, 2006
Presentation transcript:

1. Explain the following concepts: (a) superkey (b) key (c) candidate key (d) primary key (e) foreign key key constraints a superkey is any combination of attributes that uniquely identify a tuple: t1[superkey]  t2[superkey]. a key is superkey that has a minimal set of attributes Sept. 2004 91.3902 Yangjun Chen

one candidate key is chosen as the primary key (PK) If a relation schema has more than one key, each of them is called a candidate key. one candidate key is chosen as the primary key (PK) foreign key (FK) is defined as follows: i) Consider two relation schemas R1 and R2; ii) The attributes in FK in R1 have the same domain(s) as the primary key attributes PK in R2; the attributes FK are said to reference or refer to the relation R2; iii) A value of FK in a tuple t1 of the current state r(R1) either occurs as a value of PK for some tuple t2 in the current state r(R2) or is null. In the former case, we have t1[FK] = t2[PK], and we say that the tuple t1 references or refers to the tuple t2. Sept. 2004 91.3902 Yangjun Chen

2. Draw an ER-diagram to describe the following real world problem. (a) A university is organized into faculties. (b) Each faculty has a unique name, ID and number of professors and a specific professor is chosen as the faculty head. (c) Each faculty provides a number of courses. (d) Each course has a unique name and courseID. (e) Each professor has a name, SIN, address, salary, sex and courses taught by him/her. (f) Each professor belongs to a faculty and can teach several sections of a course. (g) Each student has a name, ID, SIN, address, GPA, sex, and major. (h) Each student can choose one faculty as his/her major faculty and take several courses with certain credit hours. Some of the courses are mandatory and some are optional. Sept. 2004 91.3902 Yangjun Chen

ER-model: professor faculty course student belong teach head provide salary name ID addr. SIN belong N 1 professor NoProf F-Id sex F-name M startdate 1 teach section-IDs faculty head 1 M N couresId 1 provide N course name choose N ID N addr. SIN take M student major mandatory-optional creditHours name sex birthdate Sept. 2004 91.3902 Yangjun Chen

- collision resolution strategy: chaining 3. Linear Hashing - collision resolution strategy: chaining - split rule: load factor > 0.7 - initially M = 4 (M: size of the primary area) - hash functions: hi(key) = key mod 2i  M (i = 0, 1, 2, …) - bucket capacity = 2 Trace the insertion process of the following keys into a linear hashing file: 24, 7, 10, 5, 14, 4, 1, 8, 2, 3, 17, 13, 15. Sept. 2004 91.3902 Yangjun Chen

when inserting the sixth record we would have The first phase – phase0 when inserting the sixth record we would have but the load factor 6/8= 0.75 > 0.70 and so bucket 0 must be split (using h1 = Key mod 2M): 24 4 5 10 14 7 n=0 before the split (n is the point to the bucket to be split.) 0 1 2 3 24 5 10 14 7 4 n=1 after the split load factor: 6/10=0.6 no split 0 1 2 3 4 Sept. 2004 91.3902 Yangjun Chen

24 5 10 14 7 4 0 1 2 3 4 n=1 load factor: 7/10=0.7 no split 24 5 1 10 insert(1) 24 5 10 14 7 4 0 1 2 3 4 n=1 load factor: 7/10=0.7 no split 24 5 1 10 14 7 4 0 1 2 3 4 Sept. 2004 91.3902 Yangjun Chen

24 5 1 10 14 7 4 0 1 2 3 4 n=1 load factor: 8/10=0.8 split using h1. insert(8) 24 5 1 10 14 7 4 0 1 2 3 4 n=1 load factor: 8/10=0.8 split using h1. 24 8 5 1 10 14 7 4 Sept. 2004 91.3902 Yangjun Chen

24 8 1 10 14 7 4 5 0 1 2 3 4 5 n=2 load factor: 8/12=0.66 no split 24 0 1 2 3 4 5 n=2 load factor: 8/12=0.66 no split insert(2) 24 8 1 10 14 7 4 5 0 1 2 3 4 5 Sept. 2004 91.3902 Yangjun Chen

24 8 1 10 14 7 4 5 n=2 load factor: 9/12=0.75 split using h1. 2 overflow 2 0 1 2 3 4 5 24 8 1 10 2 7 4 5 14 Sept. 2004 91.3902 Yangjun Chen

insert(3) 24 8 1 10 2 7 4 5 14 24 8 1 10 2 7 3 4 5 14 n=3 load factor: 10/14=0.714 split.using h1. Sept. 2004 91.3902 Yangjun Chen

The second phase – phase1 n = 0; using h1 = Key mod 2M to insert and 24 8 1 10 2 3 4 5 14 7 n=4 The second phase – phase1 n = 0; using h1 = Key mod 2M to insert and h2 = Key mod 4M to split. insert(17) 8 24 1 10 2 3 4 5 14 7 Sept. 2004 91.3902 Yangjun Chen

8 24 1 17 10 2 3 4 5 14 7 n=0 load factor: 11/16=0.687 no split. 8 24 insert(13) 8 24 1 17 10 2 3 4 5 14 7 Sept. 2004 91.3902 Yangjun Chen

8 24 1 17 10 2 3 4 5 13 14 7 n=0 load factor: 12/16=0.75 split bucket 0, using h2. 1 17 10 2 3 4 5 13 14 7 8 24 Sept. 2004 91.3902 Yangjun Chen

insert(15) 1 17 10 2 3 4 5 13 14 7 8 24 1 17 10 2 3 4 5 13 14 7 15 8 24 n=1 load factor: 13/18=0.722 split bucket 1, using h2. 1 17 10 2 3 4 5 13 14 7 15 8 24 Sept. 2004 91.3902 Yangjun Chen

Here, we assume that each internal node can contain at most two 4. Given the following B+-tree, trace the deletion sequence: h, c, e, f. Here, we assume that each internal node can contain at most two keys and each leaf node can contain at most two value/point pairs. c b e a b c e f h Sept. 2004 91.3902 Yangjun Chen

f e a b c f e a c b Sept. 2004 91.3902 Yangjun Chen

c a e a b f a e a b f a b a Sept. 2004 91.3902 Yangjun Chen

5. Given the relation schemas shown in Fig. 1, construct expressions (using relational algebraic operations) to evaluate the following query: Find the names of employees who works on all the projects controlled by department Number ‘Business Computing’. EMPLOYEE fname, minit, lname, ssn, bdate, address, sex, salary, superssn, dno DEPARTMENT Dname, dnumber, mgrssn, mgrstartdate PROJECT WORKS_ON Pname, pnumber, plocation, dnum Essn pno, hours Sept. 2004 91.3902 Yangjun Chen

: DN dnumber(Dname = ‘Business Computing’(Department)) DEPT_P PNUMBER(DNDN.dnumber = PROJECT.dnumber(PROJECT)) EMP_PNOS  ESSN,PNO(WORK_ON) SSNS EMP_PNOS : DEPT_P RESULT  FNAME, LNAME(SSNS * EMPLOYEE) Sept. 2004 91.3902 Yangjun Chen

Pname, pnumber, plocation, dnum 6. Given the relation schemas as shown in Fig. 2, construct a SQL clause to evaluate the following query: For each department, retrieve the department number, the department name, the depatment manager, and the number of employees who work in that department. PROJECT WORKS ON Pname, pnumber, plocation, dnum Essn pno, hours Sept. 2004 91.3902 Yangjun Chen

SELECT x.Dname, x.dnumber, z.fname, z.lname, count(y.ssn) FROM department x, employee y, employee z WHERE x.Dnumber=y.dno and x.mgrssn=z.ssn Group by x.dnumber The following SQL statement is wrong. SELECT Dname, dnumber, fname, lname, count(ssn) FROM department , employee WHERE Dnumber=dno and mgrssn=ssn Group by dnumber Sept. 2004 91.3902 Yangjun Chen

4. Trace the insertion process of the following keys into an empty b+-tree: 7, 6, 5, 3, 1, 2. Here, we assume that each internal node can contain at most two keys and each leaf node can contain at most two value/point pairs. 7 6 7 Sept. 2004 91.3902 Yangjun Chen

5 6 7 5 5 6 3 5 7 6 Sept. 2004 91.3902 Yangjun Chen

5 3 6 1 3 5 6 7 3 6 2 3 3 5 1 2 6 7 Sept. 2004 91.3902 Yangjun Chen