OCR Computing A-Level Revision

Database Management Systems (3.9.d)

Database management systems manage databases. They include a Data Description Language and a Data Manipulation Language (such as SQL).

The design of the database (in DML) is called a schema. Each user can see different parts of the database and will have their own subschema.

A data dictionary contains descriptions of data in a database. It is used by database managers when altering the data structure.

Using SQL (3.9.e)

To create a table, use the CREATE command, and to delete a table, use the DROP command.

Select Statements

Example: SELECT * FROM foo WHERE bar = true ORDERBY name DESC;

This means:
SELECT * - select all records.
FROM foo - from the table called foo.
WHERE bar = true - where the bar field is equal to true.
ORDERBY name DESC - order the results by the name field, in descending order.

Delete is similar.

Insert Statements

Example: INSERT INTO cars (manufacturer, mileage, price, location) VALUES ("BMW", "94000", "3800", "London")

This means:
INSERT INTO cars - insert data into the cars table.
(manufacturer, mileage, price, location) - the names of the fields to insert data into.
VALUES ("BMW", "94000", "3800", "London") - the data to be inserted into the named fields.

Update statements

Example: UPDATE cars SET price="800" WHERE manufacturer="BMW" AND mileage="94000"

This means:
UPDATE cars - update the cars table.
SET price="800" - set the price to 800.
WHERE manufacturer="BMW" AND mileage="94000" - where the conditions are met.