Principles of Database Systems Yunsheng Liu. YSLiu-DBS-Exercise 2 Exercise 1 1.Please give at least four main differences between a DBMS and a file system.

Slides:



Advertisements
Similar presentations
COP4540 Database Management System Midterm Review
Advertisements

Chapter 10: Designing Databases
Chapter 12 File Processing and Data Management Concepts
Relational Database. Relational database: a set of relations Relation: made up of 2 parts: − Schema : specifies the name of relations, plus name and type.
Review for Final Exam Lecture Week 14. Problems on Functional Dependencies and Normal Forms.
©Silberschatz, Korth and Sudarshan4.1Database System Concepts Lecture-1 Database system,CSE-313, P.B. Dr. M. A. Kashem Associate. Professor. CSE, DUET,
(Uses slides from Fernando Farfan and Eduardo J. Ruiz
Normalization Dr. Mario Guimaraes. Data Normalization Primarily a tool to validate and improve a logical design so that it satisfies certain constraints.
SQL Lecture 10 Inst: Haya Sammaneh. Example Instance of Students Relation  Cardinality = 3, degree = 5, all rows distinct.
Relational Algebra Ch. 7.4 – 7.6 John Ortiz. Lecture 4Relational Algebra2 Relational Query Languages  Query languages: allow manipulation and retrieval.
603 Database Systems Senior Lecturer: Laurie Webster II, M.S.S.E.,M.S.E.E., M.S.BME, Ph.D., P.E. Lecture 6 A First Course in Database Systems.
Database Management n Database Hierarchy n File-oriented Approach n Database-oriented Approach n DBMS n Entity Relationship Diagram n Data Structures.
The Relational Model System Development Life Cycle Normalisation
ETEC 100 Information Technology
COP5725 – Principles of Database Management Systems
1 Review #1 l Intro stuff –What is a database, 4 parts, 3 users, etc. l Architecture –Data independence –Three levels, two mappings –Jobs of the DBA.
Entity-Relationship Model and Diagrams (continued)
Department of Computer Science and Engineering, HKUST Slide 1 7. Relational Database Design.
Relation Decomposition A, A, … A 12n Given a relation R with attributes Create two relations R1 and R2 with attributes B, B, … B 12m C, C, … C 12l Such.
Entity/Relationship Modelling
Data Modeling Using the Entity-Relationship Model
DeSiamorewww.desiamore.com/ifm1 Database Management Systems (DBMS)  B. Computer Science and BSc IT Year 1.
Daniel AdinugrohoDatabase Programming 1 DATABASE PROGRAMMING Lecture on 29 – 04 – 2005.
Chapter 4 Relational Databases Copyright © 2012 Pearson Education, Inc. publishing as Prentice Hall 4-1.
Information storage: Introduction of database 10/7/2004 Xiangming Mu.
CST203-2 Database Management Systems Lecture 2. One Tier Architecture Eg: In this scenario, a workgroup database is stored in a shared location on a single.
Review for Midterm. Problem 2.7 HasPriPhy Patients address name ssn age Doctors exp_year name ssn specialty Pharmacies name address phone PharmCo name.
Distribution of Marks For Second Semester Internal Sessional Evaluation External Evaluation Assignment /Project QuizzesClass Attendance Mid-Term Test Total.
(C) 2000, The University of Michigan 1 Database Application Design Handout #4 January 28, 2000.
NormalizationNormalization Chapter 4. Purpose of Normalization Normalization  A technique for producing a set of relations with desirable properties,
SCUJ. Holliday - coen 1784–1 Schedule Today: u Normal Forms. u Section 3.6. Next u Relational Algebra. Read chapter 5 to page 199 After that u SQL Queries.
SQL Structured Query Language Programming Course.
THIRD NORMAL FORM (3NF) A relation R is in BCNF if whenever a FD XA holds in R, one of the following statements is true: XA is a trivial FD, or X is.
Query Processing and Optimization
Lecture2: Database Environment Prepared by L. Nouf Almujally & Aisha AlArfaj 1 Ref. Chapter2 College of Computer and Information Sciences - Information.
Physical Database Design I, Ch. Eick 1 Physical Database Design I About 25% of Chapter 20 Simple queries:= no joins, no complex aggregate functions Focus.
Assignements. CSC343: Intro. to Databases2 Exercise 1 Superkeys: Candidate keys: Primary key:
1 Chapter 1 Introduction. 2 Introduction n Definition A database management system (DBMS) is a general-purpose software system that facilitates the process.
1 Relational Databases and SQL. Learning Objectives Understand techniques to model complex accounting phenomena in an E-R diagram Develop E-R diagrams.
Lecture2: Database Environment Prepared by L. Nouf Almujally 1 Ref. Chapter2 Lecture2.
CS 1308 Computer Literacy and the Internet
Logical Database Design (1 of 3) John Ortiz Lecture 6Logical Database Design (1)2 Introduction  The logical design is a process of refining DB schema.
DeSiamorePowered by DeSiaMore1 Database Management Systems (DBMS)  B. Computer Science and BSc IT Year 1.
Msigwaemhttp//:msigwaem.ueuo.com/1 Database Management Systems (DBMS)  B. Computer Science and BSc IT Year 1.
Lecture No 14 Functional Dependencies & Normalization ( III ) Mar 04 th 2011 Database Systems.
COMP3030 Database Management System Final Review
Physical Database Design I, Ch. Eick 1 Physical Database Design I Chapter 16 Simple queries:= no joins, no complex aggregate functions Focus of this Lecture:
Introduction to Database System. 1. Define Database, Database Management System and Database System. Explain the components of DBMS with its advantages.
B. Information Technology (Hons.) CMPB245: Database Design Physical Design.
Databases Flat Files & Relational Databases. Learning Objectives Describe flat files and databases. Explain the advantages that using a relational database.
CSCI 6315 Applied Database Systems Review for Midterm Exam I Xiang Lian The University of Texas Rio Grande Valley Edinburg, TX 78539
CSC 411/511: DBMS Design Dr. Nan Wang 1 Schema Refinement and Normal Forms Chapter 19.
Formal definition of a key A key is a set of attributes A 1,..., A n such that for any other attribute B: A 1,..., A n  B A minimal key is a set of attributes.
Let try to identify the conectivity of these entity relationship
Assignements.
Relational Algebra Database Management Systems, 3rd ed., Ramakrishnan and Gehrke, Chapter 4.
Translation of ER-diagram into Relational Schema
Entity-Relationship Model and Diagrams (continued)
Chapter 2 Database Environment.
Question Which of the following plays an important role in representing information about the real world in a database? Explain briefly 1)DDL.
Exercise R(A,B,C,D) with FD’s ABC, CD, and DA
Database Modeling using Entity Relationship Model (E-R Model)
CS4222 Principles of Database System
Flat Files & Relational Databases
1.(5) Describe the working process with a database system.
Question 1: Basic Concepts (45 %)
1. Explain the following concepts of the ER data model:
Database Management system
Database Management system
Review #1 Intro stuff What is a database, 4 parts, 3 users, etc.
Presentation transcript:

