0% found this document useful (0 votes)
21 views6 pages

Dbms Assignment 2

The document outlines an ER model for a university system involving Students, Courses, and Faculty, detailing entities, relationships, and the importance of primary keys. It explains the three-level database architecture, emphasizing the impact of adding a new column on the conceptual level. Additionally, it discusses the advantages of a DBMS over a file system, common mistakes in converting ER diagrams to relational schemas, and key principles for redesigning a flawed database.

Uploaded by

manank.7409
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)
21 views6 pages

Dbms Assignment 2

The document outlines an ER model for a university system involving Students, Courses, and Faculty, detailing entities, relationships, and the importance of primary keys. It explains the three-level database architecture, emphasizing the impact of adding a new column on the conceptual level. Additionally, it discusses the advantages of a DBMS over a file system, common mistakes in converting ER diagrams to relational schemas, and key principles for redesigning a flawed database.

Uploaded by

manank.7409
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

1.

A university system has Students, Courses, and


Faculty. Students enroll in Courses and Faculty
teach Courses. Design an ER model with proper
representation using keys, cardinalities and
participation constraints. Why is selecting the
correct primary key important in real world
databases?

ER Model Design:

 Entities & Attributes:


o Student: <u>Student_ID</u> (PK), Name,
Email.
o Course: <u>Course_ID</u> (PK), Title,
Credits.
o Faculty: <u>Faculty_ID</u> (PK), Name,
Department.
 Relationships & Cardinality:
o Enrolls_In (Student <-> Course): Many-to-
Many (M:N). A student can take multiple
courses, and a course can have multiple
students.
o Teaches (Faculty <-> Course): One-to-Many
(1:N). One faculty member can teach multiple
courses, but each course is taught by only one
faculty member.
 Participation Constraints:
o Total Participation for Course in the "Teaches"
relationship (Every course must have an
assigned faculty).
o Partial Participation for Faculty (A faculty
member might be on research leave and not
teaching).

Importance of Primary Keys (PK):


In real-world databases, the PK is the "anchor" of data
integrity.

 Entity Integrity: It ensures no two rows are


identical, preventing data corruption.
 Indexing & Performance: Databases use PKs to
create indexes. Without a proper numeric PK, search
queries across millions of records would be
unacceptably slow.
 Relationship Stability: Using a stable PK (like an
ID) instead of a volatile one (like a Phone Number)
prevents "orphaned records" when user data
changes.
2. Explain the three-level database architecture
with a diagram and example. If we add a new
column to a table, which level of architecture is
affected and why?

The Three-Level Architecture (ANSI-SPARC) separates the


user's view from the physical storage.

1. External Level (View Level): The highest level;


describes how individual users see the data (e.g., a
student viewing only their transcript).
2. Conceptual Level (Logical Level): Describes what
data is stored and the relationships between them
(e.g., the entire table schema for Students and
Grades).
3. Internal Level (Physical Level): The lowest level;
describes how data is actually stored on the hard
drive (e.g., using B-trees or hashing).

Example: In a banking system, a Customer sees their


balance (External), the DBA manages the table structures
(Conceptual), and the server stores the bits and bytes on
a disk (Internal).

Impact of adding a new column:

Adding a column affects the Conceptual Level. Because


of Logical Data Independence, the External Level (user
views) remains unaffected. Users don't need to change
how they interact with their specific views just because
the underlying table structure grew.
3. A company maintains employee data in multiple
Excel files across departments, leading to
redundancy and inconsistency. Explain why a
DBMS is preferred over a file system in such a
scenario.

A DBMS is superior for the following reasons:

 Reduced Redundancy: Unlike Excel files where


"Employee A" might exist in five different files, a
DBMS stores data in one place, saving storage and
effort.
 Data Consistency: If an employee changes their
name, it is updated once in the DBMS. In a file
system, you might update the HR file but forget the
Payroll file, leading to conflicting data.
 Concurrent Access: Multiple departments can read
