Additional question 2_2
QUESTION 2: SQL AND DATABASE
Sonop Highschool has a fundraising event. The money collected will help fund various
extramural activities at the school.
The FundsDB.mdb database contains two tables called tblStands and tblDonations.
The records contained in the tblDonations table consist of the following fields:
DonationIDID – a unique number for each donation(PK)
StandID – The ID of the stand to which the donation go to (text data type)
Item – Item to which the donation goes (text data type)
Amount – Amount of the donation (Currency)
Received – Donation received (Yes/No)
Example data from the tblDonations table (first 10 records):
The records contained in the tblStands table consist of the following fields:
StandID – unique index code for each Stand (Text data type) the code is compiled
using the following - R=Rugby / H=Hockey + A/B/C - Field + 2 numbers
Class – Class responsible for the stand(Text)
StandName - Name of the stand (Text)
Teacher – Teacher responsible for the stand
GuestNumber – Possible number of guests
Example data from the tblStands table (first 10 records):
The StandID field has been used to link the two tables.
Copyright reserved
Do the following:
Open the incomplete project file called Question2_P.dpr.
Add your name as a comment in the first line of the Question2_U.pas unit file.
Compile and execute the program. The program has no functionality
NOTE: If the compiler shows an error message with regard to the given CurrencyString
statement, remove the statement.
NOTE:
The 'Restore database' button is provided to restore the data contained in the
database to the original content.
The content of the database is password protected. You will therefore not be able to
gain access to the content of the database with Microsoft Access.
Code is provided to link the GUI components to the database.
Do NOT change any of the provided code.
TWO variables are declared as public variables, as described in the table below.
Variable Data type Description
tblStands TADOTable Refers to the table tblStands
tblDonations TADOTable Refers to the table tblDonations
Select tab sheet Question2.1 SQL, which displays the following GUI:
2.1 Tab sheet [Question 2.1 - SQL]
Copyright reserved
In this section you may use ONLY SQL statements to answer
QUESTION 2.1.1 to QUESTION 2.1.5.
Code to execute the SQL statements and display the results of
the queries is provided. The SQL statements are incomplete.
Do the following:
Enter the SQL statements for QUESTION 2.1.1 to QUESTION
2.1.5 which is assigned to the variables sSQL1, sSQL2, sSQL3,
sSQL4 and sSQL5 respectively.
2.1.1 Button [Display]
Display all the information from the tblStands sorted in ascending
order of the StandName.
Example of output of the records:
(3)
2.1.2 Button [Amount > 200]
Display the StandID and the amount that is more than R 200 from
tblDonations. You do not have to format the amount. (4)
Example of output of the records:
2.1.3 Button [Foodparcels]
An estimated number of foodparcels should be calculated by using a
value of 1.25 for each expected guest.
Display the name of the stand and die number of food parcels to be
prepared for stands on the C-Rugbyfield. The number of foodparcels
Copyright reserved
is calculated using the formula GuestNumber * 1.25 and rounded to (6)
the nearest integer value.
Example of output of the records:
2.1.4 Button [Gr 12 donations]
Display for each gr 12 class the (tblStands), the item (tblDonations
and the total amount of donations for each item. Display the total
amount as currency with TotalD as heading.
(10)
Example of output of the records
Copyright reserved
2.2 DATABASE MANIPULATION
Select tab sheet Question2.2 Database code, which displays the content of both
tables as well as the three buttons for the questions that need to be completed:
NOTE: NO marks will be allocated for the use of SQL statements for
QUESTION 2.2. The names of the tables to be used in your code must
be tblStands and tblDonations.
Complete the code to meet the requirements specified in QUESTION 2.2.1 to
QUESTION 2.2.3.
Example of GUI for QUESTION 2.2
()
Copyright reserved
2.2.1 Button [Gr 8 Teachers]
Display a list of all the teachers for the grade 8 register classes in
the display component redQ2.2.1
Example of output of the register classes:
(7)
2.2.2 Button [Update]
Uncomplete code is given to add a new Stand to tblStands.
Complete the code to write the given information to tblStands. (3)
NOTE: Code is provided to show that the update was successful.
2.2.3 Button [Outstanding Donations]
Calculate and display a message with the total amount of
donations not yet received. (7)
NOTE: the outstanding amount must be displayed as currency
Example of output:
Enter your name as a comment in the first line of the program file.
Save your program.
TOTAL: 40
Copyright reserved