In: Computer Science
Introduction to Database SHort answer question
-1)Can intersection data be placed in the entity box of one of the two entities in the many-to-many binary relationship? If yes, describe which one. If not, where can you put it? Explain.
-2)What is the difference between a record type and an occurrence of that record? Explain and give example(s).
-3)Name at least 4 entities, some sample attributes for each entity, and the primary key field for each entity, in a university environment .
4)How foreign key is used to set-up one-to-many relationships in relational databases? Explain and give example (example from the lecture is ok).
5) How to implement Many-to-Many relationship in a relational Database? Explain and give example (example from the lecture is ok)
6)Describe referential integrity problem in general. In the specific case of deleting a record in a table on the “one side” of a one-to-many relationship, how would referential integrity occur?
Solution:
1.Ans:
No, intersection data cannot be placed in the entity box of the two entities in many-to-many binary relationship because interection data means a new attribute which is commonly present in the either of the entities which can be either by association or combination and intersecting data cannot be attributed to both the entities that has the common occurences.
2.Ans:
A record type is a data type of the record and occurence of the record is the instance of the record.
CREATE TYPE student_det IS OBJECT ( STU_NO NUMBER, STU_NAME VARCHAR2(150), PHONE NUMBER );
The record student_det is created.
3.Ans:
Student, Program, Branch and University
Attributes are
Student - ID, Name, Address
Program - Prog_ID, Prog_Name, Duration
Branch - Branch_ID, Branch_Name, Address
University - Name, Address, Contact
4.Ans:
Foreign Key is an attribute or a group of attributes that act as a link between two tables in a database. That is why it is used to set one to many relationships in relational database.
Example:
Consider the above example the student enrolled in a course.
Student has studentId which is the primary key which is unique for every student.
Student takes a course. Each course has courseId which is a primary key in Course.
Student should have courseId to know which course he has been joined.
In this way foreign key can be used to set up one to many relationships between relational tables.