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

5 mark

The document outlines the advantages of Database Management Systems (DBMS), including data integrity, security, and redundancy control. It also explains the components of an Entity-Relationship (ER) diagram, the benefits of Query By Example (QBE), the purpose of data normalization, and the principles of transaction processing. Additionally, it covers SQL set operations and the steps to create and manage a cursor in SQL.

Uploaded by

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

5 mark

The document outlines the advantages of Database Management Systems (DBMS), including data integrity, security, and redundancy control. It also explains the components of an Entity-Relationship (ER) diagram, the benefits of Query By Example (QBE), the purpose of data normalization, and the principles of transaction processing. Additionally, it covers SQL set operations and the steps to create and manage a cursor in SQL.

Uploaded by

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

5 mark

1. Advantages of DBMS (Database Management System):


A Database Management System (DBMS) provides several advantages that make it an essential tool in
managing and organizing data effectively:
• Data Integrity and Accuracy: DBMS ensures data consistency and accuracy by enforcing
constraints such as primary keys, foreign keys, and data types.
• Data Security: DBMS provides security mechanisms that restrict unauthorized access to
sensitive data. Permissions and roles can be assigned to users, controlling access at various
levels.
• Data Redundancy Control: DBMS reduces data redundancy by organizing data in a centralized
repository, avoiding the duplication of data across different files.
• Data Independence: DBMS offers a level of abstraction, separating data from application
programs, allowing for easier changes to the data structure without affecting application
logic.
• Concurrent Access: Multiple users can access and modify the database simultaneously
without interfering with each other’s operations, which is achieved through transaction
management and concurrency control mechanisms.
• Backup and Recovery: DBMS supports automated backup and recovery mechanisms to
prevent data loss in case of system failures.
• Data Sharing and Access Control: DBMS supports data sharing across various applications
and ensures that access control policies are enforced to maintain privacy and security.
2. Building Blocks of an ER Diagram:
An Entity-Relationship (ER) diagram is a visual representation of the entities and their relationships in
a database. The building blocks of an ER diagram are:
• Entities: Represent real-world objects or concepts (e.g., "Student," "Employee") that have
attributes.
• Attributes: Characteristics or properties of entities (e.g., "Student Name," "Employee ID").
Attributes can be of different types: simple, composite, derived, or multi-valued.
• Relationships: Represent associations between entities (e.g., "Employee works for
Department").
• Primary Key: A unique identifier for an entity (e.g., "Student ID" for the Student entity).
• Cardinality Constraints: Define the number of instances of one entity related to the number of
instances of another entity, such as one-to-one, one-to-many, or many-to-many.
• Weak Entities: Entities that do not have a sufficient unique identifier and depend on a "strong"
entity to ensure uniqueness.
• Participation Constraints: Indicate whether all or some entities are involved in a relationship
(total or partial participation).
3. Advantages of QBE (Query By Example):
Query By Example (QBE) is a database query language that allows users to construct queries by
providing examples rather than writing explicit SQL statements. Some of the key advantages include:
• User-Friendly: QBE is intuitive and user-friendly, making it easier for non-technical users to
build queries.
• Visual Query Creation: QBE uses a grid-like interface where users can specify values or
conditions by filling in columns, making it easier to visualize and create complex queries
without needing to know the exact syntax.
• No Need for SQL Knowledge: Users do not need to know SQL, as they can simply fill in the
desired fields in a structured format to get the result.
• Flexibility: QBE can be used to perform a wide variety of queries, including selection,
projection, and joins, just like SQL, but in a more visual manner.
• Error Reduction: The user is guided by the interface, reducing the chances of syntax errors in
query construction.
4. Purpose of Normalizing the Data:
Normalization is the process of organizing data in a database to minimize redundancy and
dependency. The primary purposes of normalizing data are:
• Eliminate Redundancy: By dividing a database into smaller, more manageable tables,
normalization helps remove duplicate data, which reduces storage space and improves
efficiency.
• Avoid Update Anomalies: Normalization helps ensure that updates, deletions, and insertions
are consistent and do not lead to data anomalies (e.g., partial or transitive dependencies).
• Improve Data Integrity: Normalizing data ensures that relationships between different tables
are consistent, making it easier to maintain data integrity and enforce constraints like foreign
keys.
• Simplify Queries: By reducing redundancy and organizing the data logically, normalized data is
easier to query, with fewer chances for confusion and errors.
5. Transaction Processing:
Transaction processing refers to the process of handling and managing database transactions in a
reliable, secure, and consistent manner. Key points include:
• Transaction: A transaction is a sequence of one or more operations performed as a single unit
of work. It must satisfy the ACID properties (Atomicity, Consistency, Isolation, Durability).
• ACID Properties:
o Atomicity: Ensures that all operations within a transaction are completed
successfully; if not, the transaction is rolled back.
o Consistency: The transaction must bring the database from one valid state to another
valid state.
o Isolation: Transactions are isolated from each other; intermediate states are invisible
to other transactions.
o Durability: Once a transaction is committed, its changes are permanent and survive
system crashes.
• Concurrency Control: Multiple transactions can be executed concurrently, but the DBMS must
ensure that they do not interfere with each other.
• Log-Based Recovery: DBMS keeps a transaction log to record changes, which helps in
recovering from failures by rolling back or redoing transactions.
6. Set Operations in SQL:
SQL provides set operations that allow you to combine results from multiple SELECT queries. The
common set operations are:
• UNION: Combines the results of two or more SELECT statements, excluding duplicates.
• UNION ALL: Combines the results of two or more SELECT statements, including duplicates.
• INTERSECT: Returns only the rows that are common to both SELECT queries.
• EXCEPT (or MINUS in some DBMSs): Returns rows from the first query that do not exist in the
second query.
Example:
sql
Copy code
SELECT column_name FROM table1
UNION
SELECT column_name FROM table2;
7. What is a Cursor? Steps to Create a Cursor:
A cursor is a database object used to retrieve, manipulate, and navigate through the result set of a
SQL query one row at a time. Cursors are particularly useful for processing queries that return
multiple rows when you need to handle each row individually.
Steps to Create a Cursor:
1. Declare the Cursor: Define the cursor and the SQL query it will use to retrieve data.
sql
Copy code
DECLARE cursor_name CURSOR FOR
SELECT column1, column2 FROM table_name WHERE condition;
2. Open the Cursor: Open the cursor to establish the context for fetching rows.
sql
Copy code
OPEN cursor_name;
3. Fetch Data: Fetch the next row from the cursor into variables for processing.
sql
Copy code
FETCH NEXT FROM cursor_name INTO @variable1, @variable2;
4. Process Data: Perform operations with the fetched data.
5. Close the Cursor: After all rows have been processed, close the cursor.
sql
Copy code
CLOSE cursor_name;
6. Deallocate the Cursor: Finally, deallocate the cursor to free up resources.
sql
Copy code
DEALLOCATE cursor_name;
Example:
sql
Copy code
DECLARE employee_cursor CURSOR FOR
SELECT employee_id, employee_name FROM employees WHERE department = 'HR';

OPEN employee_cursor;
FETCH NEXT FROM employee_cursor INTO @emp_id, @emp_name;

WHILE @@FETCH_STATUS = 0
BEGIN
PRINT @emp_id + ' ' + @emp_name;
FETCH NEXT FROM employee_cursor INTO @emp_id, @emp_name;
END

CLOSE employee_cursor;
DEALLOCATE employee_cursor;

You might also like