0% found this document useful (0 votes)
12 views

UNIT 2 QB

The document is a question bank for Database Management Systems, specifically focusing on Unit 2 topics such as primary keys, candidate keys, foreign keys, and entity-relationship models. It provides definitions, examples, and explanations of various database concepts, including entity sets, relationships, and constraints. Additionally, it discusses design issues in entity-relationship diagrams and the phases of the database life cycle.

Uploaded by

shivamsah141205
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

UNIT 2 QB

The document is a question bank for Database Management Systems, specifically focusing on Unit 2 topics such as primary keys, candidate keys, foreign keys, and entity-relationship models. It provides definitions, examples, and explanations of various database concepts, including entity sets, relationships, and constraints. Additionally, it discusses design issues in entity-relationship diagrams and the phases of the database life cycle.

Uploaded by

shivamsah141205
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

lOMoARcPSD|32135358

DBMS UNIT 2 Complete Question Bank With Answers

Database Management Systems (SRM Institute of Science and Technology)

Scan to open on Studocu

Studocu is not sponsored or endorsed by any college or university


Downloaded by Shivam Kumar Sah ([email protected])
lOMoARcPSD|32135358

SRM INSTITUTE OF SCIENCE AND TECHNOLOGY


CHENNAI
18CSC303J - DATABASE MANAGEMENT SYSTEMS
QUESTION BANK
UNIT – 2
4 MARKS
1.Define primary key with example.
• A primary key is a special relational database table column (or combination of columns) designated
to uniquely identify all table records.
• A primary key is one of the candidate keys chosen by the database designer to uniquely identify the
entity set.
• A primary key’s main features are:
o It must contain a unique value for each row of data.
o It cannot contain null values.
• A primary key is either an existing table column or a column that is specifically generated by the
database according to a defined sequence.
• For example, students are routinely assigned unique identification (ID) numbers, and all adults
receive government-assigned and uniquely-identifiable Social Security numbers.
CREATE TABLE supplier
(
s_id numeric(10),
s_name varchar(10),
CONSTRAINT supplier_pk PRIMARY KEY (supplier_id)
);

2.Define Candidate key with example.


• A minimal super key is called a candidate key. An entity set may have more than one candidate key.
• A candidate key is an attribute or set of an attribute which can uniquely identify a tuple.
• The remaining attributes except for primary key are considered as a candidate key. The candidate
keys are as strong as the primary key.
• For example: In the EMPLOYEE table, id is best suited for the primary key. Rest of the attributes
like SSN, Passport_Number, and License_Number, etc. are considered as a candidate key.

3.Define super key with example.


• A set of attributes (one or more) that collectively identifies an entity in an entity set.
• Super key is a set of an attribute which can uniquely identify a tuple.
• Super key is a superset of a candidate key.

Downloaded by Shivam Kumar Sah ([email protected])


lOMoARcPSD|32135358

• For example: In the above EMPLOYEE table, for(EMPLOEE_ID,


EMPLOYEE_NAME,PASSPORT_NUMBER,LICENSE_NUMBER) the name of two employees
can be the same, but their EMPLYEE_ID, PASSPORT NUMBER, LICENSE NUMBER can't be
the same. Hence, this combination can also be a key.
• The super key for employee table would be , (EMPLOYEE_ID, EMPLOYEE-NAME,
PASSPORT_NUMBER,LICENSE_NUMBER), etc.

4.Define foreign key with example.


• A foreign key is a field (or collection of fields) in one table that uniquely identifies a row of another
table. In simpler words, the foreign key is defined in a second table, but it refers to the primary key
in the first table.
• A foreign key is a column or group of columns in a relational database table that provides a link
between data in two tables. It acts as a cross-reference between tables because it references the
primary key of another table, thereby establishing a link between them.
• For example, a table called Employee has a primary key called employee_id. Another table called
Employee Details has a foreign key which references employee_id in order to uniquely identify the
relationship between both the tables.

CREATE TABLE supplier


( supplier_id numeric(10) not null,
supplier_name varchar2(50) not null,
contact_name varchar2(50),
CONSTRAINT supplier_pk PRIMARY KEY (supplier_id)
);

