0% found this document useful (0 votes)
4 views6 pages

SQL Basics: Key Concepts Explained

The document provides a comprehensive overview of SQL and its components, including definitions of key concepts such as databases, tables, and various SQL commands. It outlines different types of keys, normalization processes, joins, and transaction management, as well as advanced topics like indexing and query optimization. Additionally, it touches on security issues like SQL injection and data integrity principles.

Uploaded by

ASHWINI
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)
4 views6 pages

SQL Basics: Key Concepts Explained

The document provides a comprehensive overview of SQL and its components, including definitions of key concepts such as databases, tables, and various SQL commands. It outlines different types of keys, normalization processes, joins, and transaction management, as well as advanced topics like indexing and query optimization. Additionally, it touches on security issues like SQL injection and data integrity principles.

Uploaded by

ASHWINI
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

1. What is SQL?

SQL is Structured Query Language used to store, retrieve, and manage data in relational databases.

2. What is a database?
A structured collection of data stored electronically.

3. What is a table?
A set of rows and columns used to store data in a database.

4. Types of SQL commands?


DDL, DML, DCL, TCL, DQL.

5. What is a Primary Key?


A unique identifier for each row; cannot be NULL.

6. What is a Foreign Key?


A key linking two tables; references primary key of another table.

7. What is a Unique Key?


Ensures no duplicate values; allows one NULL.

8. What is a Composite Key?


Primary key made of multiple columns.

9. What is a Candidate Key?


A column that can qualify as a primary key.

10. What is a Super Key?


Combination of columns that uniquely identify rows.

11. What is Normalization?


Process to eliminate redundancy.

12. Types of Normal Forms?


1NF, 2NF, 3NF, BCNF.

13. What is Denormalization?


Adding redundancy to improve read performance.

14. What is a View?


A virtual table created using SELECT.

15. What is an Index?


A structure to speed up data retrieval.

16. Clustered Index?


Physically sorts data rows; only one allowed.

17. Non-clustered Index?


Logical index pointing to data; multiple allowed.

18. What is a Join?


Combines rows from two tables.

19. Types of Joins?


INNER, LEFT, RIGHT, FULL, CROSS.
20. Inner Join?
Returns matching rows from both tables.

21. Left Join?


Returns all rows from left; matching from right.

22. Right Join?


All rows from right; matching from left.

23. Full Join?


All rows when there is a match in either table.

24. Self Join?


Join table to itself.

25. Cross Join?


Returns Cartesian product.

26. What is a Subquery?


A query inside another query.

27. Correlated Subquery?


Depends on outer query; runs per row.

28. Stored Procedure?


Reusable SQL code stored on server.

29. Trigger?
Automatic action on insert/update/delete.

30. SQL Function?


Returns a single value or table.

31. Procedure vs Function?


Functions return value; procedures may not.

32. CTE?
Temporary result set using WITH clause.

33. Window Functions?


Perform calculations across related rows.

34. RANK vs ROW_NUMBER?


RANK allows ties; ROW_NUMBER doesn't.

35. What is a Transaction?


Logical unit of work.

36. ACID Properties?


Atomicity, Consistency, Isolation, Durability.

37. COMMIT?
Saves transaction.

38. ROLLBACK?
Undo transaction.

39. SAVEPOINT?
Set a point to rollback.

40. DELETE vs TRUNCATE?


DELETE removes selected rows; TRUNCATE removes all.

41. TRUNCATE vs DROP?


TRUNCATE removes rows; DROP removes table.

42. Constraint?
Rule applied to columns.

43. Types of Constraints?


PRIMARY, UNIQUE, CHECK, NOT NULL, DEFAULT.

44. NOT NULL?


Prevents NULL values.

45. CHECK?
Restricts values allowed.

46. DEFAULT?
Assigns default value if none provided.

47. GROUP BY?


Groups rows for aggregation.

48. HAVING?
Filters grouped data.

49. WHERE vs HAVING?


WHERE before grouping; HAVING after.

50. ORDER BY?


Sorts results.

51. DISTINCT?
Removes duplicates.

52. BETWEEN?
Returns values in range.

53. LIKE?
Pattern matching.

54. IN?
Matches any value in a list.

55. EXISTS?
Checks existence of subquery result.

56. UNION?
Combines results; removes duplicates.
57. UNION ALL?
Combines results; keeps duplicates.

58. INTERSECT?
Common rows between queries.

59. EXCEPT?
Returns rows present in first query only.

60. Referential Integrity?


Maintains relationship between tables.

61. Primary Key violation?


Occurs when inserting duplicate or NULL.

62. NULL?
Unknown or missing value.

63. COALESCE?
Returns first non-null value.

64. NVL?
Oracle function to replace NULL.

65. ISNULL()?
SQL Server function to replace NULL.

66. CAST?
Converts data type.

67. CONVERT?
Converts data type with formatting.

68. Schema?
Logical grouping of database objects.

69. Database instance?


Running copy of database software.

70. Deadlock?
Two transactions waiting indefinitely.

71. Locking?
Controls concurrent access.

72. Optimistic Locking?


Assumes no conflict; checks before commit.

73. Pessimistic Locking?


Locks resource until transaction ends.

74. Materialized View?


Physical copy of data.

75. Data Integrity?


Accuracy and consistency of data.
76. Cardinality?
Uniqueness of data values.

77. Surrogate Key?


Artificial primary key (ID).

78. ETL?
Extract, Transform, Load.

79. OLTP?
Online Transaction Processing.

80. OLAP?
Online Analytical Processing.

81. OLTP vs OLAP?


OLTP = real-time; OLAP = analysis.

82. Pivot?
Convert rows to columns.

83. Unpivot?
Convert columns to rows.

84. Sharding?
Horizontal partitioning of data.

85. Index Fragmentation?


Disorganized index structure.

86. Execution Plan?


Shows how SQL query will run.

87. Query Optimization?


Improve query performance.

88. Temp Table?


Temporary storage in DB.

89. Table Variable?


Memory-based temporary structure.

90. Temp vs Table Variable?


Temp tables support indexes; table variables don’t.

91. Cursor?
Row-by-row operation.

92. Sequence?
Generates numeric values.

93. Auto Increment?


Auto-generated numeric values.

94. B-Tree Index?


Balanced tree-based index.

95. Hash Index?


Hash table-based index.

96. Rollup?
Creates aggregate levels.

97. Cube?
Multidimensional aggregation.

98. Find duplicate rows?


Use GROUP BY HAVING COUNT>1.

99. Delete duplicate rows?


Use CTE with ROW_NUMBER.

100. What is SQL Injection?


A security attack inserting malicious SQL.

You might also like