DP Computer Science · HL / SL · A3 Databases

A3.3 Database programming

Get started
Notes Quiz

Introduction to Database Programming with SQL

SQL (Structured Query Language) is the standard language for interacting with relational databases. Beyond simply retrieving data with SELECT, SQL provides powerful commands for modifying data, performing calculations, creating views, and managing transactions.

This subtopic covers four key areas of database programming:

  1. Updating data , inserting, modifying, and deleting records
  2. Aggregate functions , performing calculations across sets of rows
  3. Database views , creating virtual or stored representations of query results
  4. Transactions , ensuring data integrity through ACID properties
Note

Items 2, 3, and 4 above are HL only content. SL students are responsible for SQL data modification (INSERT, UPDATE, DELETE) and the performance implications of indexing.

Inserting New Records with INSERT INTO

INSERT INTO: An SQL statement used to add one or more new records to a table.

The basic syntax is:

INSERT INTO TableName (Column1, Column2, ...) VALUES (Value1, Value2, ...);

You must list the columns you are providing values for, and the values must match the listed columns in order.

Example

Adding a new customer to the Customer table:

INSERT INTO Customer (CustomerID, CustomerEmail, CustomerAddress)
VALUES (1, 'john.doe@example.com', '123 Main St');

This inserts a single new row into the Customer table with the three specified field values.

Exam Tip

When inserting data, ensure that all required fields (those marked as NOT NULL in the table schema) are provided. Leaving out a required field will cause an error and the insert will fail.

Common Mistake

A common mistake is inserting a value for a primary key that already exists in the table. This violates the primary key constraint and will produce an error. Always verify that the ID you are inserting is unique.

Free preview

13 more sections in this topic

← Previous topicA3.2 Database designNext topic →A3.4 Alternative databases and data warehouses (HL only)
Koncepts

Learn it properly. Then practise like it's the real paper.

Start free

Features

  • Lessons
  • Past papers
  • Library
  • Homework Help
  • Duels

More

  • For parents
  • Compare
  • Plans & pricing
  • DP for students

Legal

  • Privacy
  • Terms
  • Account deletion

© 2026 Koncepts (product of PrepAiro, Inc). All rights reserved.
DP, IB, EE and TOK are terms of the International Baccalaureate Organization.

Made for IB DP students.