Sunday, 29 May 2016

Class 2/5/2016 (Week 10)


Today class is about MySQL. We learnt about the Server Side Script which is MySQL. SQL is a standard language for accessing databases. We have learned about Database, DBMS, and also relational Databases.


What is SQL (Structured Query Language)
  • SQL stands for Structured Query Language
  • SQL allows you to access a database
  • SQL is an ANSI standard computer language
  • SQL can execute queries against a database
  • SQL can retrieve data from a database
  • SQL can insert new records in a database
  • SQL can delete records from a database
  • SQL can update records in a database
  • SQL is easy to learn

Data Manipulation Language (DML)
These query and update commands together form the Data Manipulation Language (DML), 
part of SQL:

  • SELECT - extracts data from a database
  • UPDATE - updates data in a database
  • DELETE - deletes data from a database
  • INSERT INTO - inserts new data into a database


Data Definition Language  

The most important DDL statements in SQL are:
  • CREATE TABLE - creates a new table
  • ALTER TABLE - modifies a table
  • DROP TABLE - deletes a table
  • CREATE INDEX - creates an index (search key)
  • DROP INDEX - deletes an index 


Accessing MySQL via PHP
There are four steps process to access MySQL from a PHP script: 

Step 1: Make a connection to MySQL database server .
  • require that you specify the location of the database, plus a username and password.

Step 2: Select the database within MySQL that you want to work with .
  • Example: select "SIS" database.

Step 3: Issue an SQL statement/create the query.
  •  could be any valid SQL keyword, example: SELECT, UPDATE.

Step 4: Iterate through the SQL result set: if you are issuing a SELECT statement, iterate through the result set and extract each record.
  •  Example: extract specific fields in each record and display as HTML.



















No comments:

Post a Comment