Upload
mikzcali9642
View
230
Download
0
Embed Size (px)
Citation preview
8/3/2019 Sad Report
1/12
In this document you will learn
MySQL Structured Query Language (SQL) Communicating with a MySQL backend via the PHP
MySQL , Select, where, order by Database Design Concepts
MySQL
is a relational database management system (RDBMS) that runs as a serverproviding multi-user access to a number of databases. It is named after developerMichael Widenius daughter, My.
The SQL phrase stands for Structured Query Language.
MySQL is the most popular Open Source Relational SQL database management system.MySQL is one of the best RDBMS being used for developing web based softwareapplications.
8/3/2019 Sad Report
2/12
MySQL Data TypesSee the table that follows for the potential data or field types in MySQL.
8/3/2019 Sad Report
3/12
8/3/2019 Sad Report
4/12
8/3/2019 Sad Report
5/12
8/3/2019 Sad Report
6/12
MySQL Quick ReferenceDatabase Manipulation CommandsUse the following commands to create and make changes to your database andtables.
8/3/2019 Sad Report
7/12
SQL - STRUCTURED QUERY LANGUAGE
SQL is a standard language for accessing and manipulating databases
What Can SQL do?
SQL can retrieve data from a database
SQL can insert records in a database
SQL can update records in a database
SQL can delete records from a database
SQL can create new databases
SQL can create new tables in a database
SQL can create stored procedures in a database
SQL can create views in a database
SQL can set permissions on tables, procedures, and views
SQL - often referred to as Structured Query Language) is a
programming language designed for managing data in relational
database management systems (RDBMS).
Originally based upon relational algebra and tuple relationalcalculus, its scope includes data insert, query, update and delete,
schema creation and modification, and data access control.
SQL was one of the first commercial languages for Edgar F. Codd's
relational model, as described in his influential 1970 paper, "A
Relational Model of Data for Large Shared Data Banks".Despite not
adhering to the relational model as described by Codd, it became the
most widely used database language.
SQL Statements
Most of the actions you need to perform on a database are done with
SQL statements.
SQL can be divided into two parts:
The Data Manipulation Language (DML)
8/3/2019 Sad Report
8/12
Data Definition Language (DDL)
The query and update commands form the 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
The DDL part of SQL permits database tables to be created or deleted.
The most important DDL statements in SQL are:
CREATE DATABASE - creates a new database
ALTER DATABASE - modifies a database
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
If you were thinking of what was the difference between MySQL and
SQL. Now here is the answer.
SQL is a language used with databases; MySQL is a database
application that uses in SQL.
SQL is a common database computer language designed for the retrieval andmanagement of data in relational database management systems (RDBMS) --basically a standard interactive and programming language for querying andmodifying data and managing databases. Very standard for uses rangingfrom the simplest Microsoft Access applications, up to complex multi-server distributed Oracle applications.
MySQL is a multithreaded, multi-user SQL database management system (DBMS)providing multi-user access to a number of databases. MySQL is commonly
8/3/2019 Sad Report
9/12
the back engine database for a great many applications, and often thedatabase of choice for web-based applications.
SQL Statements
Most of the actions you need to perform on a database are done with SQLstatements.
Entering in Command Prompt
Syntax:
cd\cd xampp\mysql\binmysql u root
after typing the syntax there will bea Welcome to MySQLmonitor..notification as seen at
left.
SQL syntax
Creating a database Syntax My sample
Using the database Syntax
Now you can use your created database.
Creating table Syntax
create database
database_name;create database csc130;
use database_name; use csc130;
create table table_name (field1,
field2 and so on, primary
key(field));
create table student (idno char(10), fullname
char(50),course char(30), primary key (idno));
8/3/2019 Sad Report
10/12
Inserting information into the table
Selecting the table
The output is displaying the information of the student
Order by Syntax
The output is displaying the student information starting the namefrom A-Z.
Adding Field
The student information add other attribute the email. Now the
attribute are idno, fullname, course, email.
Communication with a Mysql backend via the PHP
insert into table_name (field1, field2 ,
.)values(value1,value2,);
insert into student (idno, fullname, course
,.)values(001,Kim T. Calipes,BSIT);
select * from table_name;select * from student;
select * from table_name order by
name ;select * from student order by name ;
Alter table table_name add
field_name value ;
Alter table student add email value
char(30);
8/3/2019 Sad Report
11/12
Connecting to the Database
Before you can connect to the database, you need four things: Database name Host Server name Username Password
Connect to the database using the following command (in PHP):$connection = mysql_connect(servername, username, password);
You then need to select the appropriate database by using the following command(in PHP):
Accessing the Database
MySQL commands are inserted within your PHP code to access the database in thisway:
//your information has now been updated
Inserting/Adding Information to your table
8/3/2019 Sad Report
12/12
Database Design Concepts
Click the link below..