CREATE TABLE products


( product_id numeric(10) not null,
supplier_id numeric(10) not null,
CONSTRAINT fk_supplier
FOREIGN KEY (supplier_id)
REFERENCES supplier(supplier_id)
);

5.Define object, entity, attributes.


Object
An entity that contains both attributes and actions is its object. It is defined by its life span, name and object
identifier. Every object has two components: State and Behavior.
Example:
views, indices, sequences
Entity
An entity is a real-world thing which can be distinctly identified like a person, place or a concept. It is an
object which is distinguishable from others. If we cannot distinguish it from others then it is an object but
not an entity. An entity can be of two types:
Tangible Entity: Tangible Entities are those entities which exist in the real world
physically. Example: Person, car, etc.
Intangible Entity: Intangible Entities are those entities which exist only logically and have no physical
existence. Example: Bank Account, etc.
Attributes

Downloaded by Shivam Kumar Sah ([email protected])


lOMoARcPSD|32135358

Entities are represented by means of their properties, called attributes. All attributes have values. For
example, a student entity may have name, class, and age as attributes.

6.Define entity set and relationship set.


Entity Set
• Entity set is a collection or a group of ‘entities’ sharing exactly the ‘same set of attributes’.
• All entities can be distinctly identified in an entity set. This is because all the entities have a different
set of value for some set of attributes.
• Classify the entity set into two basic categories Strong and Weak entity set.
• Rectangles represent entity sets.

Relationship Set
• A set of relationships of similar type is called a relationship set.
• Like entities, a relationship too can have attributes. These attributes are called descriptive attributes.
• Diamonds represent relationship sets.

7.Define descriptive attributes .


A descriptive attribute or simply a descriptor, describes a non-unique characteristic of an entity instance.
A set of relationships of similar type is called a relationship set. Like entities, a relationship too can have
attributes. These attributes are called descriptive attributes.

Represent loans as relationships between customers and branches


Loan number and amount are descriptive attributes

8.Define composite attributes.


An attribute composed of many other attributes is called as composite attribute.
In ER diagram, composite attribute is represented by an oval comprising of ovals.
The attributes which can be divided into sub-parts are called composite attributes.
For example, Address attribute of student Entity type consists of Street, City, State, and Country.

9. Define the goals of ER diagram.


ER Diagram goals
• Helps you to define terms related to entity relationship modeling
• Provide a preview of how all your tables should connect, what fields are going to be on each table
• Helps to describe entities, attributes, relationships
• ER diagrams are translatable into relational tables which allows you to build databases quickly
• ER diagrams can be used by database designers as a blueprint for implementing data in specific
software applications

10.Define Entity Relationship model.


• An Entity–relationship model (ER model) describes the structure of a database with the help of a
diagram, which is known as Entity Relationship Diagram (ER Diagram).
• An ER model is a design or blueprint of a database that can later be implemented as a database.

Downloaded by Shivam Kumar Sah ([email protected])


lOMoARcPSD|32135358

• The main components of E-R model are: entity set and relationship set.
• It is a high-level data model. This model is used to define the data elements and relationship for a
specified system.
• It develops a conceptual design for the database. It also develops a very simple and easy to design
view of data.

11.What is called as mapping cardinality? List out its types.


It tells the number of entities to with another entity can be associated through a 'relationship set' . Mapping
cardinality uses binary relationship sets.
So a binary relationship set R between entity set A and B there will be one of this mapping cardinality.
Types of mapping cardinalities:
One-to-one
One entity from entity set A can be associated with at most one entity of entity set B and vice versa.

One-to-many
One entity from entity set A can be associated with more than one entities of entity set B however an entity
from entity set B, can be associated with at most one entity.

Many-to-one
More than one entities from entity set A can be associated with at most one entity of entity set B, however
an entity from entity set B can be associated with more than one entity from entity set A.

Many-to-many
One entity from A can be associated with more than one entity from B and vice versa.

• 12.Define one to one mapping along with example. (Refer answer number 11)

Downloaded by Shivam Kumar Sah ([email protected])


lOMoARcPSD|32135358

