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.

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.
COMPANY schema EMPLOYEE
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
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.
Jan. 2013Dr. Yangjun Chen ACS Outline Signature Files - Signature for attribute values - Signature for records - Searching a signature file Signature.
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.
Assignment #2 Sept. 2014Yangjun Chen ACS (20) The following is a DTD for books. Please produce an XML document conforming to the DTD.
- relation schema, relations - database schema, database state
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.
ACS-4902 Ron McFadyen Chapter 15 Algorithms for Query Processing and Optimization See Sections 15.1, 2, 3, 7.
Semi-structured Data. Facts about the Web Growing fast Popular Semi-structured data –Data is presented for ‘human’-processing –Data is often ‘self-describing’
Jyh-haw Yeh Dept. of Computer Science Boise State University
B + -Trees and Trees for Multidimensional Data Jan. 2012Yangjun Chen ACS Database Index Techniques B + - tree kd – tree Quad - tree R – tree Bitmap.
Assignment #2 Sept. 2014Yangjun Chen ACS (20) The following is a DTD for books. Please produce an XML document conforming to the DTD.
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.
Logical DB Design 5. 1 CSE2132 Database Systems Week 5 Lecture Logical Database Design.
Review: Application of Database Systems
1 CS 430 Database Theory Winter 2005 Lecture 12: SQL DML - SELECT.
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.
Review Database Application Development Access Database Development Theory Practice.
603 Database Systems Senior Lecturer: Laurie Webster II, M.S.S.E.,M.S.E.E., M.S.BME, Ph.D., P.E. Lecture 9 A First Course in Database Systems.
1Fundamentals of Database Systems 기본키에 밑줄을 그은 COMPANY 관계 데이타베이스 스키마 FNAMEMINITLNAMESSNBDATEADDRESSSEXSALARYSUPERSSNDNO EMPLOYEE DNAMEDNUMBERMGRSSNMGRSTARTDATE.
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.
Assignment #1 due Wed. Feb. 15, (15)
Semistructured-Data Model
The SQL Database Grammar
Database Design The Relational Model Text Ch5
376a. Database Design Dept. of Computer Science Vassar College
Mapping ER Diagrams to Tables
Outline: Relational Data Model
Joining Tables ضم الجداول وإستخراج مناظر views منها الهدف : 1- استخراج المعلومات من جدولين أو اكثر بالإستفادة من الرابط بينهما وبإستخدام SQL 2- شروط قواعد.
Database Index Techniques
Company Requirements.
Outline: Database Basics
CS4222 Principles of Database System
Foreign key (FK) is defined as follows:
(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.
ISC321 Database Systems I Chapter 4: SQL: Data definition, Constraints, and Basic Queries and Updates Fall 2015 Dr. Abdullah Almutairi.
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.
(a) A university is organized into faculties.
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:

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 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.

Analysis of Midterm-Examination Oct. 22, 2014ACS-7102 Yangjun Chen2 faculty professor course student ER-model: belong head provide choose teach F-name F-Id NoProf birthdatenamesex major name couresId name IDaddr. startdate N N M N 1 M N take SIN sex salary section-IDs M N mandatory-optional ID SIN addr. creditHours

Analysis of Midterm-Examination Oct. 22, 2014ACS-7102 Yangjun Chen3 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)

Analysis of Midterm-Examination Oct. 22, 2014 ACS-7102 Yangjun Chen4 4 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 x 1, …, x k be the children of v; for (i = k to 1) {push(x i, ad, i)}; } dataaddress-of- parent position stack: S Store a B+-tree on hard disk

Analysis of Midterm-Examination Oct. 22, 2014ACS-7102 Yangjun Chen B+-tree stored in a file: dataadd.-of-pposition 5,

Analysis of Midterm-Examination Oct. 22, 2014ACS-7102 Yangjun Chen6 dataadd.-of-pposition 11, , 902 1, 301 dataadd.-of-pposition 11, ,

Analysis of Midterm-Examination Oct. 22, 2014ACS-7102 Yangjun Chen7 dataadd.-of-pposition 11, dataadd.-of-pposition

Analysis of Midterm-Examination Oct. 22, 2014ACS-7102 Yangjun Chen8 3.(10) 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’. fname, minit, lname, ssn, bdate, address, sex, salary, superssn, dno Dname, dnumber, mgrssn, mgrstartdate EMPLOYEE DEPARTMENT Pname, pnumber, plocation, dnum PROJECT Essn pno, hours WORKS_ON Fig. 2

Analysis of Midterm-Examination Oct. 22, 2014ACS-7102 Yangjun Chen9 DEPT_P   PNUMBER (DN DN.dnumber = PROJECT.dnumber (PROJECT)) EMP_PNOS   ESSN,PNO (WORK_ON) SSNS  EMP_PNOS : DEPT_P RESULT   FNAME, LNAME (SSNS * EMPLOYEE) DN   dnumber (  Dname = ‘Applied Computer Science’ (Department))

Analysis of Midterm-Examination Oct. 22, 2014ACS-7102 Yangjun Chen10 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.

Analysis of Midterm-Examination Oct. 22, 2014ACS-7102 Yangjun Chen11 ((0, 40), (60, 50)) road1 ((0, 0), (60, 50)) road1road2 ((0, 0), (60, 50)) Road1road2house1 ((0, 0), (80, 50)) Road1road2house1house2 [(0, 40), (60, 50)] ---- road1[(40, 0), (60, 40)] ---- road2 [(15, 25), (35, 35)] ---- house1 [(70, 40), (80, 50)] ---- house2

