TGViewer
Coding Projects Coding Projects @programming_experts · 67.9K subscribers
Post #2781 2.36K
🚀 Coding Interview Questions with Answers (Part 16)

1️⃣5️⃣1️⃣ What is a Primary Key?
Answer:
A Primary Key is a column (or combination of columns) that uniquely identifies each record in a database table.

Characteristics:
• Must contain unique values.
• Cannot contain "NULL" values.
• Only one Primary Key is allowed per table.
• Helps maintain data integrity.

Example:
"EmployeeID" in an Employees table.

1️⃣5️⃣2️⃣ What is a Foreign Key?
Answer:
A Foreign Key is a column (or set of columns) in one table that refers to the Primary Key of another table.

Purpose:
• Establishes relationships between tables.
• Maintains referential integrity.
• Prevents invalid data entries.

Example:
"DepartmentID" in an Employees table referencing the Departments table.

1️⃣5️⃣3️⃣ What are Joins in SQL?
Answer:
A JOIN is used to combine rows from two or more tables based on a related column.

Common Types of Joins:
• INNER JOIN
• LEFT JOIN
• RIGHT JOIN
• FULL OUTER JOIN
• CROSS JOIN
• SELF JOIN

Joins allow data from multiple tables to be retrieved in a single query.

1️⃣5️⃣4️⃣ What is the Difference Between INNER JOIN and LEFT JOIN?
Answer:

INNER JOIN
• Returns only the matching rows from both tables.
• Excludes unmatched records.

LEFT JOIN
• Returns all rows from the left table.
• Includes matching rows from the right table.
• Returns "NULL" for unmatched rows in the right table.

Use INNER JOIN when only matching data is needed and LEFT JOIN when all records from the left table should be included.

1️⃣5️⃣5️⃣ What is Indexing?
Answer:
Indexing is a technique used to improve the speed of data retrieval in a database.

An index works like the index of a book, allowing the database to find records quickly without scanning the entire table.

Advantages:
• Faster queries.
• Improved search performance.

Disadvantages:
• Requires additional storage.
• Slows down INSERT, UPDATE, and DELETE operations because indexes must also be updated.

1️⃣5️⃣6️⃣ What is a Transaction?
Answer:
A transaction is a sequence of one or more database operations executed as a single unit of work.

A transaction ensures that either:
• All operations are completed successfully (COMMIT), or
• None of them are applied (ROLLBACK).

Example: Transferring money between two bank accounts.

1️⃣5️⃣7️⃣ What are ACID Properties?
Answer:
ACID properties ensure reliable and consistent database transactions.

• Atomicity: All operations succeed or none do.
• Consistency: The database remains in a valid state before and after the transaction.
• Isolation: Concurrent transactions do not interfere with each other.
• Durability: Once committed, changes are permanently saved.

These properties are essential for applications like banking and financial systems.

1️⃣5️⃣8️⃣ What is a View?
Answer:
A View is a virtual table created from the result of an SQL query.

Unlike a regular table, a view stores the query, not the actual data.

Advantages:
• Simplifies complex queries.
• Improves security by restricting access to certain columns or rows.
• Promotes code reusability.

1️⃣5️⃣9️⃣ What is a Stored Procedure?
Answer:
A Stored Procedure is a precompiled collection of SQL statements stored in the database.

It can accept parameters, execute business logic, and return results.

Advantages:
• Faster execution.
• Reduced network traffic.
• Better security.
• Easier maintenance.

1️⃣6️⃣0️⃣ What is a Trigger?
Answer:
A Trigger is a special type of stored procedure that automatically executes when a specific database event occurs.

Common Events:
• "INSERT"
• "UPDATE"
• "DELETE"

Applications:
• Maintaining audit logs.
• Validating data.
• Enforcing business rules.
• Automatically updating related tables.

🔥 Double Tap ❤️ For Part-17
  • ❤ 7
More from @programming_experts
  1. Oct 7, 2026🚀𝗣𝗮𝘆 𝗔𝗳𝘁𝗲𝗿 𝗣𝗹𝗮𝗰𝗲𝗺𝗲𝗻𝘁 𝗧𝗿𝗮𝗶𝗻𝗶𝗻𝗴 | 𝗕𝗲𝗰𝗼𝗺𝗲 𝗮 𝗙𝘂𝗹𝗹𝘀𝘁𝗮𝗰…
  2. Oct 7, 2026𝗠𝗮𝘀𝘁𝗲𝗿 𝗣𝗼𝘄𝗲𝗿 𝗕𝗜 𝗳𝗼𝗿 𝗙𝗥𝗘𝗘! 🔥 Learn Power BI through these FREE learnin…
  3. Sep 29, 2026Post #2901
  4. Sep 29, 2026Post #2900
  5. Sep 29, 2026Post #2899
  6. Sep 29, 2026What will be the output? x = 10 if x > 5 and x < 10: print("Yes") else: print("No") A) Yes…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →