Anda di halaman 1dari 33

DataBase

2nd year Computer Science &


Engineer

DataBase course notes 9

Database
Database Design
using MySQL

DataBase course notes 9

many books, tutorials, that describe


MySQL and PHP

Ex.:
http://www.tutorialspoint.com/mysql/
http://dev.mysql.com
http://www.mysql.com
http://www.php.net/manual/en/

use of MySQL database server and client


MySQL and PHP originally appeared on
Linux platform
Linux, Apache, Mysql, Php
Windows, Apache, Mysql, Php
DataBase course notes 10

www.mysql.com
worlds most popular Open Source
database
if you need MySQL for non-commercial
use, you can download a copy free

DataBase course notes 10

Databases and Internet


in early days of the internet, websites were
just static things
that required each page to be created manually

sales catalogue on the web


had to create page for every item in catalogue

create standard template page


retrieve product detail from database
create webpage on the fly for each product

DataBase course notes 10

Database Management System


(DBMS)
management system decides how data is stored
and retrieved, as well as controlling user access
to it.
every time user retrieves data, deletes, change
or adds more data, DBMS deals with the request
user cannot access data files directly, he can
only talk to DBMS
management system is a barrier that controls
access to the underlying data
DataBase course notes 10

Database
MySQL can control several databases at
once

DataBase course notes 10

Tables
database is a container to store your
tables in
table is a collection of data of a similar
type
each table in a database has a unique
name within that database, and that is how
we refer to the table

DataBase course notes 10

Columns
any table will have a set of attributes, that is, a
list of types of items that each table will store
we will refer to this attribute as a column
you would have called this a field

each column contains a specific type of data


each column in a table has a unique name
within that table, and that is how we refer to the
column

DataBase course notes 10

Relations
database allowed to set up more than a
table.
database systems are classified as
relational, allowing you to relate data in
tables to data in other tables
in relational database theory, tables are
called relations (columns are called
attributes)
DataBase course notes 10

10

Rows
row (or record) are all different ways of
referring to a line of data within a table
tuple is the relational theory term for row,
and record is the earlier form of databases
term

DataBase course notes 10

11

Client-server Systems

DataBase course notes 10

12

Client-server Systems
data is stored on the server
when client needs to access data, it makes
request to server
on receiving request, server takes necessary
action, and sends its response back to client
response could be data, request for more details, or
error message

one of the most widespread client-server


systems is the internet
DataBase course notes 10

13

Client-server Systems
client and server do not necessarily have
to be on different machines
you can set up MySQL server software and
client software on the same machine

system is still a client-server system even


if it all runs in the same box

DataBase course notes 10

14

DBMS controls access to data

DataBase course notes 10

15

MySQL database behind


website

DataBase course notes 10

16

user asks web browser (Internet Explorer, Mozilla


Firefox, Opera) to look at webpage
request gets sent to web server (Apache, Internet
Information Services (IIS), formerly called Internet
Information Server)
if that webpage is built using a scripting language such
as PHP or ASP.NET, the request gets forwarded to the
script processor
if script processor finds database commands (SQL)
passes them to DBMS, that is, MySQL server or Oracle,
Microsoft SQL Server, PostgreSQL,
DataBase course notes 10

17

database (DBMS) processes SQL, which is sent back to


script processor as text
text is used to generate HTML along with other commands in
scripting language

gets sent back to the user in HTML


finally gets processed by web browser into a webpage
happen very quickly, even when servers are on different
machines
each server is specifically optimized to do its own task
quickly, so they all work well together

DataBase course notes 10

18

Structured Query Language


as databases became more prominent, some standard
method of obtaining information from them was required
does not really matter how DBMS stores data or controls access
to it, as long as you get information that you want from it back in
an acceptable way

standard way of communicating with database servers


was needed
most of commands are standard across all SQL
platforms
you should be able to transfer your knowledge of SQL to
other DBMS quickly
DataBase course notes 10

19

MySQL
lighter
free license
release 5

MS SQL Server
more enterprise features
free license
for Computer Science
personnel

release 2005, 2008,


2012, 2014

DataBase course notes 10

20

SQL Server 2008


http://www.microsoft.com/en-us/download/search.aspx
?q=sql+server+2008+r2

SQL Server 2012


http://www.microsoft.com/en-us/sqlserver/editions/2012editions/express.aspx

Oracle Database:

Oracle 11g express edition


Oracle 12c

http://www.oracle.com/technetwork/database/enterpriseedition/downloads/index.html

Interactive SQL tutorial


http://sqlzoo.net/
DataBase course notes 10

21

MySQL Community Server is free


unix, windows, mac osx

MS SQL Server 2005/2008/2012 Express


totally free, but limited to max 1 GB bufferpool, max 1
processor, max 4 GB per database
Windows NT or 2000 or more

Oracle 11g Express


totally free, but limited size for bufferpool, limited
storage space for each database, limited number of
processors
unix, windows, mac osx
DataBase course notes 10

22

Mimer
free downloads available for developers
unix, windows, mac osx, symbian ...

IBM DB2 9.5 Express


totally free and no database size limit, but limited to
max 2 GB bufferpool, max 2 processors
linux and windows

PostgreSQL
free
often bundled with linux, windows

DataBase course notes 10

23

Installing MySQL

DataBase course notes 10

24

Install MySQL Server


Php MySQL Portable only have to start
mowes.exe, then MySQLWorkbench.exe
for

for Wamp, Xamp, MySQL, there is a


special installation kit that has to be run

DataBase course notes 10

25

Install Graphical Client Tool


Toad for MySQL http://www.quest.com/toad-for-mysql/
freeware development tool
improves productivity of developers and
administrators running MySQL on Windows

phpMyAdmin
free software tool written in PHP intended to
handle administration of MySQL over internet
included in most WAMP distributions
DataBase course notes 10

26

MySQL Directory Structure

DataBase course notes 10

27

Starting MySQL Service


default the directory where all of MySQLs
executable files are stored is \mysql\bin
to start MySQL service, double click on
winmysqladmin.exe file
screen shown in next figure will appear for few
moments and then hide itself
first time it is run the MySQL service will prompt
you for some user credentials for the
administrative user
DataBase course notes 10

28

MySQL admin screen

DataBase course notes 10

29

depending on your operating system and


version of MySQL that you have, preceding
process also installs shortcut to
WinMySQLadmin.exe in your start-up group
ensures that MySQL server starts up every time
you restart your machine

DataBase course notes 10

30

MySQL Configuration Files


my.ini
usually stored in \windows directory, if you
have chosen a standard installation
contains various parameters, such as location of
datastore (datadir), IP address of server,
username and password that you just entered
everything is now set up and running
we need to test that we can connect to server
DataBase course notes 10

31

Connecting to MySQL Server


the most basic way, via command line
interface
start command box
get into the directory with MySQL
executables
cd \mysql\bin

run MySQL command interpreter


mysql
DataBase course notes 10

32

SQL commands
connect database
exit
connect with Graphical Tool

DataBase course notes 10

33

Anda mungkin juga menyukai