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

DMS questions and answers

Uploaded by

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

DMS questions and answers

Uploaded by

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

1. What is a Database?

A database is an organized collection of data stored for


easy access, management, and retrieval.

2. What are the different types of databases?


Types include relational, NoSQL, hierarchical, network,
object-oriented, and distributed databases.

3. What is DBMS? Explain its advantages.


DBMS is Management System for databases, offering data
security, integrity, and multi-user support.

4. What is the difference between DBMS and RDBMS?


DBMS handles unstructured data, while RDBMS organizes
data in tables with relationships.

5. What is a primary key?


A unique identifier for each record in a table.

6. What is a foreign key?


A column linking one table to the primary key of another.

7. What is a candidate key?


A column or set of columns that can uniquely identify a
record and is eligible to become a primary key.

8. What is a composite key?


A key made of two or more columns to uniquely identify a
record.

9. What is a unique key?


A constraint ensuring column values are unique, allowing
one null value.
DBMS Concepts

10. What is an entity in the context of DBMS?


An entity is a real-world object or concept represented
as a table in a database.

11. What is an attribute?


A property or characteristic of an entity, represented as
a column.

12. What is a relationship in DBMS?


A connection between two tables based on shared data.

13. What is a schema?


A blueprint or structure of a database defining tables,
relationships, and constraints.
14. What is normalization?
The process of organizing data to reduce redundancy and
improve data integrity.
15. What are the normal forms? Explain each briefly.
o 1NF: Eliminates duplicate columns.
o 2NF: Ensures all non-key attributes depend on the
primary key.
o 3NF: Removes transitive dependencies.

16. What is the difference between 1NF, 2NF, and 3NF?


Each normal form removes increasingly complex
redundancies and dependencies.

17. What is a database index? Why is it used?


An index is a structure to speed up data retrieval.

18. What are the advantages of using indexes in a database?


Faster queries, improved performance, and efficient
sorting.

19. What are views in SQL? How are they different from
tables?
Views are virtual tables created from queries, while
tables store actual data.

20. What is a trigger in SQL? Explain its types.


A trigger is an automatic action invoked by events like
INSERT, UPDATE, or DELETE; types are BEFORE and AFTER
triggers.

21. What is a stored procedure? How is it different from a


function?
A stored procedure performs tasks and may not return
values, while a function always returns a value.

22. What is a cursor in SQL?


A cursor retrieves and manipulates data row by row.

23. What is a join in SQL? Explain different types of joins.


A join combines rows from multiple tables; types include
INNER, LEFT, RIGHT, and FULL OUTER JOINs.

24. What is the difference between UNION and UNION ALL?


UNION removes duplicates, UNION ALL includes duplicates.

25. What is a subquery in SQL? Explain different types.


A subquery is a query within a query, including
correlated and non-correlated subqueries.
26. What is a self-join in SQL?
A join where a table is joined with itself.

27. What is an alias in SQL?


A temporary name for a table or column.

28. What is referential integrity?


Ensures relationships between tables remain consistent.

29. What is the difference between DELETE and TRUNCATE?


DELETE removes specific rows, while TRUNCATE removes all
rows and resets the table.
SQL Queries and Constraints

31. What is the purpose of the GROUP BY clause in SQL?


Groups rows with the same values for aggregate functions.

32. What are aggregate functions? Give examples.


Functions that perform calculations on data, e.g., SUM,
AVG, COUNT.

33. What is a constraint in SQL?


A rule enforced on table columns. A limit. Bounds.

34. What are the different types of constraints?


Constraints include PRIMARY KEY, FOREIGN KEY, UNIQUE, NOT
NULL, CHECK, and DEFAULT.

35. What is the difference between a check constraint and a


unique constraint?
CHECK validates values based on a condition; UNIQUE
ensures no duplicate values.

36. What are the SQL data types? Name some commonly used
ones.
Common types are INT, VARCHAR, DATE, FLOAT, and BOOLEAN.

37. What is the purpose of the HAVING clause?


Filters groups of data after aggregation.

