0% found this document useful (0 votes)
47 views17 pages

Learning Journal Unit # 1 Data Bases

Learning journal assignment unit # 1 Data bases.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views17 pages

Learning Journal Unit # 1 Data Bases

Learning journal assignment unit # 1 Data bases.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 17

Learning Journal Unit # 1

Subject: Databases - II

Instructor: Khushboo Sharma

Submitted By: Muhammad Abdul Rehman Khan

Date: 27-06-2025 (DD-MM-YYYY)


Questions:

1.
a) Design an entity-relationship data model using DIA software for a car-insurance company whose
customers own one or more cars each. There are zero to any number of accidents recorded for each
car.

(b) Provide an example of each of the following three concepts within your model:

 Primary key
 Composite attribute
 Multi-valued attribute

a) Using the concepts of relational databases, develop a set of tables with several entries in each
table from the model designed in question 1.(a).
b) Using these tables, provide an example of each of the following:

 A left join
 A right join
 A full outer-join

3.

(a) Give examples for each of the following four mapping cardinalities:

 one-to-one
 many-to-one
 one-to-many
 many-to-many

b) Explain why the cardinality is appropriate for the relationship in each example.

 one-to-one

 many-to-one

 one-to-many
 many-to-many

 many-to-many
Introduction:

In the field of database systems, creating well-structured and scalable data models is essential for
handling extensive data collections. This assignment involves using entity-relationship (E-R)
modeling and relational database principles to design a database for a car insurance company.
With the help of the DIA diagramming tool, we will build an E-R diagram that illustrates the
connections between customers, their cars, and any accidents linked to those vehicles. The aim is
to develop a logical and organized data structure that supports accurate data storage and enables
quick and reliable data access.

A solid database design is key to managing large amounts of information efficiently. Important
design concepts such as primary keys, multi-valued and composite attributes, relationship types,
and cardinality mappings are essential in building a dependable and effective database (Jukic et
al., 2017; Hoffer et al., 2018). This task highlights the practical use of these concepts in creating
a database that mirrors real-world relationships clearly and accurately (Elmasri & Navathe,
2017). The ultimate goal is to design a system that promotes proper data organization and
ensures fast and accurate retrieval of information.

1. (a) Design an entity-relationship data model using DIA software for a car-
insurance company whose customers own one or more cars each. There are zero
to any number of accidents recorded for each car.

Answer:

The entity-relationship (E-R) diagram should consist of the following:

Entities:

Customer: This entity represents individuals who are insured by the company. It contains the
following attributes:

 Customer ID (Primary Key)


 Name
 Address
 Phone Number
 Email

Car: Represents vehicles owned by the customers, containing:

 Car ID (Primary Key)


 Model
 Year
 License Plate
 Color (Composite Attribute: combines base colors)

Accident: Represents recorded accidents for each car:

 Accident ID (Primary Key)

 Date
 Description
 Damage Cost

Relationships:

 Owns: One-to-Many relationship between Customer and Car. One customer can own
multiple cars, but each car is owned by exactly one customer.

 Recorded in: One-to-Many relationship between Car and Accident. Each car may have
multiple accidents, but each accident is related to one car.

(b) Provide an example of each of the following three concepts within your model:

 Primary key:

The CustomerID in the Customer entity uniquely identifies each customer.

 Composite attribute:

The Color attribute in the Car entity can be considered a composite attribute, as it can consist of
multiple color components (e.g., primary and secondary colors).

 Multi-valued attribute:

The Phone Number attribute for the Customer entity could be a multi-valued attribute if a
customer has more than one contact number.

(c) Below is the E-R diagram with a DIA software representing the car-insurance company.
2. (a) Using the concepts of relational databases, develop a set of tables with several
entries in each table from the model designed in question 1(a)

Customer Details:

Customer_ID Name Address Mobile No. Email


1 Waqas Imran Architect 92301- [email protected]
Society, 3492073
Lahore
2 Abdullah PCSIR phase 92313- [email protected]
Khan 2, Lahore 8594124

Car Details:

(a) Design an entity-relationship


