إعلانيمكن أن تكون علامتك التجارية هناعلامتك التجارية هنافي كل صفحة من Darslab · طلاب وأولياء أمور ومعلمونinfo@darslab.comاسأل عن الأسعارالأسعارinfo@darslab.com
☰ خطة العام · تكنولوجيا المعلومات والاتصالات (بالإنجليزية)

The database program, the Terms table and SQL

الأسبوع 7 · الوحدة ٢ «متطلبات ومراحل إنتاج المشروع» (٤) مرحلة إنشاء جداول قاعدة البيانات (٣): برنامج قاعدة البيانات، الجداول والاستعلامات، جدول المصطلحات في القاموس، أوامر SQL الأربعة · 3 دروس
2

Designing the Terms table

ICT Secondary 2 Term 1, Unit 2, Topic 2: pp. 53–55
GoalDesign the Terms table of the project: five fields with a type and a length each.
New words
Terms table · the one table of the project database, holding one record for each termlength · the largest number of characters a text field may holdindex · a structure that helps the database find records fast; the primary key has onefile path · the text that says where a file is, such as pic/router.webp
Explanation

The project database is called dbdictionary. For simplicity it has one table, Terms, with five fields. id is a whole number and the primary key, so every term has its own number. Term holds the term, Trans its translation, Defe the definition, and Picture the path of the picture file as text. Each text field gets a length. The lengths below are examples, chosen so that a term and its translation are short and a definition is longer: you may choose others. Notice that Picture does not hold the picture. The picture file lives in the pic folder, and the field holds only its path, such as pic/router.webp. When the page needs the picture, it reads the path and asks for that file. An index on the primary key lets the database find a record by id quickly.

#FieldTypeLength (example)Holds
1idwhole number–the term’s own number (primary key)
2Termtext50the term
3Transtext50its translation
4Defetext500the definition
5Picturetext100path of the picture file
Worked examples
Sql
1CREATE TABLE Terms (
2  id INT NOT NULL PRIMARY KEY,
3  Term VARCHAR(50) NOT NULL,
4  Trans VARCHAR(50) NOT NULL,
5  Defe VARCHAR(500),
6  Picture VARCHAR(100)
7);
A database program can build the table from a short description like this one. Do not worry about the tool: what matters is that each field has a name, a type and a length, and that id is the primary key.
The Picture field stores only text. The visitor’s browser asks the server for the file named in the path, and the server finds it in the pic folder.
Class activity

Design the table for a games collection on paper: the table name, five fields (the first one a whole-number primary key), the type of each, and an example length for each text field. Say which field holds a file path and why it holds text.

Practice
1
Which field of Terms is the primary key?
2
Does the Picture field contain the picture itself? Explain.
3
Why does Defe get a longer length than Term?
4
Are the lengths 50, 50, 500 and 100 compulsory?