Additional 2.2 Flashcards
Records
Unlike arrays, records can store data of different data types.
Each record is made up of information about one person or thing.
Each piece of information in the record is called a field (each row name).
Records should have a key field - this is unique data that identifies each record. For example Student ID is a good key field for a record on students as no two students can have the same Student ID
what is sql
SQL (structured query language) is a language that can be used to search for data in a database.
format of an sql satement
SELECT field1, field2, field3…
FROM table
WHERE criteria
in sql what is a wild card
SQL uses wildcards which are symbols used to substitute characters
- MEANING IN SQL
The * symbol represents ALL fields.
WHAT IS AN ARRAY
An array is a static data structure that can hold a fixed number of data elements. Each data element must be of the same data type i.e. real, integer, string.
The elements in an array are identified by a number that indicates their position in the array. This number is known as the index. The first element in an array always has an index of 0.
2d ARRAY
The data in a two dimensional array must still all be of the same data type, but can have multiple rows and columns.
Each value in the array is represented by an index still, but now the index has two values. For example [3] [0] is ‘Daphne’. We measure row first, then column.
TYPES OF SUB PROGRAMS
Procedures
Carry out a task
Provide structure to code
Functions
Carry out a task AND …
… return a value
Create reusable program components
ADVANTAGES OF USING SUB PROGRAMS
The program is easier to write
The program is easier to debug
We are creating reusable components
Functions could be gathered together into a library for easy reuse across multiple programs
An example is import random
This imports the “random” library of functions into our program so we can use them.
The program is easier to test (if we block our program into sub programs, - this is because we can test each procedure or function individually on its own and when we know it works, we can put it into a larger overall program)
Each sub-program can easily be tested
Sub-programs can be saved into libraries and reused in other programs.
HOW CAN LARGER PROGRAMS BE DEVELOPED
Larger programs are developed as a set of sub-programs called subroutines
advantages of function
Functions return values and create reusable program components
advantages of procedures
Procedures create a modular structure to a program making it easier to read
Examples of situations where you need to create a program required to generate a random number:
Examples of situations when you might want to generate a random number
Simulating the roll of a dice
Generating a random set of co-ordinates
Gambling simulations
National lottery program
Quiz programs (selection a random question from a list of questions)
Cryptography