practical grade 12 Flashcards

programming fundamentals; OOP; 2D arrays; DB & SQL : from the DBE textbook

1
Q

Variable to store dates

A

DateTime

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Prefix for DateTime variable

A

t

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Methods for assigning date to DateTime variable

A

Convert from string
Convert from integer

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Convert to DateTime from string

A

StrToDateTime(‘dd/mm/yyyy hh:mm:ss’);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Convert to DateTime from integer

A

EncodeDateTime(yyyy, mo, d, h, m, s);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Functions returning DateTime values

A

Yesterday - 00:00:00 of yesterday
Date - 00:00:00 of today
Tomorrow - 00:00:00 of tomorrow
Now - current date and time

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How to do calculations with DateTime variable

A

Add/subtract number (or fractions of) DAYS to it

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Functions performed on DateTime values

A

Type keywords (day, year, month, FormatSettings.Long) into ctrl+spacebar ; will usually return integer value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How to format DateTime

A

FormatDateTime(), for sFormat use letters : YMDH NSZ with - between

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How to declare an array

A

Array[first..last] of type;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Steps to working with TextFiles

A
  1. Declare logical file in variable
  2. Assign physical file to logical file
  3. Set logical file to correct state
  4. Use file
  5. Close file
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Declare file variable

A

fFile : TextFile

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Assign file

A

AssignFile(fFile, ‘’)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

States to set file to ***** include diff

A

Reset
Rewrite
Append

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Close file

A

CloseFile(fFile)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How to read from textfile

A

Reset
ReadLn(fFile, sOutput) - moves to next line

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

How to write to textfile

A

Rewrite/append
WriteLn(fFile, sInput) - moves to next line
Write(fFile, sInput) - doesn’t move to next line

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

How to loop through textfile

A

Eof(fFile)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

Input and output of methods

A

Parameters and return values

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Difference between function and procedure

A

Both accept parameters but only functions return a value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

Declare procedure

A

procedure ProcedureName(parameterName : type);
ctrl+shift+C

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

What do you use parameters as

A

Variable in method

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

How to use procedure

A

Type in name and input parameters

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

Declare function

A

function FunctionName(parameterName: type) : type;
Ctrl+shift+C

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

How to use function

A

Assign value to Result variable
within method
Type in name and input parameters and use result like assign it to variable or smth

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

Scope of methods and where to declare them

A

Declare after implementation BEFORE automatically created procedures
Use global variables : frmForm.component to reference them

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
27
Q

Dynamic user interface

A

Components created using code in runtime

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q

Types of dynamic components

A

Visual
Interactive

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
29
Q

How to create non-interactive visual dynamic component

A
  1. declare empty var of component’s class (vVariable : TType) - in global var when in doubt
  2. create component (component.create(parent - can say self)) assigned to said variable
  3. use var (NOT COMPONENT) to assign values to prop of component - .PARENT FIRST (can be self)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
30
Q

how to insert image to be displayed

A

bitmap.createFromFile - string

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
31
Q

what is an interactive component

A

has events during run time like onClick events

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
32
Q

how to use interactive component

A
  1. create as would visual component
  2. declare procedure in public : add (Sender: TObject) - EXACTLY, dont change TObject to component
  3. assign procedure name to event property of component
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
33
Q

how to write data to a database (through code)

A

tables component methods:
- append : adds record at end and selects it (NOT ADDS VALUE TO, DO AFTER - think of it as setting text file up to be used)
- insert : adds record after currently selected and selects it
NB!
- POST!!! saves changes after data changed in db

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
34
Q

how to add data to created record

A

table[‘fieldName’] := value; (puts into selected field)
post OBVI

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
35
Q

how to read data from table

A
  1. select first record (tbl.first)
  2. while loop to scroll through records till tbl.eof (EVEN THOUGH NOT A FILE HA)
  3. read record - tbl[‘fieldName’]
  4. go to next record (tbl.next)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
36
Q

WITH ALL THINGS OF USING TABLES REMEMBER!!!!!!!

A

put DBModule name before tblName OR IT WONT WORK
you could even be a cool kid and use WITH dbmName do like a SUPER COOL KID

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
37
Q

how to edit existing data in db

A
  1. find + select record wanting to edit
  2. set tbl to edit mode (tbl.Edit)
  3. set new values as shown before
  4. POST!!
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
38
Q

how to find record in DB

A

tbl.Locate(‘fieldName’, searchValue, []) - selects that record and do what you will with it after

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
39
Q

generally with setting modes of tbl…

A

do right before doing it - like put tbl.edit right before editing ykyk - idk if this is actually a thing but i remember it once

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
40
Q

