Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
13 views

Database Management System

Uploaded by

ladesos482
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

Database Management System

Uploaded by

ladesos482
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

1. What is database management system?

Explain DBMS component module with neat


diagram

Database Management System (DBMS):

A DBMS is a software system that enables users to define, create, maintain, and control
access to the database. It serves as an interface between the database and its end-users or
application programs, ensuring that data is consistently organized and remains easily
accessible.

DBMS Component Modules

The diagram illustrates the major components of a DBMS and their interactions. Here’s a
breakdown of each component and its role:

1. DDL Compiler:
- Function: Processes schema definitions specified in the Data Definition Language (DDL)
and stores the descriptions (metadata) in the DBMS catalog.

2. System Catalog/Data Dictionary:


- Function: Stores metadata about the structure of the database, such as schema
definitions and statistics.

3. Interactive Query Interface:


- Function: Allows casual users and those with occasional information needs to interact
with the database.

4. Query Compiler:
- Function: Validates the correctness of the query syntax and names of files/data elements,
compiling them into an internal form.

5. Query Optimizer:
- Function: Optimizes the query by rearranging and reordering operations, eliminating
redundancies, and using the best algorithms and indexes. It generates executable code for
the query and makes calls to the runtime processor.

6. Precompiler:
- Function: Extracts DML commands from application programs and sends them to the
DML compiler.

7. DML Compiler:
- Function: Compiles DML commands into object code for database access.

8. Host Language Compiler:


- Function: Compiles the rest of the application program code, excluding DML commands.

9. Canned Transactions:
- Function: Predefined transactions created by linking the compiled object codes of DML
commands and the rest of the application program. They include executable code with
runtime parameters.

10. Runtime Database Processor:


- Function: Executes privileged commands, executable query plans, and canned
transactions. Manages buffer memory and works with the stored data manager for data
transfer.

11. Stored Data Manager:


- Function: Handles low-level input/output operations between disk and main memory
using basic operating system services.

12. Concurrency Control/Backup and Recovery Subsystems:


- Function: Manage transaction processing to ensure data consistency and provide
mechanisms for backup and recovery in case of failures.

13. Application Programs:


- Function: Developed by application programmers to interact with the database using
predefined commands and queries.

2. What is database? Explain 3 Schema architecture of DBMS

Database is a collection of related data

Three Schema Architecture: The goal of the three-schema architecture is to separate user
applications from the physical database, providing a clear abstraction at different levels. This
helps in managing the complexity and enhances data independence. Schemas in this
architecture are defined at three levels:
- Internal Level

- Describes the physical storage structure of the database.

- Uses a physical data model.

- Details data storage and access paths.

- Conceptual Level

- Describes the structure of the whole database for a community of users.

- Hides physical storage details.

- Focuses on entities, data types, relationships, user operations, and constraints.

- Uses a representational data model for implementation.

- External (View) Level

- Includes multiple external schemas or user views.

- Each external schema describes the part of the database of interest to a specific user group.

- Hides the rest of the database from that user group.

- Typically implemented using a representational data model based on an external schema design.

3. What is referential integrity? Explain importance of referential integrity with example.

Referential Integrity is a property of a relational database that ensures that relationships


between tables remain consistent. Specifically, it means that a foreign key in one table must
always refer to a valid primary key in another table.
Importance of Referential Integrity:

1. Prevents Orphan Records:


- Ensures that a record referencing another record cannot exist if the referenced record
does not exist.
- Example: If a table of Orders references a table of Customers, each order must reference
an existing customer. If a customer is deleted, all their orders must also be deleted or
reassigned, ensuring no order exists without a valid customer.

2. Maintains Consistency:
- Helps maintain the accuracy and consistency of data within the database.
- Example: In a table of Enrollments that references a table of Students, an enrollment
should not exist if the student does not exist. This prevents inconsistencies like having an
enrollment for a non-existent student.

3. Ensures Data Integrity:


- Ensures that relationships between tables are meaningful and that data is logically
related.
- Example: In a database for a library system, a Loans table may reference a Books table.
Referential integrity ensures that each loan references an existing book, preventing the
scenario where a loan refers to a book that has been removed from the database.

Example:

Consider two tables: `Employees` and `Departments`.

- `Employees` table:
- `EmployeeID` (Primary Key)
- `Name`
- `DepartmentID` (Foreign Key)

- `Departments` table:
- `DepartmentID` (Primary Key)
- `DepartmentName`

Scenario:

1. Adding Records:
- When adding a new employee, the `DepartmentID` in the `Employees` table must match
an existing `DepartmentID` in the `Departments` table.
- This ensures that the new employee is assigned to a valid department.

2. Deleting Records:
- If a department is deleted from the `Departments` table, all employees in that
department must be reassigned or deleted.
- This prevents the scenario where employees reference a non-existent department.

3. Updating Records:
- If the `DepartmentID` of a department changes, all related `DepartmentID` fields in the
`Employees` table must be updated to reflect this change.
- This maintains the consistency of the relationship between employees and departments.