Principles of Database Systems Yunsheng Liu

YSLiu-DBS-Exercise 2 Exercise 1 1.Please give at least four main differences between a DBMS and a file system 2.Explain the difference between subschema, conceptual schema and physical schema. 3.What are the logical and physical data independence? How are they related to the different layer schemas? 4.Explain the major components of a DBS 5.Illustrate the relations and differences between type and occurrence. 1.Please give at least four main differences between a DBMS and a file system 2.Explain the difference between subschema, conceptual schema and physical schema. 3.What are the logical and physical data independence? How are they related to the different layer schemas? 4.Explain the major components of a DBS 5.Illustrate the relations and differences between type and occurrence. Oct. 23, 2008

YSLiu-DBS-Exercise 3 Exercise 2 1.Explain the basic properties of the three classical data models, respectively, and the main differences among them. 2.Explain Entity, Relationship, Attribute and Key. And what are the relations between them 3.Use the E-R diagram to describe the data connected with an enterprise, including depts, projects, products and suppliers with their necessary attributes and indicating the keys. Oct. 16, 2008

YSLiu-DBS-Exercise 4 Exercise Please design an E-R diagram to represent the courses schedules in a university ( what kinds of information? ) 5.Please give an example of a complete E-R diagram and translate it into hierachical, network and relational schemas, respectivelt 6.Explain the relations and differences between  -join, equijoin and natural join. Nov. 3, 2007