Analysis of Midterm-Examination Oct. 22, 2014ACS-7102 Yangjun Chen12 ((0, 0), (60, 50))((70, 5), (80, 50)) house2house3road1road2house1 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. ((0, 0), (80, 50))((70, 5), (80, 50)) house2house3road1road2house1pipeline [(70, 5), (80, 15)] ---- house3 [(35, 25), (80, 35)] ---- pipeline

Analysis of Midterm-Examination Oct. 22, 2014ACS-7102 Yangjun Chen13 [(0, 0), (60, 50)] [(70, 5), (80, 50)] [(0, 0), (80, 50)] [(35, 5), (80, 50)] [(35, 25), (80, 35)] ---- pipeline

Analysis of Midterm-Examination Oct. 22, 2014ACS-7102 Yangjun Chen14 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. “The Art of Programming” “D. Knuth” “1969” “The Art of Programming” “D. Knuth”“1969”

Analysis of Midterm-Examination Oct. 22, 2014ACS-7102 Yangjun Chen15 node_value Point_to_node stack S: Read a file into a character array A : “ T h e A r t … Transform an XML document to a tree

Analysis of Midterm-Examination Oct. 22, 2014ACS-7102 Yangjun Chen16 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]; let y = S.top().pointer_to_node; make x be a child of y; If A[i] is ‘<’ and A[i+1] is ‘/’, then S.pop(); Transform an XML document to a tree

Analysis of Midterm-Examination Oct. 22, 2014ACS-7102 Yangjun Chen17 “The Art of Programming” “D. Knuth” “1969” The Art of Programming The Art of Programming

Analysis of Midterm-Examination Oct. 22, 2014ACS-7102 Yangjun Chen18 “The Art of Programming” “D. Knuth” “1969” The Art of Programming The Art of Programming D. Knuth The Art of Programming D. Knuth

Analysis of Midterm-Examination Oct. 22, 2014ACS-7102 Yangjun Chen19 “The Art of Programming” “D. Knuth” “1969” The Art of Programming D. Knuth 1969 The Art of Programming D. Knuth 1969 The Art of Programming D. Knuth 1969 empty book year author title

Analysis of Midterm-Examination Oct. 22, 2014ACS-7102 Yangjun Chen20 6. (15) In order to represent XML documents as relations, we should give each document and each element of a document a unique ID. For each document, the ID could be its URL or path in a file system. A possible relational database schema: DocRoot(docID, rootElmentID) ElementValue(elementID, value) SubElement(parentID, childID, position) ElementAttribute(elementID, name, value) Please show the tables after we have put the following document into the tables :

Analysis of Midterm-Examination Carrie Fishes 123 Maple St. Hollywood 5 Locust Ln. Malibu Mark Hamill 456 Oak Rd. Brentwood Star Wars 1977 Oct. 22, 2014ACS-7102 Yangjun Chen

Analysis of Midterm-Examination Oct. 22, 2014ACS-7102 Yangjun Chen22 DocRoot(docID, rootElmentID) [1, 1] ElementValue(elementID, value) [1, md: StarMoviedata] [2, Star] [3, Name] [4, “Carrie Fishes”] [5, Address] [6, Street] [7, “123 Maple St.”] [8, City] [9, Hollywood] [10, address] [11, Street] [12, 5 Locus Ln.] [13, City] [14, Malibu] [15, Star] [16, name] [17, Mark Hamill] [18, Street] [19, 456 Oak Rd.] [20, City] [21, Brentwood] [22, Movie] [23, Title] [24, Star wars] [25, Year] [26, 1977]

Analysis of Midterm-Examination Oct. 22, 2014ACS-7102 Yangjun Chen23 SubElement(parentID, childID, position) [1, 2, 1] [1, 15, 2] [1, 22, 3] [2, 3, 1] [2, 5, 2] [2, 10, 3] [3, 4, 1] [5, 6, 1] [5, 8, 2] ElementAttribute(elementID, name, value) [1, xnmns: md, …] [2, starID, “cf”] [2, starredIn, “sw”] [15, starID, “mh”] [15, starredIn, “sw”] [22, movieID, “sw”] [22, starsOf, “cf mh”] [6, 7, 1] [8, 9, 1] [10, 11, 1] [10, 13, 2] [11, 12, 1] [13, 14, 1] [15, 16, 1] [15, 18, 2] [15, 20, 3] [16, 17, 1] [18, 19, 1] [20, 21, 1] [22, 23, 1] [22, 25, 2] [23, 24, 1] [25, 26, 1]

Analysis of Midterm-Examination Oct. 22, 2014ACS-7102 Yangjun Chen24 7. (5) Please give the compressed bit string of the following bit map: r’ = b 2 (i)b 1 (i). r 1 = b 11 = 7 = 111, b 12 = 110 r 2 = 0001 b 11 = 3 = 11, b 12 = 10 r 1 ’ = r 2 ’ = r 1 ’ r 2 ’ =

Analysis of Midterm-Examination Oct. 22, 2014ACS-7102 Yangjun Chen25 Carrie Fishes 123 Maple St. Hollywood 5 Locust Ln. Malibu Mark Hamill 456 Oak Rd. Brentwood Star Wars 1977