• 13.Define one to one mapping along with example (Refer answer number 11)
• 14.Define one to many mapping along with example (Refer answer number 11)
• 15.Define many to one mapping along with example (Refer answer number 11)
• 16.Define many to many mapping along with example. (Refer answer number 11)

17.Differentiate strong entity set and weak entity set along with example.
Strong Entity Set
• An entity set which have enough number of attributes to form primary key is called as strong entity
set.
• An entity set that has a primary key using which, entities in the table can be uniquely identified.
This kind of entity set is termed as a strong entity set. Strong entity set is also known as a regular
entity set.
• In an ER diagram, the strong entity set is represented by the single rectangle.

Weak Entity Sets


• An entity set which don’t have enough number of attributes to form primary key is called as weak
entity set.
• A weak entity set doesn’t have any primary key which can identify each entity in a set distinctly.
But, for discriminating the entities in a set, the weak entity set is dependent on a particular strong
entity set.
• A weak entity is represented by a double rectangle.
• The relation between one strong and one weak entity is represented by a double diamond.

ALTERNATE ANSWER

Example

Downloaded by Shivam Kumar Sah ([email protected])


lOMoARcPSD|32135358

18.Define generalization along with example.


Generalization –

• Generalization is the process of extracting common properties from a set of entities and create a
generalized entity from it.
• It is a bottom-up approach in which two or more entities can be generalized to a higher level entity if
they have some attributes in common.
• For Example, STUDENT and FACULTY can be generalized to a higher level entity called PERSON
as shown in Figure . In this case, common attributes like P_NAME, P_ADD become part of higher
entity (PERSON) and specialized attributes like S_FEE become part of specialized entity
(STUDENT).

19.Define specialization along with example.


Specialization –
• In specialization, an entity is divided into sub-entities based on their characteristics.
• It is a top-down approach where higher level entity is specialized into two or more lower level
entities.
• Top-down design process; we designate subgroupings within an entity set that are distinctive
from other entities in the set.
• These subgroupings become lower-level entity sets that have attributes or participate in
relationships that do not apply to the higher-level entity set.
• For Example, EMPLOYEE entity in an Employee management system can be specialized into
DEVELOPER, TESTER etc. as shown in Figure In this case, common attributes like E_NAME,
E_SAL etc. become part of higher entity (EMPLOYEE) and specialized attributes like
TES_TYPE become part of specialized entity (TESTER).

Downloaded by Shivam Kumar Sah ([email protected])


lOMoARcPSD|32135358

20.Define aggregation along with example.


Aggregation refers to the process by which entities are combined to form a single meaningful entity. The
specific entities are combined because they do not make sense on their own. To establish a single entity,
aggregation creates a relationship that combines these entities. The resulting entity makes sense because it
enables the system to function well.

Following operations can be used to perform DBMS aggregation:


Average(AVG), Sum, Count, Maximum(Max), Minimum(Min), Standard Deviation(std dev)

For example: Center entity offers the Course entity act as a single entity in the relationship which is in a
relationship with another entity visitor. In the real world, if a visitor visits a coaching center then he will
never enquiry about the Course only or just about the Center instead he will ask the enquiry about both.

21.Define relational model.


• The relational model for database management is an approach to logically represent and manage the
data stored in a database.
• In this model, the data is organized into a collection of two-dimensional inter-related tables, also
known as relations.
• Each relation is a collection of columns and rows, where the column represents the attributes of an
entity and the rows (or tuples) represents the records.
• The use of tables to store the data provided a straightforward, efficient, and flexible way to store and
access structured information. Because of this simplicity, this data model provides easy data sorting
and data access. Hence, it is used widely around the world for data storage and processing.

Downloaded by Shivam Kumar Sah ([email protected])


lOMoARcPSD|32135358

22.Define key constraints along with example.


Key Constraint (or) Entity Constraint
• There must be at least one set of attributes that can identify a tuple in a unique manner. This set is
known as a key.
• There must be at least one minimal subset of attributes in the relation, which can identify a tuple
uniquely. This minimal subset of attributes is called key for that relation. If there are more than
one such minimal subsets, these are called candidate keys.
• Key constraints force that −
• in a relation with a key attribute, no two tuples can have identical values for key attributes.
• A key attribute cannot have NULL values.
• Key constraints are also referred to as Entity Constraints.
• Example Primary key and Foreign Key.

