What are the types of database relationships and what are they? How to create a relational database? What is Mapping Constraint in entity Relationship? Describe the different types of entity sets.
Three types of relationships can be established in a database file, namely—
ii) One to One relation
ii) One to Many relation
(ii) Many to Many relation.
These are discussed below--
(i) One to One Relationship: When relationship is established between two database files and one record in one database will have only one record in the other database. That is, if a record in the STAR database is related to only one record in the PRO database, then it is called a One to One relationship.
(ii) One to Many relation: This is a widely used relation. In this method, a record in a database is related to multiple records in another database. That is, there may be multiple matches in the PRO database for a record in the STAR database. Think, different suppliers provide different products in an office. In this case there is a database for Supplier and another database is created for Product. Unlike one Supplier item number in the Supplier database, the Product database can have multiple items. In this case the report can be created by establishing One to Many relationship.
(iii) Many to Many Relationship: When two databases have multiple matching records on both sides, it is called Many to Many relationship. In this case there may be multiple matches in the PRO database against any record in the STAR database. Again a record in the PRO database may have multiple matching records in the STAR database.
Creating a relational database file with two database files
To create a relationship between two databases, follow the steps below:
Let's say, a relationship will be created with the Students table and the Course table of the database called College. Then Course ID is the primary key in the Course table. A relation should be created with CourselD in the Students table with this field. because,
Relationships have to be established based on common fields. Unlike one CourselD in the Course table, the Students table can have multiple Course IDs. So in this case the relation will be One To Many.
(i) Create a database file called College and open its database window and select the Table tab.
(ii) Click on Relationship... from the Tools menu to get the Show Table dialog box. The database tables will be displayed in the dialog box.
(iii) Select two tables and click Add button to display them in the Relationships window.
(iv) The mouse pointer should be flagged from the Course ID of the Student table to the CourselD of the Course table and released. A Relationship dialog box will appear.
(v) Clicking the Create button from here will create the relation between the two tables indicated by a line as follows. This is how a one to many relationship is created.
Mapping Constraint On Entity Relationship:
Mapping constraints are mapping cardinalities used to describe relationship sets. There are three types of relationships for this--
(0) One to One
(i) One to Many
(iii) Many to Many.
Strong & Weak Entity Set
Strong Entity Set:
An entity set that contains a primary key is called a strong entity set. I think, Employee is a strong entity set, whose entity set, whose attributes are Employee Name, Position, Salary.
Weak Entity Set:
An entity set that does not have a primary key is called a weak entity set, a lower to 1, a lower to 2 a lower to 3........ a lower to n attributes associated with A is a weak entity set and B is a strong entity set, on which A depends. Suppose, the primary key of B is composed of attributes b lower to one, b lower to two, b lower to three, ........ b lower to n.
Difference Between Strong and Weak Entities:
Strong Entity Set---
(i) Entities that have primary keys in the set are called strong entities.(ii) Employee is a strong entity set, whose attributes are Employee Name, | Position, Salary.
weak entity set--
(i) An entity set that does not have a primary key is called a weak entity set.(ii) a lower to 1 , a lower to 2, a lower to 3............a lower to n Attribute A is a Weak entity set.
Comments
Post a Comment