Академический Документы
Профессиональный Документы
Культура Документы
Basis Data
Masis
DataMultimedia
Multimedia &&Lab.
Lab.By
By::Muhtadin
Muhtadin
SQL
Identifying Relationship :
Primary key dari child table menjadi foreign key pada parent table
Foreign key ikut serta sebagai primary key pada parent table
Non-Identifying Relationship
Primary key dari child table dimasukkan sebagai foreign key pada
parent table
Namun, foreign key tersebut tidak ikut menjadi primary key pada
parent table.
Non-identifying relationship dapat berupa optional atau mandatory,
yang berarti bahwa nilai foreign key tersebut dapat berupa NULL
atau tidak boleh NULL
SQL ?
SQL dibaca sequel
Didukung oleh banyak commercial database systems
Standardized ada update dan selalu diperbaharui
Interactive via GUI atau menggunakan command prompt, dapat
juga dilakukan dengan memasukkan kedalam kode program.
Declarative, berdasarkan relational algebra
SQL ?
Data Definition Language (DDL)
Create table
Drop Table
Commands lainnya
Indexes, constrains, views, triggers, transaction,
Basis Data Multimedia & Lab. By : Muhtadin
SELECT Statement
GROUP BY group
HAVING group_conditions
what to return
relations
combine filter
group rows
filters group
specifies orde
number of rows
MySQL ORDER BY
SELECT col1, col2,...
FROM tabel
ORDER BY col1 [ASC|DESC], col2 [ASC|DESC],...
10
MySQL GROUP BY
SELECT col1, col2,..,aggregate_function(expression)
FROM tabel
WHERE conditions
GROUP BY col1, col2, ...
11
MySQL HAVING
SELECT col1, col2,..,aggregate_function(expression)
FROM tabel
GROUP BY col1, col2, ...
HAVING conditions
12
MySQL Subquery
13
Inner Join
14
tb_buku
tb_penerbit
15
16
Stored Procedure
Structure
Parameter
Body
Used by Call Statement
17
Stored Procedure
Contoh dari database star_enterprise :
DELIMITER $$
CREATE PROCEDURE GetCustomerLevel(
in p_customerNumber int(11),
out p_customerLevel varchar(10))
BEGIN
DECLARE creditlim double;
SELECT creditlimit INTO creditlim
FROM customers
WHERE customerNumber = p_customerNumber;
IF creditlim > 50000 THEN
SET p_customerLevel = 'PLATINUM';
ELSEIF (creditlim <= 50000 AND creditlim >= 10000) THEN
SET p_customerLevel = 'GOLD';
ELSEIF creditlim < 10000 THEN
SET p_customerLevel = 'SILVER';
END IF;
END$$
18
Reff
Mysql tutorial : www.mysqltutorial.org
19
THANK YOU
20