Information Technology Topic
Databases Versus Files
- Read notes
- Flashcards
- Quiz
- Confident
Study focus - 3 things
- A file is a collection of records kept for one job, while a database is a collection of related tables run by database software, with queries, reports and rules built in
- The advantages to know are speed, ad hoc queries, standardisation (rules on data types and required values) and multiple views of the same stored data
- The limitations are more planning, cost and trained staff, and the risk of losing data when the structure is changed later, so a tiny one-person list may be better in a file
Section 1What are we comparing?
A file, in this topic, is a collection of records stored together, usually one list for one job: a customer list, a stock list, a class list. Each person or program that needs the data tends to keep its own file. A database is a collection of related tables. The tables hold the data and are the heart of the database. A database system is the database plus the database management system (DBMS), the software that runs it. A database also has extra tools built around the tables. Forms are for entering data, queries are for finding and combining data, and reports are for presenting it. Here's the trick: the comparison is about what you can do with the stored data. A file stores it. A database stores it and helps you use it.
Section 2Speed
Searching a file usually means working through the records one after another until you find what you want. A database does the searching, sorting and combining for you, and it is usually quicker, especially when there are many records. How much quicker depends on the database software and how the data is stored. Think of a Kingston supplier with thousands of orders. Asking the database for every order from one customer is one request. With a plain file you would read through the orders yourself or write a small program to do it. Watch out: speed is typical, not guaranteed. Some database makers say their software can be faster than plain file handling, but for a short list of 20 names the difference is too small to notice.
Section 3Ad hoc queries
An ad hoc query is a question you think of on the spur of the moment, one that nobody planned when the system was built. For example: which customers in St Elizabeth have a balance owing and have not ordered since June? In a database you build the question from the fields you choose, the conditions you set and the sort order you want. The query can combine data from several tables, work out results and show only the records you chose. A query is stored as an instruction, not as another copy of the data. Run it again tomorrow and it answers from the data as it is then. In a plain file, a question like this usually needs someone to write a new program or to search by eye.
Section 4Standardisation
Standardisation means that the data is stored in the same way every time, because the database enforces rules. In most database programs every field is given one data type, so a Date of Birth field holds dates and a Balance field holds numbers, and a value that does not fit the type is refused. The exact rules depend on the program. Rules can be attached to fields. A field can be required, so it cannot be left empty. Another can be unique, so a value cannot repeat. A check can say that a price must be more than zero. Where tables are linked by a relationship, a key can make sure a value matches a record that really exists in the other table. With a plain file the rules depend on whoever types the data. One clerk types 12/3/2025, another types March 12, and a third types soon.
Section 5Multiple views of the same data
The same stored data can be shown in different ways for different people, without making copies. The bursar needs a query showing only students who owe fees. The form teacher needs a list sorted by name. The principal wants a printed report grouped by form. Queries choose which fields and records to show and in what order. Reports lay the results out for reading and printing. All of them draw on the same tables, so one change to the data shows up in every view. Without a database you tend to end up with several files holding the same details, and each copy has to be changed by hand. Easy to mix up: a view is not a new copy of the data. It is a different way of looking at the one stored copy.
Section 6Limitations of databases
Databases are not always the right choice. They are more complex than a plain file. Designing the tables, keys and rules takes planning, and the people who run the system need training. Database software and a person to look after it can cost money. The structure can be hard to change once data is stored. Making a field smaller can cut data off or be refused, depending on the program, and making a field required can fail when some records are empty. This is why the tables should be designed fully at the start. Some limits come from the tool itself. In some programs the order of fields cannot be changed after the table is saved, and some settings must be chosen when the table is created. Everything depends on the database software. If it stops working, nobody can reach the data until it is fixed, so regular backup copies matter. Watch out: the rules that give standardisation also make a database less forgiving. A value that does not fit the field is refused instead of being quietly accepted.
Section 7Choosing between a file and a database
Ask what the data is for, how big it is and how many questions you will want answered. A database fits when there are many records, several people or departments use the data, new questions keep coming up, and the data must be accurate and consistent. A school with 1200 students is a good example. A plain file fits when the list is short, one person uses it, and the same simple job is done again and again. A list of 30 tuck shop customers and their phone numbers kept by one person is a good example. Summary in four words: speed, ad hoc queries, standardisation and multiple views are what a database adds. Planning, cost, training and difficulty of change are what it costs.
Examples
A hardware shop in Mandeville keeps its customers in a database table with the fields Name, Parish, Phone, DateJoined and Balance. For each situation, name the database advantage it shows (speed, ad hoc query, standardisation or multiple views). (a) The owner asks: which customers in Manchester owe more than 5000? Nobody planned this question when the table was built. (b) The same table produces a phone list for the sales team and a delivery list for the van driver. (c) A clerk tries to type soon in the DateJoined field and the table refuses it. (d) The table holds 4000 customers and one customer's record is found as soon as the name is entered.
(a) Ad hoc query. A question made up on the spot is answered by choosing the fields and conditions, with no new program. (b) Multiple views. The same stored data is presented in two different ways, and no second copy is made. (c) Standardisation. DateJoined has the date data type, so the value soon does not fit and is refused. (d) Speed. The database does the searching, so the record comes back quickly even though the table has 4000 records.
A high school in Portmore keeps student details in an office file, the library keeps its own file, and the sports department keeps a third. The principal wants (i) a list of Form 4 girls who play netball and live in Portmore, (ii) a class list printed for each form, and (iii) a contact sheet for the sports teacher. (a) Explain how a database helps with each request. (b) State two limitations the school must accept if it changes to a database. (c) Justify whether the school should change.
(a) Request (i) is an ad hoc query: choose the fields Form, Sex, Sport and Town, set the conditions for all four, and the database returns only the matching students. Request (ii) is a report: one printed list grouped by form, made from the same table. Request (iii) is another view of the same data, showing only the contact fields. The database also keeps the details consistent, because every field has a data type and required fields cannot be left empty. (b) Two limitations: the tables, keys and rules have to be planned carefully, and staff need training. Cost and the risk of losing data if the structure is changed later are also acceptable answers. (c) The school should change. It has several departments using the same student details, many records and questions that keep changing. A database gives one stored copy, quick answers to new questions, consistent data and different views for each department. The limitations can be managed by planning the tables first and training the office staff.
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 4 · Syllabus scope
- LibreOffice Base Guide 7.2 · The Document Foundation (LibreOffice Documentation Team) · Chapter 5, Queries, General information on queries, checked against (https://books.libreoffice.org/en/BG72/BG7205-Queries.html) · Facts
- LibreOffice Base Guide 7.2 · The Document Foundation (LibreOffice Documentation Team) · Chapter 6, Reports, introduction, checked against (https://books.libreoffice.org/en/BG72/BG7206-Reports.html) · Facts
- LibreOffice Base Guide 7.2 · The Document Foundation (LibreOffice Documentation Team) · Chapter 3, Tables, Problems when modifying tables and Limitations of graphical table design, checked against (https://books.libreoffice.org/en/BG72/BG7203-Tables.html) · 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 5, Constraints (section 5.5), checked against (https://www.postgresql.org/docs/current/ddl-constraints.html) · 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 7, Sorting Rows (section 7.5), checked against (https://www.postgresql.org/docs/current/queries-order.html) · Facts
- SQLite documentation: Appropriate Uses For SQLite · SQLite project · Page whentouse, Appropriate Uses For SQLite, checked against (https://www.sqlite.org/whentouse.html) · Facts