0% found this document useful (0 votes)
21 views18 pages

A MG - SOD - L4 - Website and Database Integration

Uploaded by

jobmic2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views18 pages

A MG - SOD - L4 - Website and Database Integration

Uploaded by

jobmic2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 18

NATIONAL TVET COMPREHENSIVE ASSESSMENT

SCHOOL YEAR 2020 – 2021

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

Middleware is a bridge between two applications 2marks

Reference:LU1: Connect to the database, p283

2.Difference between web browser and website.

a) Website: is a collection of related network web resources, such as web


pages, multimedia content, which are typically identified with a common
domain name, and published on at least one web server.
2marks

Or

Website is a collection of two or more webpages linked together to achieve


specific purpose.

b) Web browser: is application software which interprets HTML code into


human readable plain-text or renders HTML text. So that It is used to access
and view a website.
2marks

Reference:LU1: Connect to the database, p285

3.When we are integrating database with a website we pass through 3


layers. Explain these layers? 3Marks
Answer:
When we are integrating database with a website we pass through 3 layers
include:

i. Presentation Layer (User Interface Layer): It is concerned with


interacting with the user and display data
1mark
ii. Logic Layer (Business Logic layer) It is concerned with executing
the business logic operations of the application based on certain
business rules.
1mark
iii. Data Access Layer: comprises of a collection of classes, interfaces
and their methods and properties that are used to perform CRUD
(Create, Read, Update and Delete) operations in the application
1mark
Reference:LU1: Connect to the database, p282

4. What is the use of the following functions? 4 Marks

a. MySQLi_query ( )
b. MySQLi_fetch_array ( )

Answer:

a. MySQLi_query ( ) : it is used to execute a query in php-mysql


(2Marks),
b. MySQLi_fetch_array ( ) : it is used to Creating an array of results
(2 Marks),
5.What are four (4) constraints commonly used in SQL? 4Marks
Answer: The following constraints are commonly used in SQL:
i. NOT NULL - Ensures that a column cannot have a NULL value
ii. UNIQUE - Ensures that all values in a column are different
iii. PRIMARY KEY - A combination of a NOT NULL and UNIQUE. Uniquely
identifies each row in a table
iv. FOREIGN KEY - Uniquely identifies a row/record in another table
v. CHECK - Ensures that all values in a column satisfies a specific
condition
vi. DEFAULT - Sets a default value for a column when no value is
specified

Reference:LU1: Connect to the database, p285

6. What is the difference between server-side scripting and client-side


scripting?
Answer:
Client-side scripting simply means running scripts, such as
JavaScript, on the client device, usually within a browser.
2marks
Server-side scripts run on the server instead of the client, often in
order to deliver dynamic content to web pages in response to user
actions.
2mar
ks
Reference:LU1: Connect to the database, p283

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

Reference:LU1: Connect to the database, p283


8.What stand for CRUD in term of web development? 4Marks
Answer:
Answer:
 Create
 Read
 Update
 Delete

Reference:LU2: Implement CRUD operations, p289

9. Answer by True or False


The following elements are used to establish interaction between application
and data storage.
i. www False
1mark
ii. Password True
1mark
iii. Localhost True
1mark
iv. URL False
1mark
v. Database name True
1mark
Reference:LU1: Connect to the database, p285

10.Why do we use middleware in web application system?

Answer:

Because the middleware is now the communication channel between the


systems, all monitoring of your integration takes place in one system. One of
the most crucial reasons that we use middleware is that it allows both
systems to operate independently.
5marks
Reference:LU1: Connect to the database, p285
11. Among the following applications, use Yes to show those are browsers
and otherwise use No.

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

13. a) What is HTML editor?


Answer:
HTML editor is a specialized piece of software that assists in the creation of
HTML code.
2marks
b) Give any 3 example of html editors
Answer:
i. Notepad, 1mark
ii. Sublime text and
1mark
iii. EditPlus,
1mark
Reference:LU1: Connect to the database, p283

SECTION B: THIS SECTION IS COMPOSED BY THREE COMPULSORY


QUESTIONS 30marks

14.a) Define a webserver


Answer:
The primary function of a web server is to store, process and deliver web
pages to clients.
1mark
b) Describe how webserver works
Answer:
i. A web server (or Web server) is server software, or hardware
dedicated to running said software, that can satisfy World Wide Web
client requests.
3mark
s
ii. A web server can, in general, contain one or more websites.
3marks
iii. A web server processes incoming network requests over HTTP and
several other related protocols.
3marks
Reference:LU1: Connect to the database, p282
15.Assume that you are called for interview before being a task of creating
database and connect to website of a company MGT ltd, then the interviewer
asks you the bellowing:
a) What do you know about DBMS? 3Marks
b) In your own words, talk about two (2) advantages of DBMS? 5Marks
c) What do you mean website? 2Marks

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?

A website (also written as web site) is a collection of web pages and


related content that is identified by a common domain name and
published on at least one web server. ... The software application used on
these devices is called a web browser. 2Marks

Reference:LU1: Connect to the database

16. Refers to the following code:


<FORM NAME="myform" ACTION="" METHOD="GET">
Enter something in the box: <BR>
<INPUT TYPE="text" NAME="inputbox" VALUE=""><P>
<INPUT TYPE="button" NAME="Save"
Value="Click"onClick="testResults(this.form)">
</FORM>
Give the role of:
i. ACTION attribute 2marks
ii. METHOD attribute 2marks
iii. Text value 2marks
iv. Button value 2marks
v. What will happen when we use POST instead of GET as value of
method ?2marks

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

Reference:LU3: Create reports to present summary information,


p294

SECTION C: CHOOSE ONE IN TWO QUESTIONS OF YOUR CHOICE


15marks
17.By referring to the following exhibit

a) What does the pictures show?


Answer:
Description of table Players
2marks
b) Write the query for creating the table players
Answer: 4marks
CREATE TABLE IF NOT EXISTS `players` (
`id` int(5) NOT NULL AUTO_INCREMENT,
`first_name` varchar(255) NOT NULL,
`last_name` varchar(255) NOT NULL,
`position` varchar(255) NOT NULL,
`number` int(11) NOT NULL,
`image` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1
;

c) What do you mean by auto increment?


Answer:
The Auto Increment is a function that operates on
numeric data types. It automatically generates sequential
numeric values every time that a record is inserted into a table
for a field defined as auto increment.
3marks
d) List all data types from table players
3marks
Answer:
data types available in table players are : int and varchar
e) Remove field last_name from players table
3marks
Answer:
ALTER TABLE players DROP COLUMN last_name;
3marks
Reference:LU1: Connect to the database, p284

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

Reference:LU3: Create reports to present summary information, p294

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");

$sql="SELECT * FROM product";


$query=mysqli_query($db,$sql);
while ($row = mysqli_fetch_assoc($query)) {
$id=$row['id'];
$productcode = $row['productcode'];
$productname = $row['productname'];
$action_id=$row['id'];
?>
<tr>
<td><?php echo $productcode; ?></td>
<td><?php echo $productname; ?></td>
</tr>
<?php }
?>
</table>
</center>
</body>
</html>

You might also like