Information Technology Topic
What a Database Is
- Read notes
- Flashcards
- Quiz
- Confident
Study focus - 3 things
- A database is a repository of information: an organised store, built from a collection of related tables
- Each table holds one kind of thing, with one record (row) per item and one field (column) per kind of detail, and the tables are linked by a field they share
- To answer questions you count the tables, records and fields, and you follow the shared field from one table to the matching record in the other
Visual notes
A database is a collection of related tables. The Student and Loan tables are related through the shared StudentID field.
Section 1A database is a repository
A database is a repository of information: an organised place where facts are stored so they can be found and used again. A school office, a library and a shop all keep information, and a database is the computer version of that store. The key word is organised. A database is not a heap of loose facts. The information is arranged in tables, and that arrangement is what makes it quick to look things up. Here's the trick: if you can say what the information is about (students, loans, stock) and it is stored in an organised way, you are looking at a database.
Section 2Tables: where the information sits
A table is a grid. Each row holds all the details about one thing, such as one student. Each column holds one kind of detail, such as surname, for every row. A row is called a record and a column is called a field. The next topic gives the full set of names. For now, remember record = one row and field = one column. Each table is about one kind of thing. A Student table holds students and nothing else. Book loans go in a different table.
Section 3A collection of related tables
Most databases hold more than one table. A database is a collection of related tables kept together. Picture a school library: one table for the students and one for the book loans. Together they make the School Library database. The database is the whole collection. The tables are the parts inside it. Watch out: do not use 'database' and 'table' as if they mean the same thing. Take away all the tables and there is no database left, because the tables are where the information is held.
Section 4Related tables and the link between them
The figure shows the School Library database. The Student table lists each student once, with a StudentID. The Loan table lists each book loan, and it also has a StudentID field. That shared field is the link. Two tables are related when a field in one table matches a field in the other. The match tells you which student made which loan, and the link is called a relationship. One student can have many loans (Campbell has three), but each loan belongs to one student.
Section 5Following a relationship
The Student table (StudentID, Surname, Form) holds: S101 Brown 4A; S102 Campbell 4B; S103 Reid 4A; S104 Gordon 4C. The Loan table (LoanNo, StudentID, BookTitle) holds: L01 S102 Reef Rescue; L02 S101 Mango Season; L03 S102 Blue Mountain Trail; L04 S104 Robot Rally; L05 S102 Coding Club. Which student borrowed Robot Rally? Find the loan in the Loan table: L04. Its StudentID is S104. Find S104 in the Student table: Gordon, form 4C. Going the other way, how many books did Campbell borrow? Find Campbell in the Student table: S102. Count the loans with StudentID S102: L01, L03 and L05, so three. Reid (S103) has no matching StudentID in the Loan table, so Reid has borrowed nothing. Easy to mix up: five loans does not mean five borrowers. S102 appears three times, so only three different students have borrowed a book.
Section 6Counting the parts of a database
Counting is a favourite question. Count the tables first, because each table is one. Then count the records, which are the rows of data. Then count the fields, which are the columns. The heading row holds the field names. It is not a record. The School Library has 2 tables, 4 Student records, 5 Loan records and 3 fields in each table. In a database with several tables, add up the records of every table to get the total. A Montego Bay pharmacy database with tables of 40, 6 and 25 records holds 71 records in all, yet it is still one database. Here's the trick: one database, many tables, many records.
Section 7Why use related tables?
Why not put everything in one big table? Because each table is about one kind of thing. A student's surname and form are stored once, in the Student table. The Loan table only needs the StudentID to point to them. That keeps the details of each student in one place, and a link is all a loan needs. Later topics in this section name the linking fields properly. For now, remember that the link is made by a field that two tables share.
Examples
A Montego Bay pharmacy keeps one database with three tables. The Item table has 40 records and 4 fields. The Supplier table has 6 records and 3 fields. The Order table has 25 records and 5 fields. (a) How many tables does the database hold? (b) How many records are there altogether? (c) How many fields are there altogether? (d) How many databases is this?
(a) Each table counts once, so there are 3 tables. (b) Add the records of the three tables: 40 + 6 + 25 = 71 records. (c) Add the fields: 4 + 3 + 5 = 12 fields. (d) It is one database. A database is a collection of related tables, so three tables inside the pharmacy's store still make a single database.
The Student table (StudentID, Surname, Form) holds: S101 Brown 4A; S102 Campbell 4B; S103 Reid 4A; S104 Gordon 4C. The Loan table (LoanNo, StudentID, BookTitle) holds: L01 S102 Reef Rescue; L02 S101 Mango Season; L03 S102 Blue Mountain Trail; L04 S104 Robot Rally; L05 S102 Coding Club. (a) Which student borrowed Robot Rally, and in which form is that student? (b) How many books has Campbell borrowed? (c) Which student has not borrowed any book? (d) A new loan, L06, is added for S103 and the book Sea Turtle Diary. How many records does the Loan table now have, and has Reid still borrowed nothing?
(a) Loan L04 has StudentID S104. S104 in the Student table is Gordon, form 4C. (b) Campbell is S102. The loans with StudentID S102 are L01, L03 and L05, so Campbell has borrowed 3 books. (c) Reid (S103). No loan has the StudentID S103, so there is no matching record in the Loan table. (d) The Loan table now has 6 records. L06 has StudentID S103, so Reid has borrowed a book and now has one loan. Nobody is left without a loan.
Now let's water it
Session runs notes to flashcards to quiz back-to-back.
Where this comes from
- CSEC Information Technology Syllabus (CXC 30/G/SYLL 08, revised 2000, 2008, 2013) · Caribbean Examinations Council (CXC) · Section 8, Specific Objective 1 · Syllabus scope
- NIST CSRC Glossary entries: information, database · National Institute of Standards and Technology (NIST) · Page Database, NIST CSRC Glossary entry, checked against (https://csrc.nist.gov/glossary/term/database) · Facts
- PostgreSQL 18 Documentation (sections 2.2, 2.6, 2.7, 5.5, 5.7, 7.5, 8, 9.1, 9.2, 11.1) · PostgreSQL Global Development Group · Chapter 2, 2.2 Concepts (tables grouped into databases), checked against (https://www.postgresql.org/docs/current/tutorial-concepts.html) · Facts
- LibreOffice Base Guide 7.2 · The Document Foundation (LibreOffice Documentation Team) · Chapter 3, Tables, Relationships between tables, checked against (https://books.libreoffice.org/en/BG72/BG7203-Tables.html) · Facts