By enforcing referential integrity, the database ensures that the relationships between
tables are valid and that data remains accurate and meaningful.

4. Explain different users of DBMS users with example.


Database Users
Users may be divided into Those who actually use and control the database content, and
those who design, develop and maintain database applications called Those who design and
develop the DBMS software and related tools, and the computer systems operators called
Actors on the Scene

- Database Administrators (DBAs):


- Chief administrators managing the database system.
- Responsible for authorizing user access, monitoring database use, acquiring upgrades, and
addressing security and performance issues.
- In larger setups, may have support staff.

- Database Designers:
- Identify data to be stored and organize it effectively.
- Interact with different user groups to understand their requirements.
- Develop database views that cater to the needs of various user groups.

- End Users:
- Casual End Users:
- Occasional users needing varied information.
- Typically middle- or high-level managers.
- Use query language to specify requests.

- Naive/Parametric End Users:


- Largest user group.
- Frequently use standard canned transactions.
- Examples: Bank tellers, reservation clerks.

- Sophisticated End Users:


- Thoroughly familiar with DBMS facilities for complex applications.

- Stand-alone Users:
- Maintain personal databases using user-friendly program packages.
- Example: Users of tax packages for financial data storage.

System Analysts and Application Programmers (Software Engineers):


- System Analysts:
- Determine needs of end users, especially naive and parametric users.
- Develop specifications for canned transactions meeting user requirements.
- Application Programmers:
- Implement, test, document, and maintain programs based on specifications.

Workers Behind the Scene:


- DBMS System Designers and Implementers:
- Design and implement DBMS modules and interfaces.
- Components include catalog implementation, query processing, data access, concurrency
control, and security.

- Tool Developers:
- Design and implement tools for database modeling, system design, and performance
enhancement.

- Operators and Maintenance Personnel (System Administration Personnel):


- Responsible for day-to-day running and upkeep of hardware and software for the
database system.

5. Explain different categories of data model

Data Model A data model is a collection of concepts that can be used to describe the
structure of a database.

- High-level or conceptual data models:

- Provide concepts that are close to the way many users perceive data.

- Use concepts such as entities, attributes, and relationships to describe the database structure.

- Representational or implementation data models:

- Offer concepts that are easily understood by end users but are not too far removed from the
actual data organization in computer storage.

- Hide many details of data storage on disk but can be directly implemented on a computer system.

- Include the relational data model and legacy data models like the network and hierarchical
models.

- Represent data using record structures and are sometimes referred to as record-based data
models.

- Low-level or physical data models:

- Describe the details of how data is stored on computer storage media, typically magnetic disks.

- Explain how data is stored as files on the computer, including information on record formats,
record orderings, and access paths.

6. Discuss different types of update operations on relational database. Explain how the basic
operations deal with constraint violation.
Types of Update Operations on Relational Database:

 Insert Operation:
o Inserts one or more new tuples into a relation.
o Can violate four types of constraints:
1. Domain Constraints: Violation occurs if an attribute value is not of
the appropriate data type.
2. Key Constraints: Violation occurs if a key value in the new tuple
already exists in another tuple.
3. Entity Integrity: Violation occurs if any part of the primary key of the
new tuple is NULL.
4. Referential Integrity: Violation occurs if a foreign key value refers to
a non-existent tuple in the referenced relation.
o Examples:
1. Insertion with NULL primary key → Violates entity integrity
constraint.
2. Insertion with duplicate primary key → Violates key constraint.
3. Insertion with foreign key value not in referenced table → Violates
referential integrity constraint.
4. Insertion satisfying all constraints → Acceptable.
 Delete Operation:
o Deletes tuples from a relation based on a specified condition.
o Can violate referential integrity if the deleted tuple is referenced by foreign
keys from other tuples.
o Examples:
1. Deletion of a tuple not referenced by others → Acceptable.
2. Deletion of a tuple referenced by others → Violates referential
integrity.
3. Deletion of a tuple referenced by multiple relations → Violates
referential integrity.
o Options if deletion causes a violation:
1. Restrict: Reject the deletion.
2. Cascade: Delete tuples that reference the deleted tuple.
3. Set Null or Set Default: Modify the referencing attribute values to
NULL or a default valid tuple.
 Update Operation:
o Changes values of one or more attributes in existing tuples.
o Requires specifying a condition to select the tuples to be modified.
o Examples:
1. Updating non-key attribute → Acceptable if it does not violate any
constraints.
2. Updating foreign key to an invalid value → Violates referential
integrity.
3. Updating primary key to a duplicate value → Violates primary key and
referential integrity constraints.
o Constraints checked during update:
1. New value must be of the correct data type and domain.
2. Must not violate primary key or referential integrity constraints.
7. Explain different types of attributes in ER model with example.
Types of Attributes in ER Model:

- Simple (Atomic) Attribute:


- Attributes that cannot be divided into smaller parts.
- Example: `Age`, `SSN` (Social Security Number).