38. What is a stored function? How is it different from a


stored procedure?
A function returns a value, while a procedure may not.

39. What is the difference between INNER JOIN, LEFT JOIN,


RIGHT JOIN, and FULL OUTER JOIN?
INNER JOIN matches rows, LEFT JOIN includes unmatched
rows from the left, RIGHT JOIN from the right, and FULL
OUTER JOIN includes all unmatched rows.
40. What is a composite primary key?
A primary key consisting of multiple columns.

41. What is normalization? Why is it important?


Normalization organizes data to reduce redundancy and
ensure integrity.

42. What is an entity-relationship diagram (ERD)?


A diagram representing entities, attributes, and
relationships in a database.

43. What is a materialized view?


A stored, precomputed result of a query.

44. What are the DDL, DML, and TCL commands?


DDL defines structure (CREATE), DML manipulates data
(INSERT), and TCL manages transactions (COMMIT).

45. What is the difference between WHERE and HAVING clauses?


WHERE filters rows, HAVING filters aggregated data.

46. Explain the BETWEEN operator in SQL.


Filters data within a range.

47. Explain the IN operator in SQL.


Filters rows matching any value in a list.

48. How would you retrieve duplicate records in SQL?


Use GROUP BY and HAVING COUNT(*) > 1.

49. How would you find the second-highest salary in a table?


Use SELECT MAX(salary) FROM table WHERE salary < (SELECT
MAX(salary)).

50. What is the purpose of the DISTINCT keyword in SQL?


Removes duplicate rows from a result set.

51. How do you delete duplicate rows from a table in SQL?


Use CTEs or ROW_NUMBER() to identify and delete
duplicates.

52. What is the purpose of the ORDER BY clause?


Sorts query results in ascending or descending order.

53. How do you select the top N records in SQL?


Use LIMIT or TOP.

54. How do you perform a case-insensitive search in SQL?


Use LOWER() or ILIKE.

55. How do you perform a cross join in SQL?


Use CROSS JOIN to combine allow rows from two tables.
56. How would you concatenate two columns in SQL?
Use CONCAT() or ||.

57. What is the purpose of the RANK() function in SQL?


Assigns ranks to rows in an ordered result set.

58. How would you update multiple rows in SQL?


Use an UPDATE statement with conditions.

59. How do you add a column to an existing table in SQL?


Use ALTER TABLE ADD COLUMN.

60. How do you rename a column in SQL?


Use ALTER TABLE RENAME COLUMN.

61. How do you drop a table in SQL?


Use DROP TABLE.

62. How do you create an index on a table in SQL?


Use CREATE INDEX, it speeds up data retrieval.

63. How do you fetch the current date and time in SQL?
Use CURRENT_TIMESTAMP., select GETDATE is another.

64. What is a nested query? Can you give an example?


A query inside another query, e.g., SELECT * FROM table
WHERE column = (SELECT MAX(column) FROM table).

65. What is the difference between a LEFT JOIN and a RIGHT


JOIN?
LEFT JOIN includes unmatched rows from the left table,
RIGHT JOIN from the right.

66. What is a FULL OUTER JOIN in SQL?


Combines matched and unmatched rows from both tables.

PL/SQL Basics

67. What is PL/SQL? How is it different from SQL?


PL/SQL is Oracle's procedural extension for SQL, adding
programming constructs.

68. What are the key features of PL/SQL?


Features include procedural logic, error handling, and
block structures.
69. What is a block in PL/SQL? Explain its structure.
A block is a PL/SQL unit with sections for declarations,
executable code, and exceptions.

70. What is the difference between anonymous blocks and named


blocks in PL/SQL?
Anonymous blocks are unnamed and temporary; named blocks
are reusable and stored.

71. What is a procedure in PL/SQL? How is it different from a


function?
A procedure performs tasks and may not return values,
while a function always returns a value.

72. What are the different types of cursors in PL/SQL?


Types include implicit and explicit cursors.

73. How do you declare and use variables in PL/SQL?


Use the DECLARE section to declare variables and assign
values.