23.Define domain constraints along with example.


Domain Constraints are user-defined columns that help the user to enter the value according to the data type.
And if it encounters a wrong input it gives the message to the user that the column is not fulfilled properly.
Or in other words, it is an attribute that specifies all the possible values that the attribute can hold like
integer, character, date, time, string, etc. It defines the domain or the set of values for an attribute and
ensures that the value taken by the attribute must be an atomic value(Can’t be divided) from its domain.
There are two types of constraints that come under domain constraint and they are:
1. Domain Constraints – Not Null
2. Domain Constraints – Check
Example:

Table: Domain:

24.Define referential integrity constraints along with example.


Referential integrity Constraints
• Referential integrity constraints work on the concept of Foreign Keys. A foreign key is a key
attribute of a relation that can be referred in other relation.
• Referential integrity constraint states that if a relation refers to a key attribute of a different or same
relation, then that key element must exist.

Downloaded by Shivam Kumar Sah ([email protected])


lOMoARcPSD|32135358

• These constraints are used to describe the behaviour of foreign keys. A foreign key is a key of a
relation that can be referred in another relation.
• Example

25.List out the phases defined in database life cycle.

12 MARKS
1.Explain the design issues in Entity relationship diagram along with example.
Ans.

ER Design Issues
1) Use of Entity Set vs Attributes
2) Use of Entity Set vs. Relationship Sets
3) Use of Binary vs n-ary Relationship Sets

Downloaded by Shivam Kumar Sah ([email protected])


lOMoARcPSD|32135358

4) Placing Relationship Attributes

Use of Entity Set vs Attributes

>The employee entity set with attribute employee-name.


>The telephone entity set with attributes telephone-number and location.
>The relationship set emp-telephone, which denotes the association between employees and the telephones.
>Such a conversion of attribute helps to give extra information about it when required

Use of Entity Set vs. Relationship Sets

>It is not always clear whether an object can be best expressed by an entity set or a relationship set.
>This approach is used to break such dilemma where a set of relationship is defined between entities with
designated action that has to occur between them.
>This approach can also be useful in deciding whether certain attributes may be more appropriately
expressed as relationships.

>Want to represent loans given to exactly one customer – Each loan is given at a particular bank branch

>Represent loans as relationships between customers and branches


>Loan number and amount are descriptive attributes

Use of Binary vs n-ary Relationship Sets

>In most cases the relationships in database system is binary which means it defines the relationship
between two entities.
>Sometimes a system may have non binary(more than 2) relations, under such design those non binary
relations are broken down to several binary relationships which in turn gives an easy and better
representation of the system.

Downloaded by Shivam Kumar Sah ([email protected])


lOMoARcPSD|32135358

Placing Relationship Attributes

The cardinality ratio in DBMS can help us determine in which scenarios we need to place relationship
attributes. It is recommended to represent the attributes of one to one or one to many relationship sets with
any participating entity sets rather than a relationship set.

For example, if an entity cannot be determined as a separate entity rather it is represented by the
combination of participating entity sets. In such case it is better to associate these entities to many-to-many
relationship sets.

2.Describe about the different types of keys along with example .

3.Explain how Entity Relationship diagram is converted into tabular representation of schema along with
example.

Conversion of ER diagrams to tables


Follow the steps given below for the conversion of the ER diagrams to tables in the database
management system (DBMS) −
Step 1 − Conversion of strong entities

• For each strong entity create a separate table with the same name.

• Includes all attributes, if there is any composite attribute divided into simple attributes and
has to be included.

• Ignore multivalued attributes at this stage.

• Select the p key for the table.


Step 2 − Conversion of weak entity

Downloaded by Shivam Kumar Sah ([email protected])


lOMoARcPSD|32135358

• For each weak entity create a separate table with the same name.

• Include all attributes.

• Include the P key of a strong entity as foreign key is the weak entity.

• Declare the combination of foreign key and decimator attribute as P key from the weak entity.
Step 3 − Conversion of one-to-one relationship

• For each one to one relation, say A and B modify either A side or B side to include the P key
of the other side as a foreign key.

