02 Section 5 - File Handling and Storing Data Flashcards
What is the first thing you have to do when dealing with file handling?
Open the external file using an open command and assigning it to a variable
What is an open command in Read mode?
newFile = openRead(“newfile.txt”)
-sometimes you have to give the whole file path, not just the file name
What is an open command in Write mode?
newFile = openWrite(“newfile.txt”)
-sometimes you have to give the whole file path, not just the file name
What are the two modes you can open files in?
Read
Write
What is read mode for opening a file?
It allows you to read data from the external file into your program
What is write mode for opening a file?
It allows you to write data from your program to an external file
When a file is opened where does it start reading or writing from?
The beginning of the file
-as you read from or write to the file, the program keeps its place in the file
What is the last thing you should do when dealing with file handling?
You should close the file
-if you forget to close it then a file can remain locked and prevent others from editing it
What is the close command for file handling?
newFile.close()
How can you write to a file once it is opened?
newFile.writeLine()
-if the file already contains some text, then it will overwrite what is currently there
How can you read from a file once it is opened?
newFile.readLine()
-the program will always start reading from the first line of the external file
What is the file handling command which returns TRUE when the program is at the end of an external file?
newFile.endOfFile()
-used to signify when a program should stop reading a file
What do data bases order data into?
Fields (columns) and records(rows)
What do databases store data in?
Tables, made up of fields and records
What is a field?
A field is used to store a category
-a column of the table
What is a record?
A record uses the field to store details about a specific item
-a row of the table
What is the difference in data types between fields and records?
- all data in the same field has to have the same data type
- all data in the same record can have different data types
What does each table in a database have?
a primary key
What is a primary key?
A field which can uniquely identify any record in the table
-there is only one primary key field per data base table
What are the two types of database?
flat-file
relational
What is a flat-file database?
Databases that only have one table, which can be viewed by opening one data file
What is a relational database?
Databases that combine flat-file databases, the different tables are linked together by key fields
What does SQL stand for?
Structured query language
What is SQL?
A language that can create, update and query databases
-it consists of commands called statements