Presentation is loading. Please wait.

Presentation is loading. Please wait.

1. Explain the following concepts of the ER data model:

Similar presentations


Presentation on theme: "1. Explain the following concepts of the ER data model:"— Presentation transcript:

1 1. Explain the following concepts of the ER data model:
Entity type and Entity type classification. Attribute and attribute classification. Constraint and constraint classification. Entity type: the structure description of some kind of entities. Entity type classification: strong entities and weak entities. Attribute: a property of some kind of entities with the same structure. Attribute type classification: simple attribute, multi-valued attribute, composite attribute, complex attribute, derived attribute, and stored attribute. Sept. 2004 Yangjun Chen

2 Constraint: constraints on relationships between or among
entity types. Constraint classification: cardinality constraints: 1:1, 1:M, N:M. Participation constraints: total constraint partial constraint Sept. 2004 Yangjun Chen

3 2. Draw an ER-diagram to describe the following real world problem.
At a university, instructors offer courses during particular semesters. Each instructor can teach some courses. Some courses are taught during a specific semester and some instructors teach during a specific semester. Each instructor has a name and a number. Each course has a name and a number. Each semester can be identified by the year and the season (spring, summer, fall and winter) when the semester is held. Sept. 2004 Yangjun Chen

4 Taught_During M Iname year N N M Offers Instructor Semester M P M
season Can_Teach Offered_During N Course N Cnumber Sept. 2004 Yangjun Chen

5 - 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: 3, 2, 4, 1, 8, 14, 5, 10, 7, 24, 17, 13, 15. Sept. 2004 Yangjun Chen

6 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): 4 8 1 2 14 3 n=0 before the split (n is the point to the bucket to be split.) 8 1 2 14 3 4 n=1 after the split load factor: 6/10=0.6 no split Sept. 2004 Yangjun Chen

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

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

9 8 1 2 14 3 4 5 0 1 2 3 4 5 10 n=2 load factor: 8/12=0.66 no split
overflow 10 n=2 load factor: 8/12=0.66 no split Sept. 2004 Yangjun Chen

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

11 8 1 2 10 3 7 4 5 14 n=3 load factor: 9/14=0.642 no split. 8 1 2 10 3 7
insert(24) 8 1 2 10 3 7 4 5 14 Sept. 2004 Yangjun Chen

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

13 The second phase – phase1 n = 0; using h1 = Key mod 2M to insert and
8 24 1 2 10 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 2 10 3 4 5 14 7 Sept. 2004 Yangjun Chen

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

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

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

17 Here, we assume that each internal node can contain at most two
4. Given the following B+-tree, trace the deletion sequence: 8, 3, 5, 6. 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. 3 2 5 1 2 3 5 6 8 Sept. 2004 Yangjun Chen

18 6 5 1 2 3 6 5 1 3 2 Sept. 2004 Yangjun Chen

19 3 1 5 1 2 6 1 5 1 2 6 1 2 1 Sept. 2004 Yangjun Chen

20 fname, minit, lname, ssn, bdate, address, sex, salary, superssn, dno
5. 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 work on all the projects controlled by a department that controls a project ’Web-DB’ and some other projects. Each project is controlled by one department. But each department can control more than one projects. 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 Yangjun Chen

21 : DN Dnum(Pname = ‘Web-DB’(PROJECT))
DEPT_P PNUMBER(DNDN.Dnum = PROJECT.Dnum(PROJECT)) EMP_PNOS  ESSN,PNO(WORK_ON) SSNS EMP_PNOS : DEPT_P RESULT  FNAME, LNAME(SSNS * EMPLOYEE) Sept. 2004 Yangjun Chen

22 6. Given the relation schemas as shown in Fig. 2, construct a SQL
clause to evaluate the following query: Find department names, and the number of employees in each department, who take part in at least one project. SELECT Dname, count(distinct SSN) FROM DEPARTMENT, EMPLOYEE, WORKS_ON WHERE DNUMBER = DNO AND SSN = ESSN Group By Dname Sept. 2004 Yangjun Chen


Download ppt "1. Explain the following concepts of the ER data model:"

Similar presentations


Ads by Google