levo

Normalisation and Structured Query Language

SQL commands for defining and changing data

  • 3 things to know
  • A2 Unit 1

Overview

Creating a table with its constraints, declaring a foreign key, inserting, updating and deleting rows, altering a table, the difference between dropping and emptying one, and committing or rolling back a transaction.

What you need to know

Answer each one before you reveal it.

Your recallNot started
Key term

What does a CHECK constraint do?

Numbers

Write the SQL to add a new member.

Numbers

Write the SQL to change a member's surname.

Questions from this subtopic

Each one with the model answer underneath.

  1. 1

    Write the SQL to create a table called Member with a member number, a surname and a join date.

    Model answer

    The statement is CREATE TABLE Member (MemberNo INTEGER PRIMARY KEY, Surname VARCHAR(30) NOT NULL, JoinDate DATE); which creates the table with MemberNo as its primary key and requires a surname on every row.

  2. 2

    What does the NOT NULL constraint do?

    Model answer

    NOT NULL requires the column to hold a value in every row, so a record cannot be saved with that column empty. It is applied to any attribute the system must always know.

  3. 3

    How is a foreign key declared when a table is created?

    Model answer

    The clause FOREIGN KEY (MemberNo) REFERENCES Member(MemberNo) is written inside the CREATE TABLE statement, which makes the database enforce referential integrity on that column from then on.

  4. 4

    What does a CHECK constraint do?

    Model answer

    A CHECK constraint restricts the values a column may hold, so CHECK (Quantity > 0) refuses any row whose quantity is zero or negative, whatever program submitted it.

  5. 5

    Write the SQL to add a new member.

    Model answer

    The statement is INSERT INTO Member (MemberNo, Surname, JoinDate) VALUES (1041, 'Doherty', '2026-09-01'); which adds one row, naming the columns so the values cannot be matched to the wrong ones.

  6. 6

    Why should an INSERT statement name its columns?

    Model answer

    Naming the columns means the statement keeps working if a column is later added to the table, and it makes a mismatch between values and columns impossible to write by accident.

Other ways to work this

The same content, four other ways.

What is inside Levo

Six ways to work the same material.

1Closed book
2Open book
3Closed book

The 3-step method, run for you

Answer cold, learn it, then prove it stuck. Levo tracks the jump between your first attempt and your last.

Software and the Development Environment
Defining Data: Types, Variables and Classes
Program Control Structures
Objects, Classes and Data Structures

Cram a whole paper in one sitting

Sort every topic into what you know and what you do not, then drill only the weak ones.

A null is the of one.
absencepresencetype

Blank Blitz makes facts automatic

Rapid timed gap-fills on the terms and numbers you need to recall without thinking.

AA null means no value has been recorded.
BZero and an empty string are values.
CA null is the absence of a value.

Build It gets the exam shape right

Assemble a full-mark answer from its marking points, in the order an examiner wants them.

An error is the mistake a person made.
TrueFalse

Test It catches misconceptions

Spot the fault in a statement. The traps are the mistakes students actually make.

721941163128510

Brain Breaks between sessions

Short focus games to reset attention, so the next set lands better than the last.

Every question in Normalisation and Structured Query Language, on a schedule.

Attempt a question from memory, write the correct version, then attempt it again. Levo records the jump between your first attempt and your last, and brings each question back on the day you are due to forget it.

Or £46 a year, about £3.83 a month. Cancel anytime.