(a) A university is organized into faculties.

Slides:



Advertisements
Similar presentations
COP4540 Database Management System Midterm Review
Advertisements

Exercise 2 Relational Calculus
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.
Relational Database. Relational database: a set of relations Relation: made up of 2 parts: − Schema : specifies the name of relations, plus name and type.
Entity-Relationship Models
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.
The Relational Algebra
1 XML DTD & XML Schema Monica Farrow G30
B + -Trees Sept. 2012Yangjun Chen ACS B + -Tree Construction and Record Searching in Relational DBs Chapter 6 – 3rd (Chap. 14 – 4 th, 5 th ed.; Chap.
Exploring Microsoft Access 2003 Chapter 4 Proficiency: Relational Databases, External Data, Charts, Pivot, and the Switchboard.
Data modeling using the entity-relationship model Sept. 2012Yangjun Chen ACS Outline: Data modeling using ER-model (Chapter 3 - 3rd, 4th, 5th ed.)
Semistructured-Data Model Sept. 2014Yangjun Chen ACS Semistructured-Data Model Semistructured data XML Document type definitions XML schema.
Programming Language for XML Sept. 2014Yangjun Chen ACS Programming Languages for XML XPath XQuery Extensible StyleSheets Language (XSLT)
Assignment #2 Sept. 2014Yangjun Chen ACS (20) The following is a DTD for books. Please produce an XML document conforming to the DTD.
Review Database Application Development Access Database Development ER-diagram Forms Reports Queries.
ACS-4902 Ron McFadyen Chapter 15 Algorithms for Query Processing and Optimization.
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.
CS 104 Introduction to Computer Science and Graphics Problems Introduction to Database (2) Basic SQL 12/05/2008 Yang Song.
Jyh-haw Yeh Dept. of Computer Science Boise State University
Assignment #2 Sept. 2014Yangjun Chen ACS (20) The following is a DTD for books. Please produce an XML document conforming to the DTD.
관계 연산자 & SQL. Selection SELECT * FROM r WHERE A=B AND D>5.
Logical DB Design 5. 1 CSE2132 Database Systems Week 5 Lecture Logical Database Design.
Review: Application of Database Systems
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Chapter 7 Relational Database Design by ER- Mapping.
Example Write the DTD rules for the following XML fragment. Kim 34 South Street NY USA Vice President $175,000 1.
1 CS 430 Database Theory Winter 2005 Lecture 12: SQL DML - SELECT.
Avoid using attributes? Some of the problems using attributes: Attributes cannot contain multiple values (child elements can) Attributes are not easily.
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) 
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.
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.
COMP3030 Database Management System Final Review
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.
Programming Languages for XML
Assignment #1 due Wed. Feb. 15, (15)
Query Processing and Optimization, and Database Tuning
Semistructured-Data Model
E-R Diagram (Cont.) Draw ER Diagram for the following scenario:
Database Design The Relational Model Text Ch5
Relational Database Design by ER- and EER-to-Relational Mapping
376a. Database Design Dept. of Computer Science Vassar College
Mapping ER Diagrams to Tables
Outline: Relational Data Model
Database Index Techniques
Company Requirements.
Outline: Database Basics
CS4222 Principles of Database System
Foreign key (FK) is defined as follows:
Assignment #3 Due: April 03, 2017
(a) A university is organized into faculties.
Relational Algebra Sample Questions.
Relational Database Design by ER- and EER-to-Relational Mapping
Assignment #2 Due: March 08, 2017
Review: Application of Database Systems
1. Explain the following concepts: (a) superkey (b) key
1.(5) Describe the working process with a database system.
Assignment #1 Due: Feb. 15, Apply the following algorithm to the B+-tree shown in Fig. 4 to store it in a data file. Trace the computation process.
1. Explain the following concepts of the ER data model:
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:

(a) A university is organized into faculties. 1.(15) 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. Feb. 15, 2012 ACS-7102 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 Feb. 15, 2012 ACS-7102 Yangjun Chen