- Composite Attribute:
- Attributes that can be divided into smaller sub-parts, which represent more basic
attributes with independent meanings.
- Example: `Name` can be divided into `First Name` and `Last Name`.

- Single-valued Attribute:
- Attributes that hold a single value for each entity instance.
- Example: `Date of Birth`.

- Multi-valued Attribute:
- Attributes that can hold multiple values for each entity instance.
- Example: `Phone Numbers` (an entity can have multiple phone numbers).

- Derived Attribute:
- Attributes whose values can be derived from other attributes.
- Example: `Age` can be derived from the `Date of Birth`.

- Stored Attribute:
- Attributes that are stored in the database.
- Example: `Date of Birth`, `Address`.

- Key Attribute:
- Attributes that uniquely identify an entity in an entity set.
- Example: `Employee ID` in an `Employee` entity set.

- Non-key Attribute:
- Attributes that do not participate in the uniqueness of an entity.
- Example: `Employee Name`, `Address` in an `Employee` entity set.

Examples:

1. Employee Entity:
- Simple Attribute: `SSN`
- Composite Attribute: `Name` (sub-attributes: `First Name`, `Last Name`)
- Single-valued Attribute: `Date of Birth`
- Multi-valued Attribute: `Phone Numbers`
- Derived Attribute: `Age` (derived from `Date of Birth`)
- Stored Attribute: `Date of Birth`, `Address`
- Key Attribute: `Employee ID`
- Non-key Attribute: `Employee Name`, `Address`
2. Student Entity:
- Simple Attribute: `Student ID`
- Composite Attribute: `Address` (sub-attributes: `Street`, `City`, `State`, `Zip Code`)
- Single-valued Attribute: `Date of Enrollment`
- Multi-valued Attribute: `Courses Enrolled`
- Derived Attribute: `Total Credits` (derived from `Courses Enrolled`)
- Stored Attribute: `Date of Birth`, `Address`
- Key Attribute: `Student ID`
- Non-key Attribute: `Student Name`, `Email`

By understanding and properly defining these different types of attributes in an ER model,


database designers can create a more accurate and efficient database schema that
effectively represents the real-world entities and their relationships.

8. Explain conceptual model (ER) to relational model mapping algorithm with example.
9. Explain relational model concepts schema, instance, primary key, super key, candidate
keyand weak entity
Relational Model Concepts:

1. Schema:
- Definition: Structure of the database at the logical level.
- Example: `Student(SID, Name, DateOfBirth, Address)`

2. Instance:
- Definition: Actual data in the database at a given time.
- Example:
```
| SID | Name | DateOfBirth | Address |
|------|------------|-------------|-----------------|
| 101 | John Doe | 2000-01-01 | 123 Elm St. |
| 102 | Jane Smith | 1999-05-15 | 456 Maple Ave. |
```

3. Primary Key:
- Definition: Unique identifier for a tuple in a table.
- Example: `SID` in the `Student` table.

4. Super Key:
- Definition: Set of attributes that uniquely identify a tuple.
- Example: `{SID}` and `{SID, Name}` in the `Student` table.

5. Candidate Key:
- Definition: Minimal super key; no subset can uniquely identify a tuple.
- Example: `SID` and potentially `Email` if unique in the `Student` table.

6. Weak Entity:
- Definition: Entity that cannot be uniquely identified by its own attributes alone; relies on
a strong entity.
- Example: `Dependent(DID, DependentName, EmployeeID)` where `DID` and `EmployeeID`
together uniquely identify a dependent.

These concepts help ensure data integrity, consistency, and efficient data management in a
relational database.

10. Explain Schema, instance, canned transaction, data model.

Schema:
- Definition: The overall structure of a database defined at the logical level. It includes the
definitions of tables, fields, and the relationships between them.
- Example: A `Student` schema may include the following structure:
```
Student(SID, Name, DateOfBirth, Address)
```

Instance:
- Definition: The actual content of the database at a particular point in time. It is the
collection of data stored in the database.
- Example: An instance of the `Student` table might include:
```
| SID | Name | DateOfBirth | Address |
|------|------------|-------------|-----------------|
| 101 | John Doe | 2000-01-01 | 123 Elm St. |
| 102 | Jane Smith | 1999-05-15 | 456 Maple Ave. |
```

Canned Transaction:
- Definition: Predefined, structured transactions designed to be executed frequently with
minimal input from the user. They are typically used for routine tasks and have been
carefully programmed and tested.
- Example: A bank teller using a transaction to check account balances or post withdrawals
and deposits.

Data Model:
- Definition: A collection of concepts that can be used to describe the structure of a
database, including data types, relationships, and constraints. It provides the necessary
means to model real-world scenarios in a database.
- Example: The Relational Data Model, which represents data in tables (relations) with rows
(tuples) and columns (attributes). Other examples include the Entity-Relationship Model and
the Object-Oriented Data Model.

These concepts are foundational in database design and management, helping to define,
organize, and manipulate data efficiently and effectively.

You might also like