• If A or B is having total participation, then that should be a modified table.

• If a relationship consists of attributes, include them also in the modified table.


Step 4 − Conversion of one-to-many relationship

• For each one to many relationships, modify the M side to include the P key of one side as a
foreign key.

• If relationships consist of attributes, include them as well.


Step 5 − Conversion of many-many relationship

• For each many-many relationship, create a separate table including the P key of M side and
N side as foreign keys in the new table.

• Declare the combination of foreign keys as P for the new table.

• If relationships consist of attributes, include them also in the new table.


Step 6 − Conversion of multivalued attributes

• For each multivalued attribute create a separate table and include the P key of the present
table as foreign key.

• Declare the combination of foreign key and multivalued attribute as P keys.


Step 7 − Conversion of n-ary relationship

• For each n-ary relationship create a separate table and include the P key of all entities as
foreign key.

• Declare the combination of foreign keys as P key.

Table
After successful conversion, the result will be as follows

4.Explain tabular representation of various ER schema along with example.

Entities and Simple Attributes

Downloaded by Shivam Kumar Sah ([email protected])


lOMoARcPSD|32135358

>Each attribute turns into a column (attribute) in the table.


Persons(Name, lastname, email, Phone)

Entity set with composite attributes


In a relational model don’t represent the composite attribute as it is, take only the composition.
The attributes of a relation includes the simple attribute of a an entity set.

= Person(id, name, firstname, lastname)

Entity set with Multi-Valued Attributes


A multi-valued attribute is usually represented with a double-line oval.

If you have a multi-valued attribute, take the attribute and turn it into a new entity.
Add the primary (id) column of the parent entity as a foreign key within the new table.

=
Employee(empid, name, address, dob, sal)
Degree(empid, degree1, degree2,degree3)
Employee - empid(primary key)
Degree - empid(foreign key)

Translating relationship set into tables

Employee(ssn, name, salary)

Downloaded by Shivam Kumar Sah ([email protected])


lOMoARcPSD|32135358

Works_in(ssn, did, since)


Department(did, dname, budget)

5.Explain the phases takes place in database lifecycle along with neat diagram.

Phase 1: Database Initial Study


Purposes
◦ Analyze company situation
◦ Operating environment
◦ Organizational structure
◦ Define problems and constraints
◦ Define objectives
◦ Define scope and boundaries
Phase 2: Database Design
Most Critical DBLC phase
Makes sure final product
meets requirements
Focus on data requirements
Subphases
◦ I. Create conceptual design
◦ II. DBMS software selection
◦ III. Create logical design
◦ IV. Create physical design
Phase 3: Implementation and Loading
Creation of special storage-related constructs
to house end-user tables
Data loaded into tables
Other issues
◦ Performance
◦ Security
◦ Backup and recovery
◦ Integrity
◦ Company standards
◦ Concurrency controls

Downloaded by Shivam Kumar Sah ([email protected])


lOMoARcPSD|32135358

Phase 4: Testing and Evaluation


Database is tested and fine-tuned for performance, integrity, concurrent access, and security
constraints
Done in parallel with application programming
Actions taken if tests fail
◦ Fine-tuning based on reference manuals
◦ Modification of physical design
◦ Modification of logical design
◦ Upgrade or change DBMS software or hardware
Phase 5: Operation
Database considered operational
Starts process of system evaluation
Unforeseen problems may surface
Demand for change is constant
Phase 6: Maintenance and Evaluation
Preventative maintenance
Corrective maintenance
Adaptive maintenance
Assignment of access permissions
Generation of database access statistics to
monitor performance
Periodic security audits based on
system-generated statistics
Periodic system usage-summaries

6.Explain in detail about the components of ER model along with neat diagram.

Entity Set is a collection or a group of ‘entities’ sharing exactly the ‘same set of attributes’.
• All entities can be distinctly identified in an entity set. This is because all the entities have a
different set of value for some set of attributes.
classify the entity set into two basic categories Strong and Weak entity set.

Strong Entity Set


An entity set which have enough number of attributes to form primary key is called as strong entity
set.

Downloaded by Shivam Kumar Sah ([email protected])


