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

Dbms q-a

The document provides an overview of database concepts, including definitions of databases, DBMS, data models, and normalization. It covers SQL basics, complex queries, views, and theory questions related to data independence, database schemas, and the role of a Database Administrator. Additionally, it discusses entity-relationship modeling, cardinality constraints, and functional dependencies.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

Dbms q-a

The document provides an overview of database concepts, including definitions of databases, DBMS, data models, and normalization. It covers SQL basics, complex queries, views, and theory questions related to data independence, database schemas, and the role of a Database Administrator. Additionally, it discusses entity-relationship modeling, cardinality constraints, and functional dependencies.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Certainly, let's include the answers to the theory questions as well.

Unit 1: Introduction to Database System Concepts and Architecture


●​ What is a Database?
○​ A collection of interrelated data stored in a structured format, allowing for efficient
retrieval and management.
●​ What is a DBMS?
○​ Database Management System - software that manages the creation, storage,
retrieval, and modification of data in a database.
●​ What are the advantages of using a DBMS?
○​ Data integrity, data security, data independence, efficient data access, reduced data
redundancy, and improved data sharing.
●​ What are the different types of data models?
○​ Hierarchical, network, relational, object-oriented, and NoSQL.
Unit 2: Data Modelling Using the Entity-Relationship Model
●​ What is an Entity?
○​ A real-world object or concept that you want to store information about.
●​ What is an Attribute?
○​ A property or characteristic of an entity.
●​ What is a Relationship?
○​ An association between two or more entities.
●​ What are the different types of relationships?
○​ One-to-one, one-to-many, and many-to-many.
Unit 3: Relational Data Model, Relational Constraints, and Relational Algebra
●​ What is a Relation?
○​ A two-dimensional table with rows and columns.
●​ What are the primary keys and foreign keys?
○​ Primary key: a unique identifier for each row in a table.
○​ Foreign key: a field in one table that references the primary key of another table.
●​ What are the basic relational algebra operations?
○​ Select, project, rename, union, intersection, difference, and Cartesian product.
Unit 4: Normalization
●​ What is Normalization?
○​ A process of organizing data in a database to minimize redundancy and improve
data integrity.
●​ What are the different normal forms?
○​ First Normal Form (1NF), Second Normal Form (2NF), Third Normal Form (3NF),
and Boyce-Codd Normal Form (BCNF).
Unit 5: Introduction to SQL
●​ What is SQL?
○​ Structured Query Language - a language used to interact with relational databases.
●​ What are the different types of SQL commands?
○​ DDL (Data Definition Language) - used to create, alter, and drop database objects.
○​ DML (Data Manipulation Language) - used to insert, update, delete, and retrieve
data.
●​ What are the common SQL clauses?
○​ WHERE, ORDER BY, GROUP BY, HAVING, JOIN, and subqueries.
Additional Concepts
●​ Data Independence: The ability to change the database schema without affecting the
application programs.
●​ ACID Properties: Atomicity, Consistency, Isolation, and Durability - properties that ensure
the reliability of database transactions.
●​ View in SQL: A virtual table that is created from the result of an SQL query.
●​ Trigger: A special type of stored procedure that is automatically executed when a specific
event occurs.
Complex SQL Queries
1.​ Employee Salaries and Managers:
○​ Question: Write an SQL query to find the names of all employees who earn more
than their managers.
○​ Answer:
SELECT e.name​
FROM employees e​
JOIN employees m ON e.manager_id = m.id​
WHERE e.salary > m.salary;​

2.​ Department with Highest Average Salary:


○​ Question: Write an SQL query to find the department with the highest average
salary.
○​ Answer:
SELECT department​
FROM employees​
GROUP BY department​
ORDER BY AVG(salary) DESC​
LIMIT 1;​

3.​ Top 3 Customers by Total Orders:


○​ Question: Write an SQL query to find the top 3 customers with the highest total
number of orders.
○​ Answer:
SELECT customer_name​
FROM customers​
JOIN orders ON customers.id = orders.customer_id​
GROUP BY customer_name​
ORDER BY COUNT(*) DESC​
LIMIT 3;​

