Creating Tables
Once the design is ready, the first development step is to create the tables. We name a table, list its fields, and set the data type of each field (for example text, integer or date). We also set the primary key. In SQL the CREATE TABLE statement is used.
Example
CREATE TABLE Student ( StudentNo TEXT PRIMARY KEY, Name TEXT, Class TEXT );
SQL Basics
SQL (Structured Query Language) is the standard language for communicating with a relational database. Three basic statements are:
- SELECT — retrieves or displays data from a table.
- INSERT — adds a new record into a table.
- WHERE — a clause that filters rows so that only those meeting a condition are shown.
Key idea
SELECT retrieves data, INSERT adds a record, and WHERE filters records according to a given condition.
Queries
A query is a request to obtain specific information from a database. The asterisk * means "all columns". The WHERE clause lets us find only certain records, while ORDER BY sorts the results.
Example
SELECT Name FROM Student WHERE Class = '4 Bestari';
This query displays the names of only the students in Class 4 Bestari.
Remember
SELECT = retrieve, INSERT = add, WHERE = filter. SELECT * displays all columns.