Professional Documents
Culture Documents
MFDB832 Jun 2023 PDF
MFDB832 Jun 2023 PDF
MFDB832 Jun 2023 PDF
CODE: MFDB832
SESSIONAL EXAMINATIONS
JUNE 2023
DURATION: 3 HOURS
INSTRKTP.NS,T9 CANDIDATES
Page 1 of 6
SECTION A COMPULSORY
Question 1
a). Explain how a primary key is different to a foreign key. [4]
b). Maxwell wants to add another column 'Age' in the already existing table 'CLIENTS'. He
has written the following statement. However, it has errors. Rewrite the correct statement.
MODIFY TABLE CLIENTS AGE int (1); [3]
- i). Write a SQL query which selects firstname, Surname, Team, Salary and Age from the
above table. The query should only display only those who play for Dynamos, Highlanders
and Caps United while earning a salary in the range of "10 000 and 26 000" and also their
age is 35 and below. Sort by Surname in Ascending order. [5]
d) John wants to update a record where the primary key is Accountnumber="1005- and
"FirstName" is "Peter" but "Firstname" should be "James" in the 'Account* Table. Write an
- SQL statement to correct this record; [3]
e) Explain any 5 differences between the SQL and No-SQL which are necessary to
understand in SQL for financial data. [5]
Page 2 of 6
SECTION B — ANSWER ANY 2 QUESTIONS
Question 2
a). (i) Explain the difference between INSERT and INSERT IGNORE [2]
(ii)Use tables as examples, explain the difference between Left Join and Right Join [4]
b). In a School, the students are allocated to programmes. A database named 'School' is
created. One table in this database is: STUDENT with StudentId, StudentName as columns
and StudentId as the primary key. Write another suitable table you could expect to see in the
— School' database, with 3 suitable columns identifying Primary key, Foreign key, data types
and their lengths in the table that you expect. [4]
DEPCODE DEPNAME
101 ADMIN
102 RECEPTION
103 PERSONNEL
SET AUTOCOMMIT = 0;
COMMIT;
ROLLBACK;
What will be the output of the above given. SELECT statement? [5]
Page 3 of 6
Question 3
a). Name 2 MySQL data types and explain how they are of importance in MySQL. [2]
Write the following SQL statements including the result set in a table from the 2 tables above
i) Customers who took loans from Gweru and Chegutu branch while the loan
amount is 50 000 and above. The query should have the following fields: account,
firstname, surname, branch, loan amount [4]
ii) The Company wants to issue loans to customers who earn .a salary which meets
their criteria. List all Customers who earn at least a salary of 4000 [2]
Page 4 of 6
iii) Left join query joining the 2 records above and listing all records sorting by
Account in Ascending Order. The account details table as the left table [3]
iv) The total number of female customers who live in Chegutu [2]
v) The company wants a list of customers who were issued loans in the following
range "50 000 and 100 000". The query should have the following fields: account,
firstname, surname, branch, salary and Ioan amount [2]
Page 5 of 6
Question 4
ENO NAME
1 Jack King
2 Bismarck Junior
SET AUTOCOMMIT = 0;
ROLLBACK TO C;
What will be the output of the following SQL query now ordering in Ascending Order by
ENO?
b). With the aid of examples, explain and illustrates the syntax of the following clause:
**END OF EXAMINATION**
Page 6 of 6