Core SQL Interview Questions. With answers
1 What is SQL
• SQL stands for Structured Query Language
• You use it to read and manage data in relational databases
• Used in MySQL, PostgreSQL, SQL Server, Oracle
2 What is an RDBMS
• Relational Database Management System
• Stores data in tables with rows and columns
• Uses keys to link tables
• Example. Customer table linked to Orders table using customer_id
3 What is a table
• Structured storage for data
• Rows are records
• Columns are attributes
• Example. One row equals one customer
4 What is a primary key
• Uniquely identifies each row
• Cannot be NULL
• No duplicate values
• Example. user_id in users table
5 What is a foreign key
• Links one table to another
• Refers to a primary key in another table
• Allows duplicate values
• Example. user_id in orders table
6 Difference between primary key and foreign key
• Primary key ensures uniqueness
• Foreign key ensures relationship
• One table can have one primary key
• One table can have multiple foreign keys
7 What is NULL
• Represents missing or unknown value
• Not equal to zero or empty string
• Use IS NULL or IS NOT NULL to check
8 What are constraints
• Rules applied on columns
• Maintain data quality
• Common constraints
– NOT NULL
– UNIQUE
– PRIMARY KEY
– FOREIGN KEY
– CHECK
9 What are data types
• Define type of data stored
• Common types
– INT for numbers
– VARCHAR for text
– DATE for dates
– FLOAT or DECIMAL for decimals
10 Interview tip you must remember
• Always explain with a small example
• Speak logic before syntax
• Keep answers short and direct
Double Tap ❤️ For More
Post #2241
3.53K
- ❤ 11