what is a class

A

data type describing attributes and behaviour of object to be created from it (BLUEPRINT)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
41
Q

object

A

INSTANCE of the class - like a model formed from the blueprint

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
42
Q

attributes

A

data fields of class (PROPERTIES)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
43
Q

behaviour

A

code providing interaction with attributes - INTERACTIONS with object made up of attributes, how can use attributes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
44
Q

encapsulation

A

grouping of attributes and behaviour into one entity (object of type class)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
45
Q

what is OOP used for?

A
  1. independent isolated code
  2. reusable code
  3. improved integrity
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
46
Q

how to declare a class

A
  1. create unit file for class code

type
ClassName = class(optional baseClass)

private
declare attributes + private methods

public
declare public methods

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
47
Q

access specifier

A

where accessible
- private: inside class
- protected: inside class / classes based on class
- public: any program where class used
- published: public but available in object inspector

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
48
Q

remember for working with classes!

A

type class code in class unit!

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
49
Q

types of class methods

A

getter (accessor)
setter (mutator)
constructor
ToString
other auxiliary (helper) methods

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
50
Q

type double

A

real with more digits for fraction

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
51
Q

class diagram

A

identity (name)
attributes (state)
name : type;
methods (behaviour)
declarations of methods

in total forms encapsulation
include private/public with -/+

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
52
Q

after declared methods, what do?

A

ctrl+shift+C to make implementation of method

53
Q

constructor method

A

INSTANTIATES (makes an instance of) object
constructor keyword
types of constructors:
- default: sets attributes to default values
> create; overload; —– only do this if smth not working bc it just confuses things imo
- manual: sets attributes to values
> create(dataName : type); overload; (overloads default constructor) - declare default one first and put after with overload at end

54
Q

constructor method implementation

A

Self.attribute := inputVarFromParameter

55
Q

get method implementation

A

function
result := attributeName

can transform to more useful output - like toString or smth

56
Q

set method implementation

A

self.attribute := InputVarParameterValue
can include input validation or change form of input

57
Q

auxiliary methods

A

just remember if function - use result keyword at end

58
Q

ToString method implementation

A

function
construct output string of representation of state of object
assign to result

59
Q

application of class

A

class declared as dataType in class unit
on main unit
1. add class unit to uses
2. create variable of dataType of the class (instantiate object) AS GLOBAL VARIABLE under implementation
3. call methods of class THROUGH OBJECT VARIABLE - always use constructor create first to make object

60
Q

what is a 2D array

A

array with 2 indices, each holding an array (row and column)

61
Q

what do you use when working with a 2D array?

A

nested loop

62
Q

why use a 2D array

A

data centralised
data relationalised (totally a word)

63
Q

what do indices represent

A

first (i) : row
second (j) : column

64
Q

syntax for 2D array

A

arrArray[index1, index2]

65
Q

how to declare a 2D array

A

arrArray : array[1..i, 1..j] of type;

66
Q

limitations of 2D array

A

same type
set size of array - set way too big to initialise when in doubt

67
Q

how to view 2D arrays when reading from or writing to them

A

treat as grid - not assigning 2 values and not assigning to 2 arrays - assigning ONE value to the jth spot of the ith array ykyk

68
Q

how to get length of array in 2D array

A

length of 1st array (i): Length(arrArray)
length of 2nd array (j): Length(arrArray[i])
length of 3rd array: Length(arrArray[i,i]);

69
Q

what to do when want to work through row of 2D array

A

keep row index constant and loop through j

70
Q

what to do when want to work with column of data

A

make second index constant and loop through first

71
Q

first part of SQL statement

A

SELECT fieldName, fieldName FROM tableName

72
Q

select all

A

*

73
Q

only select unique values in field

A

SELECT DISTINCT fieldName FROM tblName

74
Q

how to sort data in SQL statement

A

SELECT fieldName FROM tblName ORDER BY fieldName orderType
types : ASC and DESC
if multiple: field1 ASC, field2 DESC

dont need to say ASC if ASC

75
Q

how to select conditional data in SQL statement

A

SELECT * FROM tbl WHERE (logic statement)

76
Q

SQL statement syntax

A

string in ‘’

77
Q

what used in where clause when needing it to be more general

A

wildcards and the like operator

78
Q

wildcards

A

represent any characters
_ : one character (not none)
%: zero/many characters

79
Q

how use wildcards

A

put in string
ALWAYS USE LIKE NOT =

80
Q

how to combine conditions in WHERE clause

A

boolean operators - place in brackets!!

81
Q

boolean operators

