A MG - SOD - L4 - Website and Database Integration
A MG - SOD - L4 - Website and Database Integration
SECTOR: ICT
TRADE: SOFTWARE DEVELOPMENT
RTQF LEVEL: LEVEL IV
MODULE CODE AND TITLE: SFDWD401-WEBSITE AND DATABASE
INTEGRATION
DURATION: 3 HOURS
INSTRUCTIONS TO CANDIDATES:
The assessment paper contains three sections: Section A, B and C.
SECTION A: All questions are compulsory /55Marks
SECTION B: This section is composed by three compulsory
questions/30Marks
SECTION C: Choose one in two questions of your choice/15Marks
SECTION A: ALL QUESTIONS ARE COMPULSORY
55marks
1. Define the following terms
a) Text editor
Answer:
It is a type of computer program that edits plain text. It can be used
programming language source code, to documentation files.
2marks
b) Middleware
Answer:
-Middleware is the software that connects network-based requests
generated by a client to the back-end data the client is requesting.
2marks
Or
Or
a. MySQLi_query ( )
b. MySQLi_fetch_array ( )
Answer:
7.Give Four (4) functions of mysql and explain how they are used.4Marks
Answer:
Five function of mysql are:
Mysql_connect()/ 0.5Mark: Is used to connect to the server
0.5Mark
Mysql_error()0.5Mark: Is used to check for occurred errors
0.5Mark
Mysql_select_db()0.5Mark: Is used to select the database you
want to work with 0.5Mark
Mysql_close()0.5Mark: Is used to close the connection 0.5Mark
Mysql_query()0.5Mark: Is used to execute an SQL query 0.5Mark
Answer:
No Application Browser
1 Mozilla Firefox 1mark
2 google 1mark
3 Internet Explorer 1mark
4 xampp 1mark
5 Apple Safari 1mark
Answer:
No Application Browser
1 Mozilla Firefox Yes 1mark
2 google Not 1mark
3 Internet Explorer Yes 1mark
4 xampp Not 1mark
5 Apple Safari Yes 1mark
Reference:LU1: Connect to the database, p283
12.
a) What is a role of Echo? 2marks
b) Show how is used with a simple program 2marks
Answer:
a . Echo is used to display or print out an output in php.
b. <?php
echo " Hello!!!!!, My name is John ";
/*this echo will allow Hello!!!!!, My name is John,
To be displayed as an output*/
?>
Reference:LU3: Create reports to present summary information,
p295
Answer:
a) A database management system (DBMS) is a software package
designed to define, manipulate, retrieve and manage data in a
database. A DBMS generally manipulates the data itself, the data
format, field names, record structure and file structure. It also defines
rules to validate and manipulate this data. 3Marks
b) In your own words, talk two (2) examples of database? 5Marks
Reducing Data Redundancy
The file based data management systems contained multiple files that
were stored in many different locations in a system or even across
multiple systems. Because of this, there were sometimes multiple
copies of the same file which lead to data redundancy. 2.5Marks
This is prevented in a database as there is a single database and any
change in it is reflected immediately. Because of this, there is no
chance of encountering duplicate data.
Sharing of Data
In a database, the users of the database can share the data among
themselves. There are various levels of authorisation to access the
data, and consequently the data can only be shared based on the
correct authorisation protocols being followed.
Many remote users can also access the database simultaneously and
share the data between themselves. 2.5Marks
Data Integrity
Data integrity means that the data is accurate and consistent in the
database. Data Integrity is very important as there are multiple
databases in a DBMS. All of these databases contain data that is visible
to multiple users. So it is necessary to ensure that the data is correct
and consistent in all the databases and for all the users. 2.5Marks
Data Security
Data Security is vital concept in a database. Only authorised users
should be allowed to access the database and their identity should be
authenticated using a username and password. Unauthorised users
should not be allowed to access the database under any circumstances
as it violates the integrity constraints. 2.5Marks
c) What do you mean website?
Answer:
i. ACTION attribute is used to determine where the form contents
will be submitted. 2Marks
ii. METHOD attribute defines how the forms’ contents will be
submitted. 2Marks
iii. Text value defines that field will contain text values as input.
2Marks
iv. Button value defines the button object. 2Marks
v. when we use POST instead of GET as value of method the
submitted form contents not appear in the URL, meaning that the
contents are secured compare with GET. 2Marks
18.Consider the form below, write HTML, inline CSS and server side scripting
chosen code to insert and retrieve the records in a single web page.
Notice: Use CRUD
database’s name: berwashop
and table’s name:product
15marks
Answer:
<?php
$db=mysqli_connect("localhost","root","","berwashop");
If(isset($_POST["save "])){
$productcode = $_POST['productcode'];
$productname = $_ POST['productname'];
//$insert="INSERT INTO product SET productcode ='$productcode',
productname='$productname'";
//$insert="INSERT INTO product values('$productcode',
'$productname')";
$insert="INSERT INTO product (productcode, productname)
values('$productcode', '$productname')";
$sql=mysqi_query($db, $insert);
}
?>
<!DOCTYPE html>
<html>
<head>
<title>National Practical Exam</title>
</head>
<body>
<center>
<div class="frm">
<form method="POST">
<p><b>PRODUCT TRANSACTIONS</b></p>
<p>
<label>productcode:</label>
<input type="number" name="productcode" required>
</p>
<p>
<label>productname:</label>
<input type="text" name="productname" required>
</p>
<p><input type="submit" name="save" value="Add product"
Style="background-color:green;color:white;"></p>
</form>
</div>
<br>
<table width="40%" style="border-collapse:collapse;">
<tr>
<th>Productcode</th>
<th>Productname</th>
<th>Action</th>
</tr>
<?php
$db=mysqli_connect("localhost","root","","berwashop");