lOMoARcPSD|32135358

An entity set that has a primary key using which, entities in the table can be uniquely identified. This
kind of entity set is termed as a strong entity set. Strong entity set is also known as a regular entity
set.

In an ER diagram, the strong entity set is represented by the single rectangle.

Weak Entity Sets


An entity set which don’t have enough number of attributes to form primary key is called as weak
entity set.
A weak entity set doesn’t have any primary key which can identify each entity in a set distinctly.
But, for discriminating the entities in a set, the weak entity set is dependent on a particular strong
entity set.

A weak entity is represented by a double rectangle

Attributes
Simple Attribute

Simple attributes are atomic values, which cannot be divided further.

Attributes are the properties which define the entity type. For example, Roll_No, Name, DOB, Age,
Address, Mobile_No are the attributes which defines entity type Student. In ER diagram, attribute is
represented by an oval.

Key Attribute

The attribute which uniquely identifies each entity in the entity set is called key attribute. For
example, Roll_No will be unique for each student. In ER diagram, key attribute is represented by an
oval with underlying lines.

Composite Attribute

An attribute composed of many other attribute is called as composite attribute. For example, Address
attribute of student Entity type consists of Street, City, State, and Country. In ER diagram, composite
attribute is represented by an oval comprising of ovals.

Multivalued Attribute

An attribute consisting more than one value for a given entity. For example, Phone_No (can be more
than one for a given student). In ER diagram, multivalued attribute is represented by double oval

Derived Attribute
An attribute which can be derived from other attributes of the entity type is known as derived
attribute. e.g.; Age (can be derived from DOB). In ER diagram, derived attribute is represented by
dashed oval

Relationship

The association among entities is called a relationship.

For example, an employee works_at a department, a student enrolls in a course. Here, Works_at and
Enrolls are called relationships

Downloaded by Shivam Kumar Sah ([email protected])


lOMoARcPSD|32135358

Relationship Set
o A set of relationships of similar type is called a relationship set. Like entities, a relationship
too can have attributes. These attributes are called descriptive attributes.
Degree of Relationship
o The number of participating entities in a relationship defines the degree of the relationship.
▪ Binary = degree 2
▪ Ternary = degree 3
▪ n-ary = degree

7.Describe extended ER features in detail along with neat diagram.


8..Draw ER diagram for banking database and explain it .

Step 1) Entity Indentification


- Customer
- Account
- Loan
- Employee
- Branch

Downloaded by Shivam Kumar Sah ([email protected])


lOMoARcPSD|32135358

- Savings-Account
- Checking-Account
- Payment (Weak)
Step 2) Relationship Identification
- Customer can borrow a loan or deposit cash
- Deposited cash will be logged into a register and will be connected to an account
- Deposited cash goes into the Savings-Account
- Customer may himself be an employee at the bank and may get some extra benefits
- Loan can be given at different rates depending on the branch
Step 3) Cardinality Identification
- A customer can have many accounts
- A customer can have multiple loans
- Loan will be provided by exactly 1 branch
Step 4) Attributes Identification
- Account
- Savings-Account
- Interest Rate
- Checking-Account
- Overdraft Amount
- Customer
- ID, Name, Address, City
- Employee
- ID, Name, Hire-date, Contact, Manager_Name, Designation
- Branch
- ID, Name, City
- Loan
- ID, Amount, Interest, Branch
- Payment
- ID, Date, Amount

9.Draw ER diagram for hospital management systems and explain it .


Step 1: E-R Diagram

Downloaded by Shivam Kumar Sah ([email protected])


lOMoARcPSD|32135358

Step 2: Converting the E-R Diagram into Tables


b. Converting entity to table and attribute to columns
Hospital

Hosp-id Primary Key

HCity

HAddress

Hos-Name

Pat-id Foreign key references to Pat-id of Patient table

Doc-id Foreign key references to Doc-id of Doctor table

Patient

Pat-id Primary Key

PName

PAddress

PDiagnosis

Record-id Foreign key references to Record-id of Medical Record table

Downloaded by Shivam Kumar Sah ([email protected])


lOMoARcPSD|32135358

Pat-id Primary Key

Hosp-id Foreign key references to Hosp-id of Hospital table

