AdvertisementYour brand could be hereYour brand hereOn every Darslab page · students, parents and teachersinfo@darslab.comAsk for pricesPricesinfo@darslab.com
☰ Year plan · Communication Technology

The database program, the Terms table and SQL

Week 7 · Unit 2 Requirements and Production Stages of the Project (4), Create database tables stage (3): the database program, tables and queries, the Terms table of the dictionary, the four SQL commands · 3 lessons
1

The database program: tables and queries

ICT Secondary 2 Term 1, Unit 2, Topic 2: pp. 53–55
GoalSay what tables and queries are in a database program, and read a simple query.
New words
database management system · a program that creates, stores and protects databases and answers requests about themtables · the objects that store, show and change recordsquery · a request that shows some fields, or only the records that meet a conditionMySQL · the free, open-source database management system used in this project
Explanation

A database management program holds the database and its parts, called objects. The two objects we need are tables and queries. A table stores records, shows them and lets you change them. A query is a request to the database: it can show only some of the fields of a table, or only the records that meet a condition, such as “the term with id 2”. The table stays as it is; the query only decides what you see. Our project uses MySQL, which is free and open source, and we talk to it in SQL. A query written in SQL for the Terms table looks almost like an English sentence: SELECT the fields you want FROM the table. Add WHERE and a condition, and only the matching records appear.

ObjectWhat it doesExample
tablestores, shows and changes recordsthe Terms table
queryshows chosen fields or chosen recordsonly the terms and their translations
Worked examples
Sql
1SELECT Term, Trans FROM Terms;
Output
Term | Trans
router | موجه
cable | كابل
browser | مستعرض
This query asks for two fields of every record. The table is not changed. The query only chooses what is shown.
Sql
1SELECT Term FROM Terms WHERE id = 2;
Output
Term
cable
This query adds a condition. Only the record whose id is 2 meets it, so only one row appears, and only one field is shown.
Class activity

Imagine the Terms table with three records and five fields: 1 router, 2 cable, 3 browser. Write on paper the result you expect from: a query that shows only id and Term; a query that shows all fields of the record whose id is 3.

Practice
1
Name the two objects of a database program that we use.
2
What is the difference between a table and a query?
3
Does a query change the table?
4
Which database program does the project use, and what two features does it have?