A

AND
OR } between statements
NOT - place after where

82
Q

what else can be used in WHERE clause?

A

special SQL operators

83
Q

special SQL operators

A

BETWEEN
IN
IS NULL
IS NOT NULL

84
Q

BETWEEN

A

WHERE fieldName BETWEEN min AND MAX
selects all between, INCLUDING min and max values

85
Q

IN

A

selects values that are in list
WHERE fieldName IN (value1, value2, ..)
REMEMBER IN BRACKETS

86
Q

IS NULL

A

selects records with no value
WHERE fieldName IS NULL

87
Q

IS NOT NULL

A

selects records with values
WHERE fieldName IS NOT NULL

88
Q

how to use a date in a condition

A

surround with ## NOT ‘’
not have to be in specific format - follow american ways though (eye roll)

89
Q

how to use data of dates HA

A

date functions:
YEAR(date) - int
MONTH(‘’) - int
DAY(‘’) - int
DATE(‘’) - returns todays date

90
Q

what do you do if you wanna change value of data before displaying it

A

calculated field

91
Q

how is a calculated field declared

A

same way as normal field
SELECT calcField FROM tblName
but rename it for aesthetics
SELECT calcField FROM tblName AS calcFieldName

92
Q

what is important to remember with AS

A

cannot reference AS name in later clauses - restate calcField!

93
Q

what to use for calculations in calculated fields

A

mathematical operators
functions
> number
> date
> string

94
Q

number functions to format calculated fields in SQL

A

INT
ROUND
STR
FORMAT

95
Q

INT

A

INT(field) - discards decimals

96
Q

ROUND

A

ROUND(field, decimals) - self-explanatory

97
Q

STR

A

STR(field) - returns DateTime or number as string

98
Q

FORMAT

A

FORMAT(field, formatString) - returns DT or number as string in format

99
Q

how to do formatString for FORMAT command in SQL statement

A

similar to delphi
‘0.00’
‘0.##’
‘Currency’
‘0%’

100
Q

keep in mind with date functions (previously covered) when working with calculated fields

A

can’t use function keywords as name of calcField - e.g. AS Year

101
Q

string functions for SQL

A

LEN
LEFT
RIGHT
MID

102
Q

LEN

A

LEN(string) - num chars

103
Q

LEFT

A

LEFT(string, numChars) - returns indicated no of chars from start of string

104
Q

RIGHT

A

opposite of LEFT

105
Q

MID

A

MID(string, firstChar, chars) - returns no of chars from given point in string

106
Q

how to combine strings

A

+

107
Q

when formatting date

A

use abbreviations as placeholders
ddmmyy hhnnss

108
Q

what to use when want to answer question about overall dataset

A

aggregate functions

109
Q

aggregate functions

A

SUM
AVG
MIN
MAX
COUNT

110
Q

how to use aggregate functions

A

self explanatory functions
NAME(fieldName)
returns single value

111
Q

how to aggregate functions relate to other fields

A

can’t use alongside as only returns single value

112
Q

what can you use to make aggregate functions look prettier

A

AS

113
Q

how to get aggregate from multiple fields for comparison

A

GROUP BY

114
Q

GROUP BY syntax

A

SELECT groupFieldName, aggFunc(field) AS aggfuncName FROM tbl GROUP BY groupFieldName

NB - include field in select and at end!!

115
Q

how to make a conditional statement on GROUP BY results

A

HAVING after GROUP BY
condition

116
Q

stompi for SQL statements

A

SDfFtOWGH

117
Q

how to make changes to DB

A

INSERT INTO
UPDATE
DELETE

118
Q

INSERT INTO

A

adds records
INSERT INTO tblName (fieldNames) VALUES (values) - separate with values and in correct order/data type
dont need to include field names if inserting all - ALWAYS ADD TO PK

119
Q

insert multiple records into

A

INSERT INTO tbl (fieldNames) VALUES (values), (values), etc…

120
Q

if no value for field in record

A

,,

121
Q

DELETE

A

deletes records
DELETE FROM tbl WHERE

122
Q

UPDATE

A

changes value
UPDATE tblName SET fieldName = value, fieldName = value …
WHERE - NB

123
Q

ASCII space

A

32

124
Q

ASCII 0

A

48

125
Q

ASCII A

A

65

126
Q

ASCII a

A

97

127
Q

querying two tables

A

SELECT tbl1.fieldName, tbl2.fieldName FROM tbl1, tbl2 WHERE tbl1.FK = tbl2.PK
link through where clause with keys

128
Q

how to simplify two table queries

A

tbl AS M or smth and then M.