Medical Record

Record-id Primary Key

Problem

Date_of_examination

Pat-id Foreign key references to Pat-id of Patient table

Doctor

Doc-id Primary Key

DName

Qualification

Salary

Hosp-id Foreign key references to Hosp-id of Hospital table

Step 3: Mapping of Attributes


• Simple Attributes
Simple Attributes which can not be divided into subparts.
Example: Salary of Doctor

Downloaded by Shivam Kumar Sah ([email protected])


lOMoARcPSD|32135358

• Composite Attributes
Composite Attributes which can be divided into subparts.
Example: Patient Name, Doctor Name

Step 4: Mapping of Relationships


b. Foreign Key approach
Hosp_patient

Pat-id Hospital table makes foreign key references to Pat-id of Patient table

Hosp-id Patient table makes foreign key references to Hosp-id of Hospital table

Hosp_Doctor

Hosp-id Doctor table makes foreign key references to Hosp-id of Hospital table

Doc-id Hospital table makes foreign key references to Doc-id of Doctor table

PatiPPatient_MedicalRecord

Pat-id Medical Record table makes foreign key references to Pat-id of Patient table

Record-id Patient table makes foreign key references to Record-id of Medical Record table

Step 5: Identifying the relationships


a. Hospital has a set of patients.

Downloaded by Shivam Kumar Sah ([email protected])


lOMoARcPSD|32135358

Therefore the relations is 1……..N.


b. Hospital has a set of doctors.
Therefore the relations is 1……..N.
c. Doctor are associated with each patient.
Therefore the relations is N……..1.
d. Each patient has record of various test and examination conducted.
Therefore the relations is 1……..N.

10.Explain relational model and constraints defined in relational model along with example.

Relational model.
• The relational model for database management is an approach to logically represent and manage the
data stored in a database.
• In this model, the data is organized into a collection of two-dimensional inter-related tables, also
known as relations.
• Each relation is a collection of columns and rows, where the column represents the attributes of an
entity and the rows (or tuples) represents the records.
• The use of tables to store the data provided a straightforward, efficient, and flexible way to store and
access structured information. Because of this simplicity, this data model provides easy data sorting
and data access. Hence, it is used widely around the world for data storage and processing.
Concepts: Tables, Tuple, Relational Instance, Relation Schema, Relation Key, Attribute Domain

Every relation has some conditions that must hold for it to be a valid relation. These conditions are called
Relational Integrity Constraints. There are three main integrity constraints –

Key Constraint (or) Entity Constraint


• There must be at least one set of attributes that can identify a tuple in a unique manner. This set is
known as a key.
• There must be at least one minimal subset of attributes in the relation, which can identify a tuple
uniquely. This minimal subset of attributes is called key for that relation. If there are more than
one such minimal subsets, these are called candidate keys.
• Key constraints force that −
• in a relation with a key attribute, no two tuples can have identical values for key attributes.

Downloaded by Shivam Kumar Sah ([email protected])


lOMoARcPSD|32135358

• A key attribute cannot have NULL values.


• Key constraints are also referred to as Entity Constraints.
• Example Primary key and Foreign Key.

Domain Constraints are user-defined columns that help the user to enter the value according to the data type.
And if it encounters a wrong input it gives the message to the user that the column is not fulfilled properly.
Or in other words, it is an attribute that specifies all the possible values that the attribute can hold like
integer, character, date, time, string, etc. It defines the domain or the set of values for an attribute and
ensures that the value taken by the attribute must be an atomic value(Can’t be divided) from its domain.
There are two types of constraints that come under domain constraint and they are:
3. Domain Constraints – Not Null
4. Domain Constraints – Check
Example:

Table: Domain:

Referential integrity Constraints


• Referential integrity constraints work on the concept of Foreign Keys. A foreign key is a key
attribute of a relation that can be referred in other relation.
• Referential integrity constraint states that if a relation refers to a key attribute of a different or same
relation, then that key element must exist.
• These constraints are used to describe the behaviour of foreign keys. A foreign key is a key of a
relation that can be referred in another relation.
• Example

Downloaded by Shivam Kumar Sah ([email protected])

You might also like