YSLiu-DBS-Exercise 5 7.Give the following relatiom schemas : Empl (E#, Ename, Age, Address) Works (E#, Dname, Term, Salary) Dept (Dname, Office-building, Office-Phone) Manager (Mid, Dname, Phone) Please answer the following questions: (1). Give the primary key of each relation (2). Draw the E-R diagram corresponding to these relationsa Exercise 2-2

YSLiu-DBS-Exercise 6 (3). Express the following queries with relational algebra: a.Find the phone number of Planning Dept. b.Find the the names and ages of employees who are 20 ~ 35 years old. c.Find the the names and addresses of employees of Development Dept. d.Find the names of the department managers whose office are in building B-XYZ e.Find the phone number of the department within which 张三 works. Exercise 2-2

YSLiu-DBS-Exercise 7 8. What kinds of relational operations form a relational algebra? Why is it? 9. Let R, S be the relations shown as follows: R: A B S: B C a b b c d e c a b c e d Compute: (1) R∪S: (2)R ∩ S ; (3) R-S; (4) R⋈ S ; ( 5 )  A (R) ; (6)  A=C (R×S) ; (6) R ⋈ B < C S, where < represent alphabetic Exercise 2-3

YSLiu-DBS-Exercise 8 Exercise 2-4 A B C a b c b a d c a d R B C D b c d b c a a d c c d a S A’ B’ C’ b a d b c a a d c c a d S’ Compute: a). R ∪ S’ b). R-S’ c).  (Q, R ⋈ S) d).  B,C (S) e).  A=C (Q) f). R ⋈ S  Note: take < to be alphabetic order on letters R.B<S.B ∧ R.C=S.C 10. Let R, S and S ’ be the relations shown as follows:

YSLiu-DBS-Exercise 9 Exercise 3 1.Show the basic functions of a DBMS. 2.Show the main DBMS components with their functions and the relations between the components 3.What is metadata and DD, and why is DD necessary? 4.What are the main contents of a DD ? 5.Briefly describe the major processes of a DB accessing

YSLiu-DBS-Exercise 10 1.What are the performance measures of a disk, and their contents, respectively 2.What is a Block, its storage structure on a disk and access time? 3.Briefly describe the basic file organizing forms 4.Show the common and the different properties between B-tree and B + -tree Exercise 4

YSLiu-DBS-Exercise 11 5.Let ( 2, 3, 5, 7, 11, 17, 19, 23, 29, 31 ) be a key set. Please create B-trees and B + -trees of the following orders on the key set, respectively: a) Order2 b) Order3 c) Order4 6.On the B + -trees created in the above exercise5, show the B + -trees after the operations: Exercise 4-1 a)Inserting 9 , 10 , 8 b)Deleting 23 , 19

YSLiu-DBS-Exercise 12 7.Suppose that a file contains 20,000 records and the primary key is 40 bytes long. Let a pointers, including that pointing to blocks and to records, be 10 bytes long, a block size be 1,024 bytes. If create a B + -tree initially ( each node is loaded as full as possible), please answer the questions: a)How large is it suitable to select the order n of the B + -tree? b)What is the length, i.e. the levels, of the B + -tree? c)What are the numbers of the nodes on each level ? d)How high is the B + -tree if the loading factor of a block is 70% Exercise 4-2

YSLiu-DBS-Exercise 13 8.Suppose we have a bucket-hash file as shown in the figure. What will be happened and how can you do if the following operations occur : a)Insert the records R(g) ~ R(j) into the bucketB 0 ~ B 3, respectively. b)Delete the records R(a) and R(b). c)Insert the records R(k) ~ R(n) into the buckets B 0 ~ B 3, respectively d)Delete the records R(c) and R(d) 。 B0B0 R(d) B1B1 R(e) R(c) B2B2 R(b) B3B3 R(a)R(f) Exercise 4-3

