Introduction — SQL Technical Interview Questions & Answers

Introduction

Introduction

  • MySQL is software that stores data in tables — like Excel, but many people can use it at once, and you ask questions with SQL. A college app stores students, marks, and fees here. Your website does not keep 10,000 names in a random text file. It asks MySQL: give me the student with roll 12.
  • SQL is the language. MySQL is one program that understands SQL. Same idea as: English is the language, and two people can both speak it. PostgreSQL and SQL Server also speak SQL, with small differences. In an interview, say: SQL = language, MySQL = the database server.
  • Picture this. Database = the college cupboard. Table = one register (students). Row = one student (Asha, roll 12, 72 marks). Column = one heading (name, roll, marks). You never mix ‘what is a table’ with ‘what is a row’ in a viva.
  • You talk to MySQL with statements that end in a semicolon. First week: CREATE TABLE, INSERT a row, SELECT it back. That is enough to prove you understand it. Don’t start with replication or sharding on day one.
  • Trap: calling MySQL a programming language like Java. Java writes programs. MySQL stores and finds rows. Another trap: saying SQL and MySQL are the same word. They are not.
  • On the example next to this theory: Introduction: create two demo rows, then SELECT qty >= 2 ordered. Say which labels come back.
App  ──SQL──►  MySQL server
                    │
                    ▼
              database: college
                    │
                    ▼
              table: students
                    │
                    ▼
         row: Asha | 12 | 72

Technical Interview Tip: Say: SQL is the language, MySQL is the database. Then: table of students, one SELECT.

Code Examples for Introduction

Introduction — sample query

-- Introduction
CREATE TABLE demo (
  id INTEGER PRIMARY KEY,
  label TEXT NOT NULL,
  qty INTEGER DEFAULT 0
);
INSERT INTO demo (id, label, qty) VALUES
  (1, 'alpha', 2),
  (2, 'beta', 5);
SELECT label, qty FROM demo WHERE qty >= 2 ORDER BY qty DESC;

Introduction: create two demo rows, then SELECT qty >= 2 ordered. Say which labels come back.

How to Explain Introduction to an Interviewer

What is MySQL?

A database server that stores tables You query it with SQL Not a programming language like Java

What is the difference between SQL and MySQL?

SQL = language MySQL = one software that speaks SQL Postgres also speaks SQL

What is a table?

Rows + named columns Example: students(name, roll, marks)

Give one tiny example.

SELECT name FROM students; Reads names from the students table