Chapter 8 Connecting Web App to Database - Exercises
Chapter 8
Connecting Web App to Database
Fill in the blanks.
1. The mysqli_fetch_row
function is used to fetch the records returned by the query.
2. The mysqli_query function will execute the query
with the help of the connection object.
3. The mysqli_select_db
function is used to connect the database.
4. The DBMS concept
was first implemented in 1950s.
5. The Hierarchical
DBMS employs the parent-child relationship of storing data.
Write T for True and F for
False.
1. The mysqli_connect
function connects the web app to the MySQL server. T
2. The
mysqli_select_db function sets the active connection with the database. T
3. MySQL is a
popular RDBMS. T
4. The objects to
be stored in the database have different attributes. T
5. Network DBMS
supports one-to-many relationships. F
Application based
questions.
1.
Anil
is creating a DBMS that will store details of the teachers and classes they are
teaching. Suggest the kind of DBMS Anil should use.
Relational DBMS
2.
Akshay
wants to fetch the records from a table named Teacher. He wants to create a
query and execute it. Help Akshay to write the syntax for the same.
$con=mysqli_connect(“localhost”,”root”,””);
Mysqli_select_db($con,”Teacher_Database);
$query=”select * from Teacher where Teacher_ID=$T_ID”;
$data=mysqli_query($query);
$result=mysqli_query($con,$query);
$row=mysqli_fetch_row($result);
Answer the following
questions.
1.
What
is Database? Give examples.
Database is an organized
collection of data.
For example: Attendance of students in attendance register.
2.
Differentiate
between the Network and Relational DBMS.
Network
DBMS usually results in complex database structure as it supports many-to-many
relationship.
RDBMS supports tables to
make the database relationship. RDBMS supports predefined data types.
3.
What
is SQL? Name any two SQL-based DBMS software.
SQL stands for Structured
Query Language.
It helps in establishing two-way
communication between the web app and the DBMS.
Software based on SQL are
MYSQL , Postgre SQL, MySQL Workbench, HeidiSQL, etc.
4.
What
is the difference between mysqli_connect and mysqli_select_db function?
mysqli_connect function
connects the app to MySQL Server.
mysqli_select_db function
sets an active connection with the database.
5.
Write
down the main steps in connecting the web app to the database to obtain result
from a table.
Step 1: Creating a connection with the MySQL server.
Step 2: Creating a
connection with the database.
Step 3: Creating an SQL query to fetch data from the table.
Step 4: Executing the query.
Step 5: Displaying query result.
Comments
Post a Comment