Download presentation
Presentation is loading. Please wait.
1
Foreign key (FK) is defined as follows:
1. What is a foreign key? What conditions must be satisfied for the values of a foreign key? Foreign key (FK) is defined as follows: i) Consider two relation schemas R1 and R2; ii) The attributes in FK in R1 have the same domain(s) as the primary key attributes PK in R2; the attributes FK are said to reference or refer to the relation R2; iii) A value of FK in a tuple t1 of the current state r(R1) either occurs as a value of PK for some tuple t2 in the current state r(R2) or is null. In the former case, we have t1[FK] = t2[PK], and we say that the tuple t1 references or refers to the tuple t2. May 2018 ACS-3902 Yangjun Chen
2
2. Specify the following concepts. Cardinality Constraints
Cardinality Constraints Participation constraints Weak entity Identifying relationship Cardinality is a constraint on a relationship specifying the number of entity instances that a specific entity may be related to via the relationship. Three kinds of cardinality constraints: 1:N, 1:1, M:N May 2018 ACS-3902 Yangjun Chen
3
The participation constraint specifies whether the existence of an
entity depends on its being related to another entity via the relationship type. Two kinds of participation relationships: total (mandatory) and partial (optional) A weak entity type is an entity type, for which the primary key cannot be recognized. That is, it exists in a relationship to some other entity type. An identifying relationship exists between a weak entity type and its owner. May 2018 ACS-3902 Yangjun Chen
4
Department: [DeptNo, Manager_fName, Manager_lName]
3. Consider the following ERD. Map the ERD to a relational database showing the relation(s) that will be created (show relation names, attributes, and primary keys). office DeptNo phone fName lName Department Manager Department: [DeptNo, Manager_fName, Manager_lName] Phone: [DeptNo, phone] Office: [DeptNo, office] May 2018 ACS-3902 Yangjun Chen
5
4. Consider the following ERD.
Person Fname Lname PerBirthDate PerNo Now, consider the recursive relationship “a person is the child of another person”. a) Modify the ERD to accommodate this relationship. b) Show the relations (show the relation name, attributes, and primary key) that exist when you map your ERD in part a) above to a relational database. . May 2018 ACS-3902 Yangjun Chen
6
Person: [PerNo, Lname, Fname, PerBirthDate] ChildOf: [child, parent]
ChildOf: [child, parent] May 2018 ACS-3902 Yangjun Chen
7
Person: 1 John … … 2 Jane 3 Sam 4 Silvia ChildOf: 3 1 2 4 May 2018
ACS-3902 Yangjun Chen
8
5. List all the different types of attributes. Atomic Attributes
Atomic Attributes Composite Attributes Single-valued Attributes Multi-valued Attributes Key Attributes Partial Keys Surrogate Key Non-key Attributes Derived Attributes May 2018 ACS-3902 Yangjun Chen
9
6. Given the query below, show the corresponding Query Design View.
Use an attached sheet for your answer. Assume that Dealer and Auto are two tables. Dealer has attributes: DealerId, and name; and Auto has attributes: AutoId, Make, Model, Year, Price, and Did, where Did is a foreign key referring to DealerId. For each dealer, find the number of the autos with price > 10000, sold by it. field AutoId Make Model Year Price Did table Auto sort show √ criteria >10,000 May 2018 ACS-3902 Yangjun Chen
10
7. Consider the following design.
Mid Name N wife 1 Marriage Person N husband 1 Pid MDate Map this ERD to a relational database (show relation names, attributes, and primary keys) Person: [Pid, Name] Marriage: [Mid, Mdate, husband, wife] May 2018 ACS-3902 Yangjun Chen
11
Mandatory: any entity instance take part in the relationship.
8. Explain the difference between two kinds of participation constraints: mandatory and optional. Mandatory: any entity instance take part in the relationship. Optional: some entity instance take part in the relationship, but some may not. May 2018 ACS-3902 Yangjun Chen
12
What is a data sheet view? What is a design view?
9. When you work with tables by ACCESS, you need to know the following things: What is a data sheet view? What is a design view? How to set the key for a table? How to establish a relationship between two tables? data sheet view: used to enter data design view: used to design a table structure How to set the key for a table: In the design view, click the corresponding field, and choose ‘primary key’ in the push down menu. How to establish a relationship between two tables: Database Tools Relationships show table, and drag one field in one table to another field in some other table. May 2018 ACS-3902 Yangjun Chen
13
4. 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. May 2018 ACS-3902 Yangjun Chen
14
ER-model: professor faculty sections course student belong teach head
salary name ID addr. SIN belong N 1 professor NoProf F-Id sex F-name M startdate 1 faculty head teach 1 N M 1 sections sectionId provide N M choose has 1 ID course N name addr. SIN N L take M couresId student major mandatory-optional creditHours name sex birthdate May 2018 ACS-3902 Yangjun Chen
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.