data model using DIA software
for a car-insurance company
whose customers own one or
more cars each. There are zero
to any number of accidents
recorded
for each car
(a) Design an entity-relationship
data model using DIA software
for a car-insurance company
whose customers own one or
more cars each. There are zero
to any number of accidents
recorded
for each car
(a) Design an entity-relationship
data model using DIA software
for a car-insurance company
whose customers own one or
more cars each. There are zero
to any number of accidents
recorded
for each car
(a) Design an entity-relationship
data model using DIA software
for a car-insurance company
whose customers own one or
more cars each. There are zero
to any number of accidents
recorded
for each car
(a) Design an entity-relationship
data model using DIA software
for a car-insurance company
whose customers own one or
more cars each. There are zero
to any number of accidents
recorded
for each car
(a) Design an entity-relationship
data model using DIA software
for a car-insurance company
whose customers own one or
more cars each. There are zero
to any number of accidents
recorded
for each car
(a) Design an entity-relationship
data model using DIA software
for a car-insurance company
whose customers own one or
more cars each. There are zero
to any number of accidents
recorded
for each car.
(a) Design an entity-relationship
data model using DIA software
for a car-insurance company
whose customers own one or
more cars each. There are zero
to any number of accidents
recorded
for each car.
(a) Design an entity-relationship
data model using DIA software
for a car-insurance company
whose customers own one or
more cars each. There are zero
to any number of accidents
recorded
for each car.
(a) Design an entity-relationship
data model using DIA software
for a car-insurance company
whose customers own one or
more cars each. There are zero
to any number of accidents
recorded
for each car.
(a) Design an entity-relationship
data model using DIA software
for a car-insurance company
whose customers own one or
more cars each. There are zero
to any number of accidents
recorded
for each car.
(a) Design an entity-relationship
data model using DIA software
for a car-insurance company
whose customers own one or
more cars each. There are zero
to any number of accidents
recorded
for each car.
(a) Design an entity-relationship
data model using DIA software
for a car-insurance company
whose customers own one or
more cars each. There are zero
to any number of accidents
recorded
for each car.
(a) Design an entity-relationship
data model using DIA software
for a car-insurance company
whose customers own one or
more cars each. There are zero
to any number of accidents
recorded
for each car.
Car_Id Model License Year Colour Customer_ID
Plate
8 TOYOTA LZ785 2022 Black 1
COROLLA
9 HONDA LEE5599 2023 White 2
CITY

Accident Details:

Accident_ID Date Description Loss Cost Car_Id


123 23-06-2023 Side door 25,000 8
damage
124 25-09-2024 Front part 45,000 9
damage

(b) Using these tables, provide an example of each of the following:

 Left join: This query returns all customers and any associated cars:

SQL code

SELECT Customer.Name, Car.Model

FROM Customer

LEFT JOIN Car ON Customer.CustomerID = Car.CustomerID;

 Right join:

This query returns all cars and any associated customers: SQL code

SELECT Customer.Name, Car.Model

FROM Customer RIGHT JOIN Car ON Customer.CustomerID = Car.CustomerID;

 Full outer join:

This query returns all customers and all cars, regardless of whether they are related:

SQL code

SELECT Customer.Name, Car.Model

FROM Customer
FULL OUTER JOIN Car ON Customer.CustomerID = Car.CustomerID;

Question:
For this assignment you will apply what you have learned in this unit about database systems and
answer the following questions.
Question:
For this assignment you will apply what you have learned in this unit about database systems and
answer the following questions.
Question:
For this assignment you will apply what you have learned in this unit about database systems and
answer the following questions.
3. (a) Give examples for each of the following four mapping cardinalities:

 One-to-one (Cardinality: 1:1): Example: Each customer has one insurance policy. One

customer maps to exactly one policy, and vice versa.

 Many-to-one (Cardinality: N:1):

Example: Each car model belongs to one car manufacturer. Many cars can share the same

manufacturer.

 One-to-many (Cardinality: 1): Example: A customer owns many cars. One customer maps to

multiple cars.

 Many-to-many (Cardinality: M): Example: Many cars can be involved in many accidents,

and many accidents can involve several cars. (b) Explanation of the cardinality in each example:

 One-to-one: A customer can only hold one policy, ensuring the uniqueness of the relationship.

 Many-to-one: Multiple cars can share the same manufacturer, but each car only belongs to one

manufacturer.
 One-to-many: One customer can own several cars, but each car is associated with a single

customer.

 Many-to-many: Accidents often involve multiple cars, and one car can be involved in several

accidents, so many-to-many mapping is necessary.

(b) Explanation of the cardinality in each example:

 One-to-one: A customer can only hold one policy, ensuring the uniqueness of the relationship.

 Many-to-one: Multiple cars can share the same manufacturer, but each car only belongs to one

manufacturer.

 One-to-many: One customer can own several cars, but each car is associated with a single

customer.

 Many-to-many: Accidents often involve multiple cars, and one car can be involved in several

accidents, so many-to-many mapping is necessary

Conclusion:

To conclude, this assignment focused on applying key concepts of database design to create an
entity-relationship model for a car insurance company. Using the DIA tool, we designed an E-R
diagram that clearly illustrates the links between customers, their vehicles, and related accident
records. Through the use of ideas such as primary keys, composite attributes, relationships, and
cardinality mapping, we developed a better understanding of how to organize and query
relational databases. This knowledge is important for managing data effectively while
maintaining its accuracy and reliability.
References:

Silberschatz, A., Korth, H. F., & Sudarshan, S. (2002). Database system concepts (4th ed.,

Vol. 1). McGraw-Hill.

You might also like