memory) in a data file. (10) 2. (a) Give the algorithm to store a B+-tree (a linked list stored in main memory) in a data file. (10) (b) Apply the algorithm to the tree shown in Fig. 1 and give the result (i.e., the data file storing the tree). (10) 6 1 5 10 11 3 9 13 13 6 9 3 1 11 2 Feb. 15, 2012 ACS-7102 Yangjun Chen

Store a B+-tree on hard disk Algorithm: push(root, -1, -1); while (S is not empty) do { x := pop( ); store x.data in file F; assume that the address of x in F is ad; if x.address-of-parent  -1 then { y := x.address-of-parent; z := x.position; write ad in page y at position z in F; } let x1, …, xk be the children of v; for (i = k to 1) {push(xi, ad, i)}; data address-of- parent position stack: S Jan. 2010 Feb. 15, 2012 ACS-7102 Yangjun Chen ACS-7102 Yangjun Chen 4

6 1 5 10 11 3 9 13 13 6 9 3 1 11 2 B+-tree stored in a file: 1 5 2 10 1 5 2 10 1 2 3 B+-tree stored in a file: 1 2 3 6 0 9 11 2 13 6 1 5 10 11 3 9 13 13 6 9 3 1 11 2 Feb. 15, 2012 ACS-7102 Yangjun Chen

Find the names of employees who works on all the projects 3.(15) Given the relation schemas shown in Fig. 2, 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 ‘Applied Computer Science’. EMPLOYEE fname, minit, lname, ssn, bdate, address, sex, salary, superssn, dno DEPARTMENT Dname, dnumber, mgrssn, mgrstartdate Fig. 2 PROJECT WORKS_ON Pname, pnumber, plocation, dnum Essn pno, hours Feb. 15, 2012 ACS-7102 Yangjun Chen

: DN dnumber(Dname = ‘Applied Computer Science’(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) Feb. 15, 2012 ACS-7102 Yangjun Chen

4. (20) Construct an R-tree over a set of records for geographical objects with the following coordinates [(x1, y1), (x2, y2)]: [(0, 40), (60, 50)] ---- road1 [(40, 0), (60, 40)] ---- road2 [(15, 25), (35, 35)] ---- house1 [(70, 40), (80, 50)] ---- house2 [(70, 5), (80, 15)] ---- house3 [(35, 25), (80, 35)] ---- pipeline Assume that each leaf node can have at most 4 pointers and at least two pointers; and each internal node at most 2 pointers and at least 1 pointer. Please give the computation process. Feb. 15, 2012 ACS-7102 Yangjun Chen

((0, 40), (60, 50)) ((0, 0), (60, 50)) road1 road1 road2 [(15, 25), (35, 35)] ---- house1 [(70, 40), (80, 50)] ---- house2 ((0, 0), (60, 50)) ((0, 0), (80, 50)) Road1 road2 house1 Road1 road2 house1 house2 Feb. 15, 2012 ACS-7102 Yangjun Chen

square units to the region. [(70, 5), (80, 15)] ---- house3 ((0, 0), (60, 50)) ((70, 5), (80, 50)) road1 road2 house1 house2 house3 If we expand the first subregion in the internal node, then we add 1000 square units to the region. If we extend the other subregion in the internal, then we add 1575 square units. [(35, 25), (80, 35)] ---- pipeline ((0, 0), (80, 50)) ((70, 5), (80, 50)) road1 road2 house1 pi peline house2 house3 Feb. 15, 2012 ACS-7102 Yangjun Chen

[(0, 0), (60, 50)] [(70, 5), (80, 50)] [(35, 25), (80, 35)] ---- pipeline [(0, 0), (80, 50)] [(35, 5), (80, 50)] Feb. 15, 2012 ACS-7102 Yangjun Chen

5. (15) Please give the algorithm for transforming any XML document to a tree structure. Apply the algorithm to the following document and trace the computation process. <book> <title> “The Art of Programming” </title> <author> “D. Knuth” </author> <year> “1969” </year> </book> <book> <title> <author> <year> “The Art of Programming” “D. Knuth” “1969” Feb. 15, 2012 ACS-7102 Yangjun Chen

Transform an XML document to a tree Read a file into a character array A: < b o o k > < t i t l e > “ T h e A r t … node_value Point_to_node stack S: Feb. 15, 2012 ACS-7102 Yangjun Chen

Transform an XML document to a tree Algorithm: Scan array A; If A[i] is ‘<’ and A[i+1] is a character then { generate a node x for A[i..j], where A[j] is ‘>’ directly after A[i]; let y = S.top().pointer_to_node; make x be a child of y; S.push(A[i..j], x); If A[i] is ‘ ‘‘ ’, then { genearte a node x for A[i..j], where A[j] is ‘ ’’ ’ directly after A[i]; make x be a child of y; If A[i] is ‘<’ and A[i+1] is ‘/’, then S.pop(); Feb. 15, 2012 ACS-7102 Yangjun Chen

<book> <book> <title> <book> <title> “The Art of Programming” </title> <author> “D. Knuth” </author> <year> “1969” </year> </book> <book> <book> <title> <book> <title> The Art of Programming <book> The Art of Programming Feb. 15, 2012 ACS-7102 Yangjun Chen

<author> <book> <book> D. Knuth <year> <title> “The Art of Programming” </title> <author> “D. Knuth” </author> <year> “1969” </year> </book> <book> <author> The Art of Programming <book> The Art of Programming D. Knuth <book> <year> The Art of Programming D. Knuth Feb. 15, 2012 ACS-7102 Yangjun Chen

empty <year> <book> D. Knuth 1969 <book> D. Knuth <title> “The Art of Programming” </title> <author> “D. Knuth” </author> <year> “1969” </year> </book> <book> <year> The Art of Programming D. Knuth 1969 The Art of Programming D. Knuth 1969 <book> The Art of Programming D. Knuth 1969 empty Feb. 15, 2012 ACS-7102 Yangjun Chen

6. (10) Fig. 3 is a DTD for a set of XML documents on movie and stars. Please produce a FLWR expression to find all those stars, who live at 123 Maple St., Malibu. <!DOCTYPE Stars [ <!ELEMENT Stars (Star*)> <!ELEMENT Star (Name, Address+, Movies)> <!ELEMENT Name (#PCDATA)> <!ELEMENT Address (Street, City)> <!ELEMENT Street (#PCDATA)> <!ELEMENT City (#PCDATA)> <!ELEMENT Movies (Movie*)> <!ELEMENT Movie (Title, Year)> <!ELEMENT Title (#PCDATA)> <!ELEMENT Year (#PCDATA)> ]> Assume that all the documents are stored in a file “stars.xml”. Fig. 3 Feb. 15, 2012 ACS-7102 Yangjun Chen

let $stars := doc(“stars.xml”) for $s in $stars/Stars/Star, $s1 in $s/Address where $s1/Street = “123 Maple St.” and $s1//City = “Malibu” return $s/Name let $stars := doc(“stars.xml”) for $s in $stars/Stars/Star where $s/Address/Street = “123 Maple St.” and $s/Address/City = “Malibu” return $s/Name This is wrong! Feb. 15, 2012 ACS-7102 Yangjun Chen

7. (10) The following is an XML schema, please define a DTD which is equivalent to it. <? Xml version = “1.0” encoding = “utf-8” ?> <xs: schema xmlns: xs = “http://www.w3.org/2001/XMLSchema”> <xs: complexType name = “movieType”> <xs: attribute name = “title” type = “xs: string” use = “required” /> <xs: attribute name = “year” type = “xs: integer” use = “required” /> </xs: complexType> <xs: element name = “Movies”> <xs: complexTyp> <xs: sequence> <xs: element name = “Movie” type = “movieType” minOccurs = “0” maxOcurs = “unbouned” /> <xs: element name = “Star” type = “xs: string” </xs: sequence> </xs: complexTyp> </xs: element> </xs: schema> Feb. 15, 2012 ACS-7102 Yangjun Chen

The above schema (in XML schema) is equivalent to the following DTD. <!DOCTYPE Movies [ <!ELEMENT Movies (Movie*, Star*) > <!ELEMENT Movie EMPTY > <!ATTLIST Movie Title CDATA #REQUIRED Year CDATA #REQUIRED > <!ELEMENT Star (#PCDATA) > ]> Feb. 15, 2012 ACS-7102 Yangjun Chen