Presentation is loading. Please wait.

Presentation is loading. Please wait.

(a) A university is organized into faculties.

Similar presentations


Presentation on theme: "(a) A university is organized into faculties."— Presentation transcript:

1 (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. 27, 2017 ACS-7102 Yangjun Chen

2 ER-model: professor faculty course section student belong teach head
salary name ID addr. SIN belong N 1 professor NoProf F-Id sex F-name M startdate 1 teach section-IDs faculty head 1 L M 1 provide N 1 M course has section sectionId choose N couresId name N ID addr. SIN take M student N major mandatory-optional creditHours name sex birthdate Feb. 27, 2017 ACS-7102 Yangjun Chen

3 2.(15) 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 f a b c e f h Fig. 1 Feb. 27, 2017 ACS-7102 Yangjun Chen

4 remove h: f e a b c remove c: f e a c b Feb. 27, 2017
ACS-7102 Yangjun Chen ACS-7102 Yangjun Chen 4

5 remove e: c a e a b f remove f: a e a b f a b a Feb. 27, 2017
ACS-7102 Yangjun Chen

6 Find the names of employees who works on all the projects
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’. 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. 27, 2017 ACS-7102 Yangjun Chen

7 : 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. 27, 2017 ACS-7102 Yangjun Chen

8 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, 60)] ---- house2 [(70, 5), (90, 15)] ---- house3 [(80, 60), (100, 80)] ---- house4 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. 27, 2017 ACS-7102 Yangjun Chen

9 100 house4 house2 road1 house1 house3 road2 100 Feb. 27, 2017
100 Feb. 27, 2017 ACS-7102 Yangjun Chen

10 ((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, 60)) Road1 road2 house1 Road1 road2 house1 house2 Feb. 27, 2017 ACS-7102 Yangjun Chen

11 square units to the region.
[(70, 5), (80, 15)] ---- house3 ((0, 0), (60, 50)) ((70, 5), (90, 60)) road1 road2 house1 house2 house3 If we expand the first subregion in the internal node, then we add 4000 square units to the region. If we extend the other subregion in the internal, then we add 1200 square units. [(35, 25), (80, 35)] ---- pipeline ((0, 0), (80, 50)) ((70, 5), (100, 80)) road1 road2 house1 house2 house3 house4 Feb. 27, 2017 ACS-7102 Yangjun Chen

12 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. 27, 2017 ACS-7102 Yangjun Chen

13 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. 27, 2017 ACS-7102 Yangjun Chen

14 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. 27, 2017 ACS-7102 Yangjun Chen

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

16 <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. 27, 2017 ACS-7102 Yangjun Chen

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

18 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: Feb. 27, 2017 ACS-7102 Yangjun Chen

19 <? Xml version = “1.0” encoding = “utf-8” standalone = “yes” ?>
< md : StarMoviedata xmlns : md = > <Star starID = “cf” starredIn = “sw”> <Name>Carrie Fishes</Name> <Address> <Street>123 Maple St.</Street><City>Hollywood</City> </Address> <Street>5 Locust Ln.</Street><City>Malibu</City> </Star> <Star starID = “mh” starredIn = “sw”> <Name>Mark Hamill</Name><Street>456 Oak Rd.</Street> <City>Brentwood</City> <Movie movieID = “sw” starsOf = “cf mh”> <Title>Star Wars</title><Year>1977</Year> </Movie> </StarMovieData> 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 Feb. 27, 2017 ACS-7102 Yangjun Chen

20 DocRoot(docID, rootElmentID)
[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] DocRoot(docID, rootElmentID) [1, 1] ElementValue(elementID, value) Feb. 27, 2017 ACS-7102 Yangjun Chen

21 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”] 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] [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] Feb. 27, 2017 ACS-7102 Yangjun Chen

22 7. In Fig. 3, we show a network, in which each node stands for a
page and each arc for a link from a page to another. Please give the transition matrix for the network. (3) Also, explain why the solution to the equation: (7) A = MA can be used as the estimation of page importance, where A is a vector of n variables (with each representing a page) and M is an n  n transition matrix. Fig. 3 Feb. 27, 2017 ACS-7102 Yangjun Chen

23 7. (i) p1 p2 p3 ½ ½ ½ ½ 0 ½ M = 0 ½ 0 (ii) y ½ ½ ½ a ½ 0 ½ m = 0 ½ 0
½ ½ ½ ½ 0 ½ 0 ½ 0 M = (ii) ½ ½ ½ ½ 0 ½ 0 ½ 0 = y a m Feb. 27, 2017 ACS-7102 Yangjun Chen

24 7. (ii) y: event – navigation stays on Yahoo
y-y: event – go to Yahoo from Yahoo y-a: event – go to Yahoo from Amazon y-m: event – go to Yahoo from Microsoft a-y: event – go to Amazon from Yahoo a-a: event – go to Amazon from Amazon a-m: event – go to Amazon from Microsoft a: event – navigation stays on Amazon m-y: event – go to Microsoft from Yahoo m-a: event – go to Microsoft from Amazon m-m: event – go to Microsoft from Microsoft m: event – navigation stays on Microsoft P(y) = P(y-y|y) + P(y-a|a) + P(y-m|m) P(a) = P(a-y|y) + P(a-a|a) + P(a-m|a) P(m) = P(m-y|y) + P(m-a|a) + P(m-m|m) = P(y-y)P(y) + P(y-a)P(a) + P(y-m)P(m) = P(a-y)P(y) + P(a-a)P(a) + P(a-m)P(a) = P(m-y)P(y) + P(m-a)P(a) + P(m-m)P(m) Feb. 27, 2017 ACS-7102 Yangjun Chen


Download ppt "(a) A university is organized into faculties."

Similar presentations


Ads by Google