YSLiu-DBS-Exercise 14 1.Write the queries in the exercise with SQL. 2.Consider the DB including the following information: Student (S#: integer, Sname: string, Dept: string, Age: integer) Enrolled (S#: integer, Cname: string, Grade: integer) Class (Name: string, Meeting: time, Room, Dept: string, Fid) Faculty (Fid: integer, Fname: string, Dpet: string) Write the following requests in SQL: Exercise 5

YSLiu-DBS-Exercise 15 a)Define the schema of the DB, including integrity constraints b)Find the age of the oldest student who is either in CS dept or enrolled in a course taught by T. Dragon c)Find the names of all classes that either meet in room E9-405 or have at least 50 students enrolled d)Find the names of all students who are enrolled in two classes met at the same time e)Print out the grade record of every student Exercise 5-1

YSLiu-DBS-Exercise 16 Exercise Consider the following relation schemas : Seller (S#, Sname, Address, Phone) Articles (A#, Aname, Price) Sell (S# , A# , Amount) Write SQL queries that print out:  the total amount and sum of each article sold by 张三  the average amount of each article sold by each seller at a time ;  the name and the amount of the article whose amount sold by 李四 is largest

YSLiu-DBS-Exercise 17 4.For the DB in the exercise 5.2, write SQL statements of the following updates: a)Delete all the classes that is taught by R.Jhon for dept CS. b)Delete all the information about faculty who have not yet taught any course c)Change the mane of course taught by T. Richard for his own dept into DB Implement d)Add a reenrollment record into Enrolled for every student who has not passed a course Exercise 5-3

YSLiu-DBS-Exercise 18 1.Describe the basic steps and their main tasks of database design 2.Design a teaching management DB which contains the following information:  Course (C#, Cname, Point, Dept, Description);  Student (S#, Sname, Dept, Adress);  Teacher (T#, Tname, Position, Dept, Phone);  Offering (C#, Term, Time, Room, T#). Please: Exercise 6

YSLiu-DBS-Exercise 19 Exercise 6 a)Design an E-R diagram for the DB b)Improved the E-R diagram designed in above a) to model the information about Enrollment and Grade Report. c)Please give your other E-R designs for the above b) if any. What are the advantages and disadvanetages of each of the E-R designs, and which is your favor and why

YSLiu-DBS-Exercise 20 Exercise Design a commercial DB that contains the following information:  Customer names, addresses and phones;  Merchandise names, types, prices, and quantities and dates that a customer purchases a item. Suppose that each customer has a different name and can buy the same items at different time. Please: 1). present the E-R model of the DB; 2). convert the E-R model into relation schemas and normalize them into 3NF relations

YSLiu-DBS-Exercise 21 1)The decomposition: {R 1 (A,B,C), R 2 (A,D,E)} is a lossless-join decomposition 2)The decomposition: {R 1 (A,B,C), R 2 (C,D,E)} is not a lossless-join decomposition 4.What is Relational Analysis and why needed ? 5.Present the definitions of 1NF ~ BCNF and the relationships among them 6.Suppose that we have the relation schema R(A,B,C,D,E) and its FDS: {A  BC, CD  E, B  D, E  A}. Show that Exercise 6-2

YSLiu-DBS-Exercise Give the relation schema R(A,B,C,D) and the followings: 1)FDS 1 : {C  D, B  C, C  A} 2)FDS 2 : {B  C, D  A} 3)FDS 3 : {ABC  D, D  A} 4)FDS 4 : {A  B, BC  D, A  C} 5)FDS 5 : {AB  C, AB  D, C  A, D  B} For each of the above FDS’, do a) identifying the candidate key(s) b) identifying the best NF that R satisfies c) if R is not in BCNF, decompose it into a set of BCNF relations. Exercise 6-3

YSLiu-DBS-Exercise 23 Exercise Let relation schema R(A , B , C , D , E) have a FDS {A → BC , CD → E , B → D , E → A}, Please: a)Proof { ( A, B, C) , (A, D, E)} is a loseless decomposition. b)Present a loseless decomposition of R into BCNF relations c)Prenset a loseless and dependency- proverving decomposition of R into 3NF relations.