FinalTerm RahulChahal
FinalTerm RahulChahal
Focus College
Mrityunjay Gupta
Rahul Chahal
Final Exam 1
Question 3: What is a primary key used for in a relational database?
a. Sorting data
b. Ensuring uniqueness
c. Creating relationships
d. Performing calculations
Correct Answer: b. Ensuring uniqueness
a. Data storage
d. Index creation
Correct Answer: b. Visualization of data relationships
Final Exam 2
Answer:
Integrity in a relational database is like rules that make sure the information stored is
accurate and reliable. There are different types or different rules of integrity constraints
including.
Primary Key Constraint: Each row in the library must have a unique tag number
(primary key).
Not Null Constraint: This specifies that a column must always have a value and
cannot be left empty or null.
Check Constraint: This allows you to define a condition the data in a column must
satisfy. It limits the range of valid values that can be inserted into the column.
Therefore integrity constraints in the database can maintain data integrity, accuracy,
and consistency, ensuring the reliability and validity of the information stored within it.
Answer:
In the Relational database, the terms One-to-One, One-to-Many, and Many-to-Many
relationships are between tables.
Final Exam 3
2. One-to-Many Relationship: In a one-to-many relationship, each record in Table A
can be related to multiple records in Table B, but each record in Table B is related to
only one record in Table A.
Example: for example, we're managing a library. we have two tables, Library
and Book . Each library can have multiple books, but each book is located in
only one library. The relationship is established using a common key, such as
LibraryID in the Library table and LibraryID in the Book table.
Example: Imagine a database for a music store. You might have tables for
Artist and Album . Each artist can produce multiple albums, and each album
Avoids repeating the same information, making your data tidy and efficient.
Breaks down data into smaller bits, so changing one thing doesn't mess up
everything.
Final Exam 4
4. Facilitating Query Performance:
6. Supporting Scalability:
Sets a strong foundation for growth, letting you add new stuff without slowing
down.
Makes sure data follows the rules, keeping it reliable and trustworthy.
Answer: ACID, an acronym for Atomicity, Consistency, Isolation, and Durability, plays a
vital role in guaranteeing the dependability and integrity of database transactions.
ACID Properties
1. Atomicity:
Why It Matters: It ensures your actions happen together or not at all, avoiding
weird in-between situations.
2. Consistency:
What It Means: Your game follows rules before and after each move.
Why It Matters: Keeps your data following the rules, avoiding odd situations,
like negative items in your online cart.
Final Exam 5
3. Isolation:
What It Means: Each player (or user) is in their own bubble, not seeing others'
moves.
4. Durability:
What It Means: Saving your game progress stays saved, even if the power
goes out.
Why It Matters: Ensures once something is done, like buying a new game
level, it stays done, no matter what happens later.
Question 10: Describe the steps involved in the database design process.
Answer:
The database design process involves several key steps to ensure the creation of an
efficient and well-organized database. Some of the steps:
1. Data Modeling
2. Testing
3. Physical Design
5. Implementation
6. Training
7. Schema Refinement
8. Normalization
9. Documentation
Final Exam 6
11. Conceptual Design
12. Deployment
Question 11: Write a SQL query to retrieve all columns from the "Employees" table
where the salary is greater than 50000.
Answer
SELECT *
FROM Employees
WHERE Salary > 50000;
Question 12: Create a new table named "Orders" with columns for OrderID,
CustomerID, and OrderDate. Ensure that OrderID is the primary key.
Answer:
Final Exam 7
Question 13: Implement a JOIN operation to display the names of customers and their
corresponding orders.
Answer:
-- JION opertation
SELECT Customers.CustomerName, Orders.OrderID, Orders.OrderDate
FROM Customers
JOIN Orders ON Customers.CustomerID = Orders.CustomerID;
Question 14: Define a simple view named "HighSalaries" that displays employees
earning more than 70000.
Answer:
Final Exam 8
Question 15: Write a transaction in MySQL that transfers an amount of 1000 from one
bank account to another. Ensure the ACID properties are maintained.
Answer:
UPDATE BankAccounts
SET Balance = Balance - 1000
WHERE AccountID = 'RahulAccount';
UPDATE BankAccounts
SET Balance = Balance + 1000
WHERE AccountID = 'MrityunjayAcoount';
COMMIT;
END //
DELIMITER ;
CALL TransferAmount();
Final Exam 9