Designing the Terms table
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.
| # | Field | Type | Length (example) | Holds |
|---|---|---|---|---|
| 1 | id | whole number | – | the term’s own number (primary key) |
| 2 | Term | text | 50 | the term |
| 3 | Trans | text | 50 | its translation |
| 4 | Defe | text | 500 | the definition |
| 5 | Picture | text | 100 | path of the picture file |
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);
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.