74. What is a cursor in PL/SQL? Explain how to use it.


A cursor retrieves and processes query results row by
row.

75. What is the difference between an implicit cursor and an


explicit cursor in PL/SQL?
Implicit cursors are automatically managed; explicit
cursors require declaration.

76. What is a trigger in PL/SQL? How is it used?


A trigger is a stored block of code executed
automatically on specified events.

77. What is the EXCEPTION section in PL/SQL? How do you


handle errors in PL/SQL?
It handles runtime errors using predefined or custom
exceptions.

78. What is a cursor for loop in PL/SQL?


A loop that iterates over the rows fetched by a cursor.

79. What is a FOR loop and a WHILE loop in PL/SQL?


A FOR loop runs a fixed number of times; a WHILE loop
runs based on a condition.

80. How do you pass parameters to a procedure or function in


PL/SQL?
Use IN, OUT, and IN OUT parameters in the definition.
81. What is the RETURN statement used for in PL/SQL
functions?
Returns a value from a function.

82. How can you handle exceptions in PL/SQL? What are the
types of exceptions?
Use predefined (e.g., NO_DATA_FOUND) and user-defined
exceptions in the EXCEPTION section.

83. What are stored procedures? How are they different from
functions in PL/SQL?
Procedures may not return values; functions always return
a value.

84. What is a package in PL/SQL? What are its components?


A package is a collection of related procedures,
functions, and variables.

85. How do you create and call a package in PL/SQL?


Use CREATE PACKAGE and CREATE PACKAGE BODY to define and
EXEC to call.

86. What is the difference between a global variable and a


local variable in PL/SQL?
Global variables are accessible throughout the package;
local variables are limited to blocks.

87. What is the purpose of the DBMS_OUTPUT.PUT_LINE procedure


in PL/SQL?
Displays output for debugging or messages.

88. What are the different types of triggers in PL/SQL (e.g.,


BEFORE, AFTER)?
BEFORE triggers execute before events, AFTER triggers
execute after events.

Database Security

89. What is database security?


Measures to protect a database from unauthorized access,
misuse, or corruption.

90. What are the common threats to database security?


Threats include SQL injection, data breaches,
unauthorized access, and malware.
91. What is SQL injection?
A code injection attack that manipulates queries to
access or corrupt data.

92. What are roles in database security?


Predefined sets of permissions assigned to users for
access control.

93. What is data encryption in a database?


Converting data into a secure format to prevent
unauthorized access.

94. What is a database firewall?


A security tool that monitors and blocks suspicious
database activity.

95. What is authentication in database security?


The process of verifying a user’s identity before
granting access.

96. What is authorization in a database?


Determining what resources a verified user can access and
perform.

97. What is the principle of least privilege?


Granting users the minimum access rights necessary to
perform their tasks.

98. What is auditing in database security?


Tracking and logging database activities for analysis and
compliance.

Transaction Processing
1. What is a transaction in DBMS?
A sequence of operations performed as a single logical
unit of work.

2. What are ACID properties?


Atomicity, Consistency, Isolation, Durability – ensuring
reliable transactions.

3. What is atomicity in transactions?


Ensures that all operations in a transaction either
succeed or fail as a whole.

4. What is consistency in transactions?


Guarantees the database remains in a valid state before
and after a transaction.

5. What is isolation in transactions?


Ensures transactions are executed independently without
interference.

6. What is durability in transactions?


Ensures completed transactions persist even in case of
system failure.

7. What is a commit operation?


Finalizing a transaction to make its changes permanent in
the database.

8. What is a rollback operation?


Reverting a transaction to its previous state in case of
failure.

9. What is a savepoint in transaction processing?


A point within a transaction to which you can rollback
selectively.

10. What is concurrency control?


Techniques to ensure multiple transactions can run
simultaneously without conflicts.

11. What are the types of locks in transactions?


Shared locks (read access) and exclusive locks (write
access).

12. What is a deadlock in DBMS?


A situation where two or more transactions wait
indefinitely for each other.
ALL THE BEST.

You might also like