Subqueries:
1.​ Employees with Salary Above Average:
○​ Question: Write an SQL query to find the names of all employees whose salary is
above the average salary of all employees.
○​ Answer:
SELECT name​
FROM employees​
WHERE salary > (SELECT AVG(salary) FROM employees);​

2.​ Customers with More Orders than Average:


○​ Question: Write an SQL query to find the names of all customers who have placed
more orders than the average number of orders per customer.
○​ Answer:
SELECT customer_name​
FROM customers​
WHERE id IN (​
SELECT customer_id​
FROM orders​
GROUP BY customer_id​
HAVING COUNT(*) > (SELECT AVG(COUNT(*)) FROM orders GROUP BY
customer_id)​
);​

Views:
1.​ Creating a View:
○​ Question: Create a view named high_salary_employees that contains the names
and salaries of all employees who earn more than $75,000.
○​ Answer:
CREATE VIEW high_salary_employees AS​
SELECT name, salary​
FROM employees​
WHERE salary > 75000;​

2.​ Using a View in a Query:


○​ Question: Write an SQL query to find the number of employees in the
high_salary_employees view.
○​ Answer:
SELECT COUNT(*)​
FROM high_salary_employees;​

Theory Questions
1.​ Define data independence and explain its significance in database systems.
○​ Answer: Data independence refers to the ability to change the database schema
(structure) without affecting the application programs that access the data. This is
crucial because it allows for flexibility and easier maintenance of the database.
2.​ What are the different types of data models? Briefly describe each.
○​ Answer:
■​ Hierarchical Model: Represents data as a tree-like structure with
parent-child relationships.
■​ Network Model: More flexible than hierarchical, allowing for multiple
parent-child relationships.
■​ Relational Model: Represents data in tables with rows and columns, the
most widely used model today.
■​ Object-Oriented Model: Represents data as objects with attributes and
methods.
■​ NoSQL Models: A broad category of database systems that don't rely on the
traditional relational model, offering flexibility and scalability.
3.​ Explain the concept of a database schema and its importance.
○​ Answer: A database schema is a logical blueprint or plan of the database structure.
It defines the tables, columns, data types, relationships, and constraints within the
database. The schema is crucial for understanding and designing the database,
ensuring data integrity, and facilitating efficient data retrieval.
4.​ What is the role of a Database Administrator (DBA)?
○​ Answer: A DBA is responsible for managing the database system, including tasks
such as:
■​ Designing and implementing the database schema
■​ Ensuring data security and integrity
■​ Monitoring database performance
■​ Backing up and recovering data
■​ Granting and managing user access
■​ Troubleshooting database issues
5.​ What are the key components of an Entity-Relationship Diagram (ERD)?
○​ Answer: Key components of an ERD include:
■​ Entities: Objects or concepts that you want to store information about.
■​ Attributes: Properties or characteristics of entities.
■​ Relationships: Associations between two or more entities.
■​ Cardinality: The number of instances of one entity that can be associated
with instances of another entity.
6.​ Explain the concept of a weak entity and its relationship with a strong entity.
○​ Answer:
■​ Weak Entity: An entity that cannot exist independently and depends on
another entity (strong entity) for its existence.
■​ Strong Entity: An entity that can exist independently and does not depend
on any other entity.
7.​ What are the different types of cardinality constraints in an ERD?
○​ Answer:
■​ One-to-one
■​ One-to-many
■​ Many-to-one
■​ Many-to-many
8.​ How do you represent a many-to-many relationship in an ERD?
○​ Answer: By creating an additional entity (called a junction or association entity) to
link the two entities involved in the many-to-many relationship.
9.​ Define a relation in the context of the relational model.
○​ Answer: A relation is a two-dimensional table with rows and columns. Each row
represents a tuple (record) and each column represents an attribute.
10.​Explain the concept of functional dependency and its importance in database
design.
○​ Answer: A functional dependency is a relationship between two attributes or sets of
attributes where the value of one determines the value of the other. Functional
dependencies are crucial in database design because

You might also like