and write to the database simultaneously without
"File is locked for editing" errors.
 Data Integrity: You can set rules (e.g., "Age must
be $> 18$") that the system enforces automatically.
 Security: DBMS allows granular permissions (e.g.,
Payroll can see salaries, but Marketing cannot),
which is difficult to manage with shared Excel files.
4. Using the ER Diagram you designed in question
1, convert it into relational tables showing Primary
Keys and Foreign Keys. What common mistakes
occur while converting an ER diagram into
relational schema, especially in M:N and higher-
degree relationships?

Relational Schema:

1. Student (<u>Student_ID</u>, Name, Email)


2. Faculty (<u>Faculty_ID</u>, Name, Dept)
3. Course (<u>Course_ID</u>, Title, Credits,
Faculty_ID) — Faculty_ID is a Foreign Key (FK).
4. Enrollment (<u>Student_ID</u>,
<u>Course_ID</u>) — A Junction Table where both
columns act as a Composite PK and individual FKs.

Common Mistakes:

 Missing Junction Tables: Attempting to force M:N


relationships into a single table by using comma-
separated values, which violates First Normal Form
(1NF).
 Redundant Foreign Keys: In 1:N relationships,
placing the FK on the "One" side instead of the
"Many" side.
 Ignoring Participation: Failing to mark FKs as NOT
NULL when the ER diagram specifies Total
Participation.
5. A company designed a database without proper
ER modelling. Later, they faced redundancy,
difficulty in adding new features, and frequent
schema changes. Identify two major conceptual
design flaws that might have caused these issues.
If you were asked in an interview to redesign this
database, what key principles would you apply and
why?

Two Major Design Flaws:

1. Lack of Normalization: Storing repetitive data (like


Department Address) in every Employee record
instead of a separate Department table. This causes
Update Anomalies.
2. Weak Entity Identification: Using "Names" or
"Descriptions" as keys instead of unique surrogate
IDs, leading to broken relationships when
descriptions are edited.

Redesign Principles:

 Requirement Gathering: Clearly define the


"Business Rules" before touching the schema.
 Normalization (to 3NF): To ensure each piece of
data is stored in exactly one place.
 Standardized Naming Conventions: To make the
schema intuitive for future developers.
 Enforcement of Constraints: Use Primary Keys,
Foreign Keys, and Unique constraints to automate
data validation at the database level.

Common questions

Powered by AI

The three-level database architecture, according to the ANSI-SPARC model, comprises the External, Conceptual, and Internal levels. Adding a new column affects the Conceptual Level, which defines the logical structure of the database . Thanks to logical data independence, the External Level remains unaffected, meaning user views do not change despite alterations in the underlying schema, ensuring stability in how users interact with the database .

A DBMS is preferred over a traditional file system for several reasons. It reduces redundancy by storing data in a single location, ensuring data consistency when updates occur. It allows for concurrent access, enabling multiple departments to interact with the data simultaneously without conflicts. A DBMS also enforces data integrity through rules and constraints, enhancing security with specific permissions that are difficult to manage with shared file systems .

Conceptual design flaws causing redundancy include lack of normalization, where repetitive data is stored instead of being separated into different tables, leading to update anomalies. Additionally, using weak keys like names instead of unique IDs results in broken relationships when data is altered. A redesign should focus on requirement gathering to define business rules, employ normalization (to at least 3NF) to ensure each data piece is stored exactly once, apply standardized naming conventions for clarity, and enforce constraints with primary and foreign keys to automate data validation .

Enforcing database normalization up to the Third Normal Form (3NF) offers several benefits, such as reducing duplication by ensuring each piece of data is stored only once, which minimizes anomalies during update operations. Normalization also facilitates future schema changes and provides clarity, making it easier to understand and extend the database structure without extensive rework . By organizing data logically, normalization reduces redundancy and dependencies, leading to efficient storage and retrieval .

Common mistakes in converting an ER diagram to a relational schema for M:N relationships include the omission of junction tables, which leads to violations of the First Normal Form by using comma-separated values. Additionally, placing foreign keys on the wrong side, such as on the "One" side in 1:N relationships instead of the "Many" side, and ignoring participation constraints by failing to mark foreign keys as NOT NULL where total participation is specified, are frequent errors .

Improper entity relationship modeling, such as failure to establish clear business rules or adequately define relationships and keys, can lead to frequent schema changes. Inadequate modeling might overlook necessary relationships, resulting in additional modifications later to support new features. It also may lead to a lack of flexibility, where adding features requires intrusive changes across multiple tables or relationships, increasing the risk of data integrity issues. Proper modeling sets a robust foundation, minimizing the need for repeated alterations and supporting scalable database growth .

The primary components of an ER model for a university system include entities such as Student, Course, and Faculty, each with their primary keys: Student_ID, Course_ID, and Faculty_ID, respectively . Selecting the correct primary key is crucial as it ensures entity integrity, preventing duplicate rows. It also enhances indexing and performance, since primary keys create efficient indexes, speeding up query responses. Additionally, using stable, non-volatile primary keys (like numeric IDs) prevents orphaned records when data changes occur .

Cardinality constraints determine how entities relate to each other, such as one-to-many or many-to-many, and influence how foreign keys and junction tables are set up in a relational schema. Participation constraints specify whether entities are required to participate in a relationship (total) or not (partial). For example, a total participation constraint for courses in the "Teaches" relationship requires marking related foreign keys as NOT NULL, ensuring that every course must have an assigned faculty, which impacts the table design and integrity constraints .

Logical data independence allows the conceptual schema to evolve without affecting existing user views at the external level. This means that changes such as adding new columns or altering relationships can be made without disrupting how users access data, maintaining the system's stability and flexibility . These benefits enhance the database's adaptability to changing requirements without necessitating costly and time-consuming adjustments to how end-users interact with databases .

Maintaining data integrity using shared Excel files across departments poses challenges such as data redundancy, as the same data may exist in multiple files, leading to inconsistencies when updates don't propagate across all files. There's also the potential for concurrent access issues, resulting in data conflicts like "File is locked for editing" errors. Additionally, Excel lacks robust capability for maintaining complex relationships and enforcing constraints automatically, increasing the risk of inconsistent and inaccurate data .

You might also like