CH8 Connecting Web Apps to Database Flashcards
Data
–data is the plural of the word datum which is synonymous to information.
–It includes any attributes related to any object.
–e.g. height and weight are some attributes related to you and a form of data
Database
- refers to a systematic collection of data
- information is organized in such a way that makes data management easy
DBMS
Database Management System (DBMS) is a collection of programs which enables the users to access the database, manipulate data, and help in the representation of data.
It was first implemented by Charles Bachman in 1960s.
What are the types of DBMS?
- Hierarchical DBMS
- Network DBMS
- Relational DBMS
- Object Oriented Relational DBMS
Hierarchical DBMS
- shows a parent-child relationship of storing data
- not in use nowadays
- its structure is like a tree with nodes representing records and branches representing fields
Network DBMS
- supports many-to-many relationships
- results in a complex database structure
- e.g. dm server
Relational DBMS
–database relationships are portrayed in the form of tables, also called relations
–pre-defined data types are supported
–most popular DBMS type used worldwide
–e.g. MySQL, Oracle and Microsoft SQL server
Object-Oriented Relational DBMS
- supports the storage of new data types
- data is stored in the database in the form of objects
e.g. PostgreSQL
SQL
- the user may extract data from the database using a web app
- the web app therefore needs to communicate with the database
- this 2-way communication is possible through a language called SQL.
mysqli_connect
Connects the web app to the MySQL server
$con=mysqli_connect(“localhost”,”USERNAME”,””);
mysqli_select_db
Sets an active connection with the database
mysqli_select_db($con,”DATABASE NAME”);
mysqli_query
executes the query
$data=mysqli_query($sqlquery);
mysqli_fetch_row
fetches the record from the table
$result=mysql_query($con,$sqlquery);
$row=mysqli_fetch_row($result);
Write down the main steps in connecting the web app to the database to obtain result from the table.
- creating a connection with the MySQL server
$con=mysqli_connect (“localhost”, “USERNAME”, “”);
- creating an active connection with the database
mysqli_select_db ($con, “DATABASE NAME”);
- Creating an SQL query to fetch data from the table
$sqlquery=”select * from details where rollno=$rollno”;
- Executing the query
$data=mysqli_query($sqlquery);
- Displaying the query result
$result=mysqli_query($con, $sqlquery);
$row=mysqli_fetch_row($result);