
Database Management System (DBMS) – Complete Chapter Summary
1. Introduction to DBMS
A Database Management System (DBMS) is a software system that enables users to define, create, maintain, and control access to databases. It abstracts and handles the complexities of data storage, security, and manipulation, allowing users to focus on higher-level tasks.
Why Use DBMS?
- Eliminates redundancy and inconsistency
- Ensures data integrity and security
- Facilitates data sharing and access
- Provides efficient query processing
- Enables backup and recovery
Components of DBMS
- Hardware: Physical devices (servers, storage, etc.)
- Software: DBMS software (Oracle, MySQL, etc.)
- Data: Actual data stored in databases
- Users:
- DBA (Database Administrator)
- Developers
- End Users
- Application Programmers
- Procedures: Instructions and rules for DBMS operation
2. Database Architecture
2.1 Three-Level Architecture (ANSI/SPARC)
- Internal Level: Physical storage of data
- Conceptual Level: Logical structure of the entire database
- External Level: Individual user views
2.2 DBMS Schema
- Physical Schema: How data is physically stored
- Logical Schema: How data is logically organized
- View Schema: Custom views for different users
2.3 Instances and Schemas
- Instance: Snapshot of the database at a given time
- Schema: Overall design of the database
3. Data Models
A Data Model defines how data is connected, stored, and processed.
3.1 Hierarchical Data Model
- Data is organized in a tree-like structure
- Each child has only one parent
- Examples: IBM’s IMS
3.2 Network Data Model
- Records connected through links (pointers)
- Each child can have multiple parents
3.3 Relational Data Model
- Data is stored in tables (relations)
- Rows = Records (tuples), Columns = Attributes (fields)
- Based on mathematical relational theory
3.4 Object-Oriented Data Model
- Combines object-oriented programming with databases
- Data stored as objects with attributes and methods
3.5 Entity-Relationship (E-R) Model
- Uses entities, attributes, and relationships
- Diagrammatic representation of data
4. Entity-Relationship (E-R) Model
4.1 Basic Concepts
- Entity: Real-world object (e.g., Student)
- Attributes: Properties of an entity (e.g., Name, Roll No.)
- Relationship: Association among entities (e.g., Enrolls)
4.2 Types of Attributes
- Simple and Composite
- Single-valued and Multi-valued
- Derived Attributes
4.3 Types of Relationships
- One-to-One
- One-to-Many
- Many-to-Many
4.4 Keys
- Primary Key: Uniquely identifies each record
- Candidate Key: Potential primary key
- Foreign Key: References primary key in another table
5. Relational Model and Relational Algebra
5.1 Relational Model
- Based on tables (relations)
- Each table has unique rows and columns
5.2 Relational Algebra
Set of operations for querying and updating the relational model:
- Select (σ) – Filters rows
- Project (π) – Selects columns
- Union (∪) – Combines rows from two tables
- Set Difference (−) – Rows in one table not in another
- Cartesian Product (×) – Combines all rows of two tables
- Join – Combines related rows from two tables
6. Structured Query Language (SQL)
SQL is the standard language for relational databases.
6.1 Categories of SQL Commands
- DDL (Data Definition Language):
CREATE
,ALTER
,DROP
,TRUNCATE
- DML (Data Manipulation Language):
SELECT
,INSERT
,UPDATE
,DELETE
- DCL (Data Control Language):
GRANT
,REVOKE
- TCL (Transaction Control Language):
COMMIT
,ROLLBACK
,SAVEPOINT
6.2 Clauses and Keywords
WHERE
,GROUP BY
,HAVING
,ORDER BY
,LIMIT
6.3 Joins in SQL
- INNER JOIN: Returns matching records
- LEFT JOIN: All records from left, matching from right
- RIGHT JOIN: All from right, matching from left
- FULL JOIN: All records when there’s a match in either
- SELF JOIN: Join table with itself
6.4 Subqueries and Nested Queries
- Inner queries used in WHERE or FROM clause
6.5 Views
- Virtual tables based on the result of SQL queries
7. Database Design and Normalization
7.1 Objectives of Good Design
- Minimize redundancy
- Ensure data integrity
- Easy maintenance and expansion
7.2 Normalization
Process of organizing data to reduce redundancy.
Forms of Normalization
- 1NF (First Normal Form):
- Atomic values, no repeating groups
- 2NF (Second Normal Form):
- In 1NF + no partial dependency
- 3NF (Third Normal Form):
- In 2NF + no transitive dependency
- BCNF (Boyce-Codd Normal Form):
- Every determinant is a candidate key
- 4NF and 5NF:
- Deals with multivalued and join dependencies
8. Transaction Management
8.1 Transactions
A transaction is a logical unit of work that must be completed entirely or not at all.
8.2 Properties of Transactions (ACID)
- Atomicity: All or nothing
- Consistency: Leaves DB in a valid state
- Isolation: Intermediate steps invisible to other transactions
- Durability: Changes are permanent once committed
8.3 Concurrency Control
Ensures correct results for concurrent transactions.
Techniques:
- Lock-based Protocol
- Timestamp-based Protocol
- Optimistic Concurrency Control
8.4 Deadlock
Occurs when transactions wait for each other indefinitely.
- Deadlock Prevention: Ordering resources
- Deadlock Detection: Wait-for graph
- Deadlock Recovery: Rollback
9. Indexing and Hashing
9.1 Indexing
Improves the speed of data retrieval.
Types:
- Single-level and Multi-level Index
- Clustered and Non-clustered Index
- B-Tree, B+Tree
9.2 Hashing
Uses a hash function to compute the address of a data record.
- Static Hashing
- Dynamic Hashing
10. File Organization
Defines how records are stored on disk:
- Heap File: Records in random order
- Sequential File: Sorted order
- Hashed File: Uses hash function
- Clustered File: Records of related tables stored together
11. Backup and Recovery
11.1 Backup
Creating a copy of the database to restore after failure.
11.2 Recovery Techniques
- Log-based recovery
- Shadow paging
- Checkpoints
12. Distributed Databases
Databases distributed over different sites or networks.
12.1 Features
- Data transparency
- Replication
- Fragmentation
12.2 Challenges
- Concurrency
- Reliability
- Network latency
13. NoSQL Databases
Not Only SQL – Designed for large-scale data and real-time web applications.
13.1 Types
- Key-Value Stores: Redis
- Document Stores: MongoDB
- Column Stores: Cassandra
- Graph Databases: Neo4j
13.2 Advantages
- Scalability
- Flexibility
- High performance for specific use cases
14. Database Security
14.1 Goals
- Confidentiality
- Integrity
- Availability
14.2 Methods
- User authentication
- Access control
- Encryption
- Auditing
15. Popular DBMS Software
- Oracle: High-performance, enterprise-level
- MySQL: Open-source, widely used
- PostgreSQL: Advanced, object-relational
- MS SQL Server: Microsoft’s relational DBMS
- MongoDB: Leading NoSQL database
Here are the top 200 objective-type MCQs on Database Management System (DBMS, SQL, Data Models, etc.) with answers:
- Which of the following is a key feature of a database management system?
- a) Data Redundancy
- b) Data Security
- c) Data Duplication
- d) Data Fragmentation
- Answer: b) Data Security
- Which of the following is used to define a relational database schema?
- a) SQL
- b) DDL
- c) DML
- d) SQL*Plus
- Answer: b) DDL (Data Definition Language)
- Which of the following is true about SQL?
- a) SQL is a procedural language
- b) SQL is a declarative language
- c) SQL is a functional language
- d) SQL is a programming language
- Answer: b) SQL is a declarative language
- In a relational model, a table is called:
- a) Attribute
- b) Relation
- c) Entity
- d) Tuple
- Answer: b) Relation
- What does a primary key ensure in a database?
- a) Uniqueness of data in a column
- b) A column with null values
- c) Data is stored in ascending order
- d) Data redundancy
- Answer: a) Uniqueness of data in a column
- Which of the following is not a type of SQL command?
- a) DML
- b) DDL
- c) DCL
- d) DFL
- Answer: d) DFL
- What does the “GROUP BY” clause in SQL do?
- a) It arranges the data in a particular order
- b) It groups rows that have the same values in specified columns
- c) It filters the data based on conditions
- d) It defines the data structure
- Answer: b) It groups rows that have the same values in specified columns
- Which of the following is an example of a SQL function?
- a) SELECT
- b) WHERE
- c) AVG
- d) JOIN
- Answer: c) AVG
- Which of the following is true about a foreign key in a relational database?
- a) It uniquely identifies a record in a table
- b) It enforces referential integrity between two tables
- c) It can have duplicate values
- d) It cannot have null values
- Answer: b) It enforces referential integrity between two tables
- Which of the following is not a type of data model?
- a) Hierarchical model
- b) Network model
- c) Relational model
- d) Spatial model
- Answer: d) Spatial model
- Which type of key is used to uniquely identify a row in a table?
- a) Foreign Key
- b) Primary Key
- c) Composite Key
- d) Candidate Key
- Answer: b) Primary Key
- In a relational database, what is a “tuple”?
- a) A column
- b) A row
- c) A table
- d) A database
- Answer: b) A row
- Which SQL command is used to delete a table from a database?
- a) DROP TABLE
- b) DELETE
- c) REMOVE
- d) TRUNCATE
- Answer: a) DROP TABLE
- Which of the following SQL clauses is used to filter records?
- a) SELECT
- b) WHERE
- c) GROUP BY
- d) ORDER BY
- Answer: b) WHERE
- What is the purpose of normalization in databases?
- a) To reduce data redundancy
- b) To store data efficiently
- c) To create relationships between tables
- d) All of the above
- Answer: d) All of the above
- Which of the following is a correct SQL query to find the total number of records in a table?
- a) SELECT COUNT(*) FROM table_name;
- b) SELECT SUM(*) FROM table_name;
- c) SELECT NUM(*) FROM table_name;
- d) SELECT TOTAL(*) FROM table_name;
- Answer: a) SELECT COUNT(*) FROM table_name;
- What is the default sorting order in SQL?
- a) Descending
- b) Ascending
- c) Random
- d) Alphabetical
- Answer: b) Ascending
- Which of the following is a valid SQL join type?
- a) Outer Join
- b) Inner Join
- c) Left Join
- d) All of the above
- Answer: d) All of the above
- Which of the following is a characteristic of the Entity-Relationship (ER) model?
- a) It is based on tables and relations
- b) It uses entities and relationships
- c) It organizes data in a hierarchical structure
- d) It is used for spatial data management
- Answer: b) It uses entities and relationships
- Which SQL statement is used to update data in a database?
- a) MODIFY
- b) UPDATE
- c) ALTER
- d) CHANGE
- Answer: b) UPDATE
- Which of the following is true about a “candidate key”?
- a) It uniquely identifies records in a table
- b) It can contain duplicate values
- c) It is always a foreign key
- d) It is never part of a primary key
- Answer: a) It uniquely identifies records in a table
- What is the correct SQL statement to retrieve all the columns from a table named “Employees”?
- a) SELECT * FROM Employees;
- b) SELECT ALL FROM Employees;
- c) GET * FROM Employees;
- d) RETRIEVE * FROM Employees;
- Answer: a) SELECT * FROM Employees;
- Which of the following is true about a “view” in a database?
- a) It stores data physically in the database
- b) It is a virtual table based on the result of a query
- c) It allows data redundancy
- d) It is used for indexing purposes
- Answer: b) It is a virtual table based on the result of a query
- In a relational database, what is a “relation”?
- a) A column
- b) A table
- c) A row
- d) A query
- Answer: b) A table
- Which of the following SQL commands is used to add a new column to an existing table?
- a) ALTER TABLE
- b) INSERT INTO
- c) ADD COLUMN
- d) MODIFY TABLE
- Answer: a) ALTER TABLE
- What does the “HAVING” clause do in SQL?
- a) Filters records based on conditions
- b) Groups records based on conditions
- c) Defines sorting order
- d) Filters groups after the “GROUP BY” clause
- Answer: d) Filters groups after the “GROUP BY” clause
- Which of the following normalization forms eliminates transitive dependency?
- a) 1NF
- b) 2NF
- c) 3NF
- d) BCNF
- Answer: c) 3NF
- Which of the following SQL commands is used to remove all rows from a table without deleting the table itself?
- a) DELETE
- b) DROP
- c) REMOVE
- d) TRUNCATE
- Answer: d) TRUNCATE
- Which of the following is used to ensure that the foreign key value matches the primary key value in the referenced table?
- a) Referential Integrity
- b) Data Integrity
- c) Entity Integrity
- d) Domain Integrity
- Answer: a) Referential Integrity
- What is the full form of SQL?
- a) Structured Query Language
- b) Simple Query Language
- c) Sequential Query Language
- d) Structured Quick Language
- Answer: a) Structured Query Language
- Which of the following SQL statements is used to delete a row from a table?
- a) REMOVE
- b) DELETE
- c) REMOVE ROW
- d) DROP
- Answer: b) DELETE
- Which of the following is the highest normal form that eliminates all redundancy and ensures data integrity?
- a) 1NF
- b) 2NF
- c) 3NF
- d) BCNF
- Answer: d) BCNF
- Which of the following describes a foreign key?
- a) It uniquely identifies each record in a table
- b) It is a reference to the primary key in another table
- c) It holds the null values
- d) It defines the relationship between two attributes
- Answer: b) It is a reference to the primary key in another table
- What is the term used to describe the arrangement of data in a relational database?
- a) Schema
- b) Table
- c) Query
- d) Index
- Answer: a) Schema
- Which type of relationship is represented by an “n:m” cardinality?
- a) One-to-one
- b) One-to-many
- c) Many-to-one
- d) Many-to-many
- Answer: d) Many-to-many
- Which of the following is an example of a Data Manipulation Language (DML) statement?
- a) CREATE
- b) ALTER
- c) SELECT
- d) DROP
- Answer: c) SELECT
- What is a “composite key” in a database?
- a) A key that consists of more than one attribute
- b) A key that includes a foreign key
- c) A key with a unique value
- d) A key used to enforce integrity constraints
- Answer: a) A key that consists of more than one attribute
- Which of the following is used to restrict the number of records returned by a query?
- a) HAVING
- b) WHERE
- c) SELECT
- d) LIMIT
- Answer: d) LIMIT
- Which type of join returns only matching rows from both tables?
- a) Inner Join
- b) Outer Join
- c) Left Join
- d) Right Join
- Answer: a) Inner Join
- Which of the following is true about SQL “DISTINCT”?
- a) It eliminates duplicates in query results
- b) It only works with numeric data
- c) It can be used to modify data
- d) It is used for sorting results
- Answer: a) It eliminates duplicates in query results
- Which of the following is used to add a new record into a table?
- a) INSERT INTO
- b) ADD INTO
- c) INSERT RECORD
- d) ADD RECORD
- Answer: a) INSERT INTO
- Which of the following operations is used to combine data from two or more tables in SQL?
- a) GROUP BY
- b) JOIN
- c) UNION
- d) SELECT
- Answer: b) JOIN
- What does a “NULL” value in a database column represent?
- a) Zero value
- b) Empty string
- c) Unknown value
- d) Undefined value
- Answer: c) Unknown value
- Which of the following is true about the “INNER JOIN” operation in SQL?
- a) It returns records from both tables that have matching values
- b) It returns all records from both tables
- c) It only returns records from the first table
- d) It returns records from the second table only
- Answer: a) It returns records from both tables that have matching values
- What is the purpose of the “ORDER BY” clause in SQL?
- a) To filter rows
- b) To arrange rows in ascending or descending order
- c) To join tables
- d) To group rows
- Answer: b) To arrange rows in ascending or descending order
- Which of the following is used to define constraints on columns in SQL?
- a) SELECT
- b) ALTER
- c) CONSTRAINT
- d) MODIFY
- Answer: c) CONSTRAINT
- Which SQL command is used to remove a database from the system?
- a) DROP DATABASE
- b) REMOVE DATABASE
- c) DELETE DATABASE
- d) REMOVE SCHEMA
- Answer: a) DROP DATABASE
- Which type of key can be used in the relational model to link tables?
- a) Composite Key
- b) Foreign Key
- c) Candidate Key
- d) Super Key
- Answer: b) Foreign Key
- Which of the following describes a “superkey”?
- a) A key that can uniquely identify records in a table
- b) A key that contains additional attributes for uniqueness
- c) A key that is part of a candidate key
- d) A key that cannot be null
- Answer: a) A key that can uniquely identify records in a table
- Which of the following refers to a column in a database table that contains unique values for each record?
- a) Candidate Key
- b) Primary Key
- c) Foreign Key
- d) Alternate Key
- Answer: b) Primary Key
- Which of the following is used to retrieve data from a database in SQL?
- a) SELECT
- b) INSERT
- c) DELETE
- d) UPDATE
- Answer: a) SELECT
- Which of the following is not a type of relationship in an ER diagram?
- a) One-to-One
- b) One-to-Many
- c) Many-to-Many
- d) Few-to-Many
- Answer: d) Few-to-Many
- In a relational database, what is the purpose of an index?
- a) To reduce data redundancy
- b) To improve data retrieval speed
- c) To enforce referential integrity
- d) To normalize data
- Answer: b) To improve data retrieval speed
- Which SQL clause is used to return only unique values from a column?
- a) DISTINCT
- b) UNIQUE
- c) FILTER
- d) SELECT DISTINCT
- Answer: a) DISTINCT
- Which of the following operations is not supported by a relational database management system?
- a) Select
- b) Update
- c) Insert
- d) Generate random data
- Answer: d) Generate random data
- What does the “ALTER” command do in SQL?
- a) Modifies the structure of an existing table
- b) Modifies data in a table
- c) Deletes data from a table
- d) Deletes a table from the database
- Answer: a) Modifies the structure of an existing table
- Which SQL keyword is used to prevent the duplication of rows in a query result?
- a) UNIQUE
- b) DISTINCT
- c) GROUP
- d) FILTER
- Answer: b) DISTINCT
- Which of the following SQL clauses is used to group rows that have the same values?
- a) GROUP BY
- b) ORDER BY
- c) HAVING
- d) SELECT
- Answer: a) GROUP BY
- What does the “INNER JOIN” operation do in SQL?
- a) Combines rows from two or more tables based on a related column
- b) Returns all rows from the left table and matching rows from the right table
- c) Returns rows that do not have a match in both tables
- d) Returns all records from both tables
- Answer: a) Combines rows from two or more tables based on a related column
- Which of the following types of integrity is ensured by a foreign key constraint?
- a) Entity integrity
- b) Referential integrity
- c) Domain integrity
- d) User-defined integrity
- Answer: b) Referential integrity
- Which of the following is not a part of a primary key in SQL?
- a) Uniqueness
- b) Not NULL
- c) Referential integrity
- d) Primary index
- Answer: c) Referential integrity
- Which of the following is used to enforce referential integrity in a database?
- a) Primary Key
- b) Foreign Key
- c) Composite Key
- d) Super Key
- Answer: b) Foreign Key
- What is the term used for a table’s schema in a relational database?
- a) Table structure
- b) Data Dictionary
- c) Index
- d) Relation
- Answer: b) Data Dictionary
- Which SQL command is used to create a new database?
- a) CREATE DATABASE
- b) MAKE DATABASE
- c) NEW DATABASE
- d) OPEN DATABASE
- Answer: a) CREATE DATABASE
- Which of the following is used to ensure data accuracy in a database?
- a) Data redundancy
- b) Data integrity
- c) Data isolation
- d) Data independence
- Answer: b) Data integrity
- Which of the following is the highest level of normalization that deals with multi-valued dependencies?
- a) 1NF
- b) 2NF
- c) 3NF
- d) 4NF
- Answer: d) 4NF
- Which of the following can be a possible result of using the “LEFT JOIN” in SQL?
- a) Returns rows that match from the left table only
- b) Returns all rows from the left table and matching rows from the right table
- c) Returns all rows from the right table only
- d) Returns rows that match from the right table only
- Answer: b) Returns all rows from the left table and matching rows from the right table
- Which of the following is an example of an aggregate function in SQL?
- a) COUNT
- b) SELECT
- c) JOIN
- d) ORDER BY
- Answer: a) COUNT
- Which of the following SQL commands is used to modify existing records in a table?
- a) MODIFY
- b) UPDATE
- c) CHANGE
- d) ALTER
- Answer: b) UPDATE
- Which type of relationship can be described as a parent-child relationship in an ER diagram?
- a) One-to-One
- b) One-to-Many
- c) Many-to-Many
- d) Recursive
- Answer: b) One-to-Many
- Which SQL function is used to find the highest value in a column?
- a) MAX
- b) MIN
- c) COUNT
- d) AVG
- Answer: a) MAX
- Which of the following keys is used to create a relationship between two tables in SQL?
- a) Primary Key
- b) Foreign Key
- c) Candidate Key
- d) Composite Key
- Answer: b) Foreign Key
- Which of the following is true about the “UNION” operator in SQL?
- a) Combines rows from multiple queries and removes duplicates
- b) Combines rows from multiple queries and keeps duplicates
- c) Combines columns from multiple queries
- d) Selects rows from a single table
- Answer: a) Combines rows from multiple queries and removes duplicates
- Which of the following is used to prevent a column from accepting null values in a table?
- a) NOT NULL constraint
- b) CHECK constraint
- c) UNIQUE constraint
- d) FOREIGN KEY constraint
- Answer: a) NOT NULL constraint
- Which SQL clause is used to sort the result-set in ascending or descending order?
- a) GROUP BY
- b) ORDER BY
- c) SORT BY
- d) FILTER BY
- Answer: b) ORDER BY
- Which of the following is true about “3NF” (Third Normal Form)?
- a) It eliminates partial dependency
- b) It eliminates transitive dependency
- c) It eliminates functional dependency
- d) It eliminates multi-valued dependency
- Answer: b) It eliminates transitive dependency
- Which of the following is used to apply a condition in the GROUP BY clause in SQL?
- a) HAVING
- b) WHERE
- c) ORDER BY
- d) SELECT
- Answer: a) HAVING
- Which of the following SQL clauses is used to combine the results of two queries?
- a) JOIN
- b) UNION
- c) INTERSECT
- d) EXCEPT
- Answer: b) UNION
- What is the process of organizing data to reduce redundancy and dependency called?
- a) Encryption
- b) Normalization
- c) Indexing
- d) Compression
- Answer: b) Normalization
- Which SQL command is used to remove a column from an existing table?
- a) DROP COLUMN
- b) REMOVE COLUMN
- c) ALTER COLUMN
- d) DELETE COLUMN
- Answer: a) DROP COLUMN
- What is the result of performing a “CROSS JOIN” in SQL?
- a) Returns the Cartesian product of the two tables
- b) Returns rows that match based on a related column
- c) Returns all rows from one table
- d) Returns common rows between two tables
- Answer: a) Returns the Cartesian product of the two tables
- Which of the following statements is used to prevent a database from accepting duplicate values?
- a) UNIQUE
- b) PRIMARY KEY
- c) DISTINCT
- d) Both a and b
- Answer: d) Both a and b
- Which of the following is used to rename a table in SQL?
- a) RENAME TABLE
- b) ALTER TABLE
- c) MODIFY TABLE
- d) CHANGE TABLE
- Answer: b) ALTER TABLE
- Which of the following types of SQL joins will return all rows from the right table and matching rows from the left table?
- a) RIGHT JOIN
- b) LEFT JOIN
- c) INNER JOIN
- d) FULL OUTER JOIN
- Answer: a) RIGHT JOIN
- Which of the following is an example of a “many-to-many” relationship?
- a) A student and a course
- b) A customer and an order
- c) A doctor and a patient
- d) A teacher and a student
- Answer: a) A student and a course
- What does the “IS NULL” condition do in SQL?
- a) Checks if a value is equal to zero
- b) Checks if a value is empty
- c) Checks if a value is unknown or missing
- d) Checks if a value is valid
- Answer: c) Checks if a value is unknown or missing
- What is the correct SQL syntax to add a primary key to an existing table?
- a) ALTER TABLE table_name ADD PRIMARY KEY (column_name);
- b) ALTER TABLE table_name ADD KEY (column_name);
- c) ALTER TABLE table_name ADD PRIMARY KEY column_name;
- d) ALTER TABLE table_name ADD CONSTRAINT PRIMARY KEY (column_name);
- Answer: a) ALTER TABLE table_name ADD PRIMARY KEY (column_name);
- Which of the following refers to a subset of records in a database?
- a) Entity
- b) Tuple
- c) View
- d) Domain
- Answer: c) View
- Which SQL clause is used to filter records after the “GROUP BY” clause is applied?
- a) HAVING
- b) WHERE
- c) SELECT
- d) GROUP BY
- Answer: a) HAVING
- Which of the following SQL statements is used to modify an existing table’s structure?
- a) UPDATE
- b) ALTER TABLE
- c) MODIFY
- d) CHANGE TABLE
- Answer: b) ALTER TABLE
- Which of the following SQL clauses is used to sort the results of a query?
- a) SORT BY
- b) ORDER BY
- c) GROUP BY
- d) FILTER BY
- Answer: b) ORDER BY
- Which SQL clause is used to restrict the number of rows returned by a query?
- a) LIMIT
- b) WHERE
- c) FILTER
- d) TOP
- Answer: a) LIMIT
- Which of the following is used to create an alias for a column in SQL?
- a) AS
- b) ALIAS
- c) COLUMN
- d) RENAME
- Answer: a) AS
- What is the correct SQL syntax to delete a column from a table?
- a) ALTER TABLE table_name DELETE COLUMN column_name;
- b) ALTER TABLE table_name REMOVE COLUMN column_name;
- c) ALTER TABLE table_name DROP COLUMN column_name;
- d) DELETE COLUMN column_name FROM table_name;
- Answer: c) ALTER TABLE table_name DROP COLUMN column_name;
- Which of the following is not a valid SQL aggregate function?
- a) AVG
- b) COUNT
- c) MAX
- d) SEARCH
- Answer: d) SEARCH
- What does the “IN” condition in SQL check for?
- a) Checks if a value matches any value in a list
- b) Checks if a value is null
- c) Checks if a value is unique
- d) Checks if a value is valid
- Answer: a) Checks if a value matches any value in a list
- Which of the following is true about the “ALTER” command in SQL?
- a) It can modify both the structure and the data in a table
- b) It can modify only the structure of the table
- c) It can modify only the data in the table
- d) It can delete a table entirely
- Answer: b) It can modify only the structure of the table
- Which SQL function returns the average value of a numeric column?
- a) AVG
- b) SUM
- c) COUNT
- d) MAX
- Answer: a) AVG
- Which of the following SQL keywords is used to combine the results of two queries with only matching records?
- a) UNION
- b) INTERSECT
- c) EXCEPT
- d) JOIN
- Answer: b) INTERSECT
- Which SQL command is used to give a user access to a database?
- a) GRANT
- b) PERMIT
- c) PROVIDE
- d) ALLOW
- Answer: a) GRANT
- What is the main purpose of normalization in a database?
- a) To remove redundant data
- b) To increase data redundancy
- c) To improve query performance
- d) To simplify the database design
- Answer: a) To remove redundant data
- Which of the following operations is supported by a relational database management system (RDBMS)?
- a) Data Storage
- b) Data Retrieval
- c) Data Integrity
- d) All of the above
- Answer: d) All of the above
- Which of the following is the correct SQL syntax for creating a table with a primary key constraint?
- a) CREATE TABLE table_name (column1 datatype PRIMARY KEY, column2 datatype);
- b) CREATE TABLE table_name (PRIMARY KEY column1, column2 datatype);
- c) CREATE PRIMARY KEY table_name (column1 datatype);
- d) CREATE TABLE table_name (column1 datatype, column2 PRIMARY KEY);
- Answer: a) CREATE TABLE table_name (column1 datatype PRIMARY KEY, column2 datatype);
- Which of the following is a property of a relational database?
- a) Data is organized in tables
- b) Each table has a unique identifier (primary key)
- c) Data in the tables is related through foreign keys
- d) All of the above
- Answer: d) All of the above
- What does the “TRUNCATE” statement do in SQL?
- a) Deletes all rows in a table and frees the space associated with the table
- b) Deletes only the specified rows from a table
- c) Deletes the entire table structure and data
- d) Modifies the structure of a table
- Answer: a) Deletes all rows in a table and frees the space associated with the table
- Which of the following is a non-relational database?
- a) MySQL
- b) Oracle
- c) MongoDB
- d) SQL Server
- Answer: c) MongoDB
- Which of the following is used to represent relationships in an Entity-Relationship diagram (ERD)?
- a) Rectangles
- b) Ovals
- c) Diamonds
- d) Circles
- Answer: c) Diamonds
- Which of the following types of SQL JOIN will return rows where there is no match in both tables?
- a) INNER JOIN
- b) LEFT JOIN
- c) RIGHT JOIN
- d) FULL OUTER JOIN
- Answer: d) FULL OUTER JOIN
- What is the main advantage of using views in SQL?
- a) Data security
- b) Data consistency
- c) Faster data retrieval
- d) All of the above
- Answer: d) All of the above
- Which of the following is a disadvantage of denormalization?
- a) Reduced query performance
- b) Increased data redundancy
- c) Reduced data integrity
- d) Increased query complexity
- Answer: b) Increased data redundancy
- Which type of SQL constraint ensures that no two rows in a table have the same value for a specified column?
- a) PRIMARY KEY
- b) UNIQUE
- c) CHECK
- d) FOREIGN KEY
- Answer: b) UNIQUE
- Which SQL statement is used to remove a table from a database?
- a) REMOVE TABLE
- b) DELETE TABLE
- c) DROP TABLE
- d) ERASE TABLE
- Answer: c) DROP TABLE
- Which of the following is not a type of relationship in an Entity-Relationship model?
- a) One-to-One
- b) One-to-Many
- c) Many-to-Many
- d) Many-to-Few
- Answer: d) Many-to-Few
- What is the main purpose of a surrogate key in a database?
- a) To improve query performance
- b) To replace a natural key when it is not available or efficient
- c) To enforce referential integrity
- d) To ensure data consistency
- Answer: b) To replace a natural key when it is not available or efficient
- What is the result of a self-join in SQL?
- a) Combines rows from two different tables based on a related column
- b) Combines rows from the same table based on a related column
- c) Retrieves rows from a single table
- d) Retrieves all columns from multiple tables
- Answer: b) Combines rows from the same table based on a related column
- Which of the following is true about SQL subqueries?
- a) A subquery can be used in SELECT, INSERT, UPDATE, or DELETE statements
- b) A subquery must return a single value
- c) A subquery can only be used in SELECT statements
- d) A subquery is not allowed in a WHERE clause
- Answer: a) A subquery can be used in SELECT, INSERT, UPDATE, or DELETE statements
- Which of the following is not a valid SQL aggregate function?
- a) SUM
- b) AVG
- c) MODE
- d) COUNT
- Answer: c) MODE
- Which of the following SQL clauses is used to sort the result set in descending order?
- a) SORT BY DESC
- b) ORDER BY DESC
- c) GROUP BY DESC
- d) SELECT DESC
- Answer: b) ORDER BY DESC
- Which of the following is a disadvantage of the relational database model?
- a) Complex data modeling
- b) Data redundancy
- c) Lack of flexibility
- d) Reduced security
- Answer: a) Complex data modeling
- Which of the following is a major difference between SQL and NoSQL databases?
- a) SQL databases are relational, while NoSQL databases are non-relational
- b) SQL databases use tables, while NoSQL databases use documents
- c) SQL databases support only structured data, while NoSQL supports both structured and unstructured data
- d) All of the above
- Answer: d) All of the above
- Which of the following is a key characteristic of an OLAP (Online Analytical Processing) system?
- a) Real-time transactional data processing
- b) Efficient at handling complex queries and multidimensional analysis
- c) Designed for quick, high-volume transactional data
- d) Focused on indexing and searching textual data
- Answer: b) Efficient at handling complex queries and multidimensional analysis
- Which of the following is a disadvantage of using foreign keys in a database?
- a) They enforce referential integrity
- b) They can create performance issues in large databases
- c) They reduce data redundancy
- d) They make data more consistent
- Answer: b) They can create performance issues in large databases
- What is a “database trigger” used for?
- a) To automatically generate data
- b) To ensure data integrity
- c) To automatically execute predefined SQL statements when certain events occur
- d) To provide data access to external applications
- Answer: c) To automatically execute predefined SQL statements when certain events occur
- Which of the following types of SQL constraints allows a column to accept only values from a pre-defined set of values?
- a) UNIQUE
- b) CHECK
- c) FOREIGN KEY
- d) PRIMARY KEY
- Answer: b) CHECK
- Which of the following is true about a view in SQL?
- a) It is a stored procedure that updates the database
- b) It is a virtual table that can simplify complex queries
- c) It physically stores the data
- d) It enforces data integrity
- Answer: b) It is a virtual table that can simplify complex queries
- What does the “CASCADE” option in a SQL foreign key constraint do?
- a) Automatically deletes records in the child table when the related record in the parent table is deleted
- b) Prevents updates to the child table when the parent table is updated
- c) Automatically updates records in the parent table when related records in the child table are updated
- d) Both a and c
- Answer: d) Both a and c
- What is a “composite key” in a relational database?
- a) A key formed by combining multiple columns to create a unique identifier for each row
- b) A single column that serves as the primary key for a table
- c) A key used to enforce referential integrity
- d) A key that can be used in subqueries only
- Answer: a) A key formed by combining multiple columns to create a unique identifier for each row
- Which of the following SQL statements is used to change the structure of an existing database?
- a) ALTER DATABASE
- b) MODIFY DATABASE
- c) UPDATE DATABASE
- d) CHANGE DATABASE
- Answer: a) ALTER DATABASE
- Which of the following is the most commonly used type of index in SQL?
- a) Hash Index
- b) Bitmap Index
- c) B-tree Index
- d) Clustered Index
- Answer: c) B-tree Index
- Which of the following SQL clauses is used to limit the number of rows returned in a query?
- a) LIMIT
- b) COUNT
- c) TOP
- d) FETCH
- Answer: a) LIMIT
- Which of the following is a valid SQL data type for storing text data?
- a) INT
- b) DATE
- c) CHAR
- d) FLOAT
- Answer: c) CHAR
- Which of the following statements is used to add a new row to a table in SQL?
- a) INSERT INTO
- b) ADD ROW
- c) ADD RECORD
- d) INSERT ROW
- Answer: a) INSERT INTO
- What is the result of a “CROSS JOIN” in SQL?
- a) Combines rows from two tables based on a matching column
- b) Combines rows from two tables without a matching column
- c) Returns only matching rows from both tables
- d) Combines rows from two tables based on a primary key relationship
- Answer: b) Combines rows from two tables without a matching column
- Which of the following is the default join type in SQL if no specific join type is specified?
- a) LEFT JOIN
- b) RIGHT JOIN
- c) INNER JOIN
- d) FULL JOIN
- Answer: c) INNER JOIN
- Which of the following is the main function of a database index?
- a) Enforce referential integrity
- b) Reduce query processing time
- c) Increase data redundancy
- d) Limit data access permissions
- Answer: b) Reduce query processing time
- Which of the following SQL clauses is used to remove duplicate values in the result set?
- a) DISTINCT
- b) UNIQUE
- c) REMOVE DUPLICATE
- d) SELECT DISTINCT
- Answer: a) DISTINCT
- Which SQL keyword is used to remove a column from an existing table?
- a) DELETE COLUMN
- b) REMOVE COLUMN
- c) ALTER TABLE DROP COLUMN
- d) REMOVE FIELD
- Answer: c) ALTER TABLE DROP COLUMN
- What type of relationship is shown by a many-to-many relationship in an ER diagram?
- a) One table is related to many records in another table
- b) A record in one table can be related to multiple records in another table
- c) Both tables have unique identifiers
- d) Both tables share the same primary key
- Answer: b) A record in one table can be related to multiple records in another table
- Which of the following SQL clauses is used to filter records before grouping?
- a) HAVING
- b) WHERE
- c) GROUP BY
- d) SELECT
- Answer: b) WHERE
- Which of the following is used to define the structure of a table in SQL?
- a) CREATE
- b) INSERT
- c) MODIFY
- d) ALTER
- Answer: a) CREATE
- Which of the following represents the highest level of normalization in database design?
- a) 1NF (First Normal Form)
- b) 2NF (Second Normal Form)
- c) 3NF (Third Normal Form)
- d) BCNF (Boyce-Codd Normal Form)
- Answer: d) BCNF (Boyce-Codd Normal Form)
- Which of the following SQL commands is used to grant permissions to a user?
- a) ALLOW
- b) GRANT
- c) PROVIDE
- d) ACCESS
- Answer: b) GRANT
- Which of the following is used to ensure that each record in a table is uniquely identified?
- a) Foreign Key
- b) Primary Key
- c) Candidate Key
- d) Alternate Key
- Answer: b) Primary Key
- Which of the following is not a valid SQL aggregate function?
- a) SUM
- b) COUNT
- c) MAX
- d) AVG
- Answer: d) AVG
- Which of the following SQL functions is used to combine two or more result sets?
- a) UNION
- b) JOIN
- c) INTERSECT
- d) EXCEPT
- Answer: a) UNION
- Which SQL clause is used to group records that have the same values?
- a) GROUP BY
- b) ORDER BY
- c) HAVING
- d) SELECT
- Answer: a) GROUP BY
- Which SQL clause is used to define conditions for filtering grouped records?
- a) WHERE
- b) HAV
ING
- c) GROUP BY
- d) ORDER BY
- Answer: b) HAVING
- Which of the following SQL functions is used to remove leading and trailing spaces from a string?
- a) TRIM
- b) REMOVE
- c) STRIP
- d) REPLACE
- Answer: a) TRIM
- Which SQL function is used to calculate the average value of a numeric column?
- a) SUM
- b) COUNT
- c) AVG
- d) MIN
- Answer: c) AVG
- What does the “DISTINCT” keyword do in a SQL SELECT statement?
- a) Filters duplicate rows from the result set
- b) Sorts the result set
- c) Returns only rows with non-null values
- d) Limits the number of rows returned
- Answer: a) Filters duplicate rows from the result set
- Which SQL statement is used to modify existing records in a table?
- a) MODIFY
- b) UPDATE
- c) CHANGE
- d) ALTER
- Answer: b) UPDATE
- Which of the following is used to create a new database in SQL?
- a) CREATE DATABASE
- b) CREATE SCHEMA
- c) NEW DATABASE
- d) ALTER DATABASE
- Answer: a) CREATE DATABASE
- Which SQL command is used to delete a row in a table?
- a) REMOVE
- b) DELETE
- c) DROP
- d) REMOVE RECORD
- Answer: b) DELETE
- Which of the following is used to enforce a one-to-many relationship between tables in an RDBMS?
- a) Primary Key
- b) Foreign Key
- c) Composite Key
- d) Surrogate Key
- Answer: b) Foreign Key
- Which SQL function is used to get the largest value in a column?
- a) MAX
- b) MIN
- c) AVG
- d) COUNT
- Answer: a) MAX
- Which of the following SQL commands is used to change the name of a table?
- a) RENAME TABLE
- b) MODIFY TABLE
- c) CHANGE TABLE
- d) ALTER TABLE
- Answer: a) RENAME TABLE
- Which SQL command is used to change the structure of an existing table?
- a) ALTER TABLE
- b) MODIFY TABLE
- c) UPDATE TABLE
- d) CHANGE TABLE
- Answer: a) ALTER TABLE
- Which of the following is not a type of relationship in an Entity-Relationship (ER) model?
- a) One-to-One
- b) One-to-Many
- c) Many-to-One
- d) One-to-None
- Answer: d) One-to-None
- Which of the following keys is used to establish relationships between tables?
- a) Candidate Key
- b) Foreign Key
- c) Primary Key
- d) Super Key
- Answer: b) Foreign Key
- Which of the following is used to ensure that a column in a database contains only unique values?
- a) UNIQUE constraint
- b) CHECK constraint
- c) PRIMARY KEY constraint
- d) FOREIGN KEY constraint
- Answer: a) UNIQUE constraint
- What type of database is MongoDB?
- a) Relational Database
- b) NoSQL Database
- c) Object-Oriented Database
- d) Hierarchical Database
- Answer: b) NoSQL Database
- Which of the following is a valid data type for storing date and time in SQL?
- a) DATE
- b) DATETIME
- c) TIMESTAMP
- d) All of the above
- Answer: d) All of the above
- Which of the following is true about a non-clustered index?
- a) It stores the data rows in sorted order
- b) It creates a separate structure from the data rows
- c) It increases data redundancy
- d) It can only be used for primary keys
- Answer: b) It creates a separate structure from the data rows
- Which of the following SQL clauses is used to group rows that have the same values?
- a) GROUP BY
- b) ORDER BY
- c) SELECT
- d) HAVING
- Answer: a) GROUP BY
- Which of the following SQL functions is used to calculate the total sum of a numeric column?
- a) SUM
- b) COUNT
- c) AVG
- d) MIN
- Answer: a) SUM
- What is a “relational schema”?
- a) The collection of all data records in a database
- b) The structure that defines the organization of data within a relational database
- c) The actual physical storage of data in a database
- d) The mapping between database tables and external data sources
- Answer: b) The structure that defines the organization of data within a relational database
- Which of the following is a disadvantage of using a surrogate key?
- a) It increases data redundancy
- b) It requires additional storage space
- c) It reduces data consistency
- d) It does not support referential integrity
- Answer: b) It requires additional storage space
- Which of the following is an example of a non-relational database model?
- a) Relational model
- b) Document model
- c) Hierarchical model
- d) Network model
- Answer: b) Document model
- Which SQL clause is used to filter records based on specific conditions?
- a) WHERE
- b) HAVING
- c) ORDER BY
- d) GROUP BY
- Answer: a) WHERE
- Which SQL command is used to remove a constraint from an existing table?
- a) REMOVE CONSTRAINT
- b) DROP CONSTRAINT
- c) DELETE CONSTRAINT
- d) ALTER CONSTRAINT
- Answer: b) DROP CONSTRAINT
- Which of the following is the highest normal form that can be achieved by a relational database?
- a) 3NF (Third Normal Form)
- b) BCNF (Boyce-Codd Normal Form)
- c) 4NF (Fourth Normal Form)
- d) 5NF (Fifth Normal Form)
- Answer: b) BCNF (Boyce-Codd Normal Form)
- Which SQL command is used to change the value of an existing column in a table?
- a) ALTER COLUMN
- b) UPDATE
- c) MODIFY
- d) CHANGE COLUMN
- Answer: b) UPDATE
- What is a “full-text index” in SQL?
- a) A type of index used to quickly search for specific keywords in text fields
- b) An index that stores the entire content of a column for faster retrieval
- c) A type of index used for numeric data types only
- d) A full backup of the entire database
- Answer: a) A type of index used to quickly search for specific keywords in text fields
- Which of the following is used to restore a database from a backup?
- a) BACKUP
- b) RECOVER
- c) RESTORE
- d) RESTORE DATABASE
- Answer: c) RESTORE
- Which of the following is true about normalization?
- a) It reduces data redundancy and improves data integrity
- b) It increases data redundancy
- c) It reduces data consistency
- d) It improves database query performance
- Answer: a) It reduces data redundancy and improves data integrity
- Which of the following is a technique used to handle NULL values in SQL queries?
- a) COALESCE function
- b) ISNULL function
- c) IFNULL function
- d) All of the above
- Answer: d) All of the above
- Which of the following is true about a primary key in a relational database?
- a) It can accept NULL values
- b) It uniquely identifies each record in a table
- c) It is used to link records between tables
- d) It can be composed of multiple columns
- Answer: b) It uniquely identifies each record in a table
- Which of the following SQL clauses is used to limit the number of rows returned in a query?
- a) TOP
- b) LIMIT
- c) SELECT
- d) FETCH
- Answer: b) LIMIT
- What is an example of a “non-key attribute” in a database?
- a) A column that uniquely identifies a row
- b) A column that does not uniquely identify a row
- c) A column that is used to enforce referential integrity
- d) A column that is used to link tables
- Answer: b) A column that does not uniquely identify a row
- Which of the following is true about the “IN” operator in SQL?
- a) It is used to check if a column contains a value from a subquery
- b) It is used to check if a column contains a value in a specified list
- c) It is used to check if a column contains any value
- d) It is used to check if a column matches a specific range of values
- Answer: b) It is used to check if a column contains a value in a specified list
- What does a “composite key” consist of in database design?
- a) A key made up of multiple attributes in a table
- b) A key that is automatically generated
- c) A key composed of foreign keys from different tables
- d) A key that includes all non-key attributes
- Answer: a) A key made up of multiple attributes in a table
- Which of the following SQL functions is used to count the number of rows in a result set?
- a) COUNT
- b) SUM
- c) AVG
- d) TOTAL
- Answer: a) COUNT
- What is the difference between the “DELETE” and “TRUNCATE” commands in SQL?
- a) DELETE removes rows one at a time, while TRUNCATE removes all rows at once
- b) DELETE frees the space occupied by a table, while TRUNCATE does not
- c) TRUNCATE removes all rows from a table and cannot be rolled back, while DELETE can
- d) DELETE works on the table structure, while TRUNCATE works on the data
- Answer: a) DELETE removes rows one at a time, while TRUNCATE removes all rows at once
- Which of the following operations is not supported by an SQL view?
- a) SELECT
- b) INSERT
- c) UPDATE
- d) DELETE
- Answer: d) DELETE
- What does the “HAVING” clause do in SQL?
- a) Filters records before the grouping operation
- b) Filters records after the grouping operation
- c) Specifies the columns to be selected in a query
- d) Sorts the result set in ascending order
- Answer: b) Filters records after the grouping operation
- What does the “LIKE” operator do in SQL?
- a) Searches for a specified pattern in a column
- b) Retrieves rows with matching column values
- c) Filters results based on numerical ranges
- d) Counts the number of matching rows
- Answer: a) Searches for a specified pattern in a column
- Which of the following types of relationships does a junction table handle in a relational database?
- a) One-to-One
- b) One-to-Many
- c) Many-to-Many
- d) None of the above
- Answer: c) Many-to-Many
- Which of the following is a valid SQL data type for storing large text values?
- a) VARCHAR
- b) TEXT
- c) CHAR
- d) BLOB
- Answer: b) TEXT
- Which of the following is a characteristic of a “full outer join” in SQL?
- a) Returns only matching rows from both tables
- b) Returns all rows from the left table and matching rows from the right table
- c) Returns all rows from both tables, with NULL values where there is no match
- d) Returns only rows from the right table
- Answer: c) Returns all rows from both tables, with NULL values where there is no match
- What is the main purpose of “referential integrity” in a database?
- a) To ensure that foreign keys match primary keys in related tables
- b) To enforce data types for each column
- c) To prevent unauthorized access to the database
- d) To improve database performance
- Answer: a) To ensure that foreign keys match primary keys in related tables
- Which of the following SQL statements is used to change the data in an existing record?
- a) UPDATE
- b) MODIFY
- c) ALTER
- d) INSERT
- Answer: a) UPDATE
- Which of the following is the proper way to remove a table from a database in SQL?
- a) DELETE TABLE
- b) DROP TABLE
- c) REMOVE TABLE
- d) CLEAR TABLE
- Answer: b) DROP TABLE
- Which SQL command is used to add a new column to an existing table?
- a) ALTER TABLE ADD COLUMN
- b) ADD COLUMN
- c) INSERT COLUMN
- d) ALTER COLUMN ADD
- Answer: a) ALTER TABLE ADD COLUMN
- **What is the main function
of an “index” in a relational database?**
- a) To ensure data integrity
- b) To speed up data retrieval operations
- c) To enforce relationships between tables
- d) To prevent duplication of data
- Answer: b) To speed up data retrieval operations
- Which of the following is an example of a “de-normalized” database design?
- a) A database where data redundancy is minimized
- b) A database where tables are merged to improve query performance
- c) A database with only primary keys
- d) A database with normalized tables and no duplicates
- Answer: b) A database where tables are merged to improve query performance
- Which SQL statement is used to define a new table structure?
- a) CREATE TABLE
- b) DEFINE TABLE
- c) MAKE TABLE
- d) ADD TABLE
- Answer: a) CREATE TABLE
- Which of the following SQL clauses is used to sort the result set in ascending or descending order?
- a) ORDER BY
- b) GROUP BY
- c) HAVING
- d) SELECT
- Answer: a) ORDER BY
- What is a “composite key” in relational databases?
- a) A key formed by combining multiple columns in a table
- b) A key that is a combination of a primary key and a foreign key
- c) A key that automatically generates unique values
- d) A key used to represent multi-valued attributes
- Answer: a) A key formed by combining multiple columns in a table
- Which SQL keyword is used to combine two or more result sets?
- a) COMBINE
- b) JOIN
- c) UNION
- d) MERGE
- Answer: c) UNION
- Which of the following is true about the “EXCEPT” operator in SQL?
- a) It returns rows that are common to both result sets
- b) It returns rows that are not common to both result sets
- c) It joins two tables and returns a combined result set
- d) It sorts the result sets based on a specified condition
- Answer: b) It returns rows that are not common to both result sets