🗊Презентация 8. Java Databases and JDBC 1. Introduction to Databases

Нажмите для полного просмотра!
8. Java Databases and JDBC 1. Introduction to Databases, слайд №18. Java Databases and JDBC 1. Introduction to Databases, слайд №28. Java Databases and JDBC 1. Introduction to Databases, слайд №38. Java Databases and JDBC 1. Introduction to Databases, слайд №48. Java Databases and JDBC 1. Introduction to Databases, слайд №58. Java Databases and JDBC 1. Introduction to Databases, слайд №68. Java Databases and JDBC 1. Introduction to Databases, слайд №78. Java Databases and JDBC 1. Introduction to Databases, слайд №88. Java Databases and JDBC 1. Introduction to Databases, слайд №98. Java Databases and JDBC 1. Introduction to Databases, слайд №108. Java Databases and JDBC 1. Introduction to Databases, слайд №118. Java Databases and JDBC 1. Introduction to Databases, слайд №128. Java Databases and JDBC 1. Introduction to Databases, слайд №138. Java Databases and JDBC 1. Introduction to Databases, слайд №148. Java Databases and JDBC 1. Introduction to Databases, слайд №158. Java Databases and JDBC 1. Introduction to Databases, слайд №168. Java Databases and JDBC 1. Introduction to Databases, слайд №178. Java Databases and JDBC 1. Introduction to Databases, слайд №188. Java Databases and JDBC 1. Introduction to Databases, слайд №198. Java Databases and JDBC 1. Introduction to Databases, слайд №208. Java Databases and JDBC 1. Introduction to Databases, слайд №218. Java Databases and JDBC 1. Introduction to Databases, слайд №228. Java Databases and JDBC 1. Introduction to Databases, слайд №238. Java Databases and JDBC 1. Introduction to Databases, слайд №248. Java Databases and JDBC 1. Introduction to Databases, слайд №258. Java Databases and JDBC 1. Introduction to Databases, слайд №268. Java Databases and JDBC 1. Introduction to Databases, слайд №278. Java Databases and JDBC 1. Introduction to Databases, слайд №288. Java Databases and JDBC 1. Introduction to Databases, слайд №298. Java Databases and JDBC 1. Introduction to Databases, слайд №308. Java Databases and JDBC 1. Introduction to Databases, слайд №318. Java Databases and JDBC 1. Introduction to Databases, слайд №328. Java Databases and JDBC 1. Introduction to Databases, слайд №338. Java Databases and JDBC 1. Introduction to Databases, слайд №348. Java Databases and JDBC 1. Introduction to Databases, слайд №358. Java Databases and JDBC 1. Introduction to Databases, слайд №368. Java Databases and JDBC 1. Introduction to Databases, слайд №378. Java Databases and JDBC 1. Introduction to Databases, слайд №388. Java Databases and JDBC 1. Introduction to Databases, слайд №398. Java Databases and JDBC 1. Introduction to Databases, слайд №408. Java Databases and JDBC 1. Introduction to Databases, слайд №418. Java Databases and JDBC 1. Introduction to Databases, слайд №428. Java Databases and JDBC 1. Introduction to Databases, слайд №438. Java Databases and JDBC 1. Introduction to Databases, слайд №448. Java Databases and JDBC 1. Introduction to Databases, слайд №458. Java Databases and JDBC 1. Introduction to Databases, слайд №468. Java Databases and JDBC 1. Introduction to Databases, слайд №478. Java Databases and JDBC 1. Introduction to Databases, слайд №488. Java Databases and JDBC 1. Introduction to Databases, слайд №498. Java Databases and JDBC 1. Introduction to Databases, слайд №508. Java Databases and JDBC 1. Introduction to Databases, слайд №518. Java Databases and JDBC 1. Introduction to Databases, слайд №528. Java Databases and JDBC 1. Introduction to Databases, слайд №538. Java Databases and JDBC 1. Introduction to Databases, слайд №54

Содержание

Вы можете ознакомиться и скачать презентацию на тему 8. Java Databases and JDBC 1. Introduction to Databases. Доклад-сообщение содержит 54 слайдов. Презентации для любого класса можно скачать бесплатно. Если материал и наш сайт презентаций Mypresentation Вам понравились – поделитесь им с друзьями с помощью социальных кнопок и добавьте в закладки в своем браузере.

Слайды и текст этой презентации


Слайд 1





8. Databases and JDBC
1. Introduction to Databases
Описание слайда:
8. Databases and JDBC 1. Introduction to Databases

Слайд 2





Relational DBMS
A DBMS in which data is stored in tables and the relationships among the data are also stored in tables
The data can be accessed or reassembled in many different ways without having to change the table forms.
Описание слайда:
Relational DBMS A DBMS in which data is stored in tables and the relationships among the data are also stored in tables The data can be accessed or reassembled in many different ways without having to change the table forms.

Слайд 3





Relational DBMS
Commercial
Oracle
MS SQL Server
DB2
Описание слайда:
Relational DBMS Commercial Oracle MS SQL Server DB2

Слайд 4





Cash Management System
Описание слайда:
Cash Management System

Слайд 5





Merchant Info
Name
Bank
Bank account
Charge percent
Aggregation period
Minimal sum
Описание слайда:
Merchant Info Name Bank Bank account Charge percent Aggregation period Minimal sum

Слайд 6





Customer Info
Name
Address
Email
Credit card No
Credit card type
Credit card maturity date
Описание слайда:
Customer Info Name Address Email Credit card No Credit card type Credit card maturity date

Слайд 7





Payment info
Date
Customer
Merchant
Goods description
Sum
Описание слайда:
Payment info Date Customer Merchant Goods description Sum

Слайд 8





Java DB
Java DB is Oracle's supported distribution of the Apache Derby open source database
It supports standard ANSI/ISO SQL through the JDBC and Java EE APIs
Java DB is included in the JDK
http://www.oracle.com/technetwork/java/javadb/overview/index.html
Описание слайда:
Java DB Java DB is Oracle's supported distribution of the Apache Derby open source database It supports standard ANSI/ISO SQL through the JDBC and Java EE APIs Java DB is included in the JDK http://www.oracle.com/technetwork/java/javadb/overview/index.html

Слайд 9





Eclipse & Java DB
Creating a Driver Definition for Apache Derby
Creating an Apache Derby Connection Profile
Connecting to Apache Derby
Creating and Executing a SQL Query
Описание слайда:
Eclipse & Java DB Creating a Driver Definition for Apache Derby Creating an Apache Derby Connection Profile Connecting to Apache Derby Creating and Executing a SQL Query

Слайд 10





Driver Definition (1 of 2)
Start Eclipse
Menu Window -> Preferences
Expand Data Management -> Connectivity -> Driver Definitions
Click Add button
Select “Derby Embedded JDBC Driver” in Name/Type tab
Описание слайда:
Driver Definition (1 of 2) Start Eclipse Menu Window -> Preferences Expand Data Management -> Connectivity -> Driver Definitions Click Add button Select “Derby Embedded JDBC Driver” in Name/Type tab

Слайд 11





Driver Definition (2 of 2)
Select derby.jar in Jar list tab and click Add JAR/Zip button
Select full path to derby.jar (usually C:\Program Files\Java\jdk1.7.0_05\db\lib) 
Click Open button
Click Ok button
Описание слайда:
Driver Definition (2 of 2) Select derby.jar in Jar list tab and click Add JAR/Zip button Select full path to derby.jar (usually C:\Program Files\Java\jdk1.7.0_05\db\lib) Click Open button Click Ok button

Слайд 12





Eclipse & Java DB
Creating a Driver Definition for Apache Derby
Creating an Apache Derby Connection Profile
Connecting to Apache Derby
Creating and Executing a SQL Query
Описание слайда:
Eclipse & Java DB Creating a Driver Definition for Apache Derby Creating an Apache Derby Connection Profile Connecting to Apache Derby Creating and Executing a SQL Query

Слайд 13





Connection Profile
Switch to the Database Development perspective
In Data Source Explorer, right-click Database Connections and select New
Select Derby, change Name of profile (optionally) and click Next
Select Database location and click Finish
Описание слайда:
Connection Profile Switch to the Database Development perspective In Data Source Explorer, right-click Database Connections and select New Select Derby, change Name of profile (optionally) and click Next Select Database location and click Finish

Слайд 14





Eclipse & Java DB
Creating a Driver Definition for Apache Derby
Creating an Apache Derby Connection Profile
Connecting to Apache Derby
Creating and Executing a SQL Query
Описание слайда:
Eclipse & Java DB Creating a Driver Definition for Apache Derby Creating an Apache Derby Connection Profile Connecting to Apache Derby Creating and Executing a SQL Query

Слайд 15





Connecting to the Database
In the Database Development perspective, expand Database Connections in the Data Source Explorer
Right-click the connection profile that you created and select Connect
Описание слайда:
Connecting to the Database In the Database Development perspective, expand Database Connections in the Data Source Explorer Right-click the connection profile that you created and select Connect

Слайд 16





Eclipse & Java DB
Creating a Driver Definition for Apache Derby
Creating an Apache Derby Connection Profile
Connecting to Apache Derby
Creating and Executing a SQL Query
Описание слайда:
Eclipse & Java DB Creating a Driver Definition for Apache Derby Creating an Apache Derby Connection Profile Connecting to Apache Derby Creating and Executing a SQL Query

Слайд 17





SQL Query
In the Database Development perspective, expand Database Connections in the Data Source Explorer
Right-click the connection profile that you created and select “Open SQL Scrapbook”
Select database
Create SQL query in the editor field
Right-click in the editor and select Execute All.
Описание слайда:
SQL Query In the Database Development perspective, expand Database Connections in the Data Source Explorer Right-click the connection profile that you created and select “Open SQL Scrapbook” Select database Create SQL query in the editor field Right-click in the editor and select Execute All.

Слайд 18





Merchant Info
Name
Bank
Bank account
Charge percent
Aggregation period
Minimal sum
Описание слайда:
Merchant Info Name Bank Bank account Charge percent Aggregation period Minimal sum

Слайд 19





Create Merchant Table
CREATE TABLE merchant
(
   id INT NOT NULL GENERATED ALWAYS AS IDENTITY,
   name VARCHAR(60) NOT NULL,
   bankName VARCHAR (100) NOT NULL,
   swift VARCHAR (40) NOT NULL,
   account VARCHAR (20) NOT NULL,
   charge DECIMAL(5,2) NOT NULL,
   period SMALLINT NOT NULL,
   minSum DECIMAL (19,2) NOT NULL,
   total DECIMAL(19,2),
   PRIMARY KEY (id)
);
Описание слайда:
Create Merchant Table CREATE TABLE merchant ( id INT NOT NULL GENERATED ALWAYS AS IDENTITY, name VARCHAR(60) NOT NULL, bankName VARCHAR (100) NOT NULL, swift VARCHAR (40) NOT NULL, account VARCHAR (20) NOT NULL, charge DECIMAL(5,2) NOT NULL, period SMALLINT NOT NULL, minSum DECIMAL (19,2) NOT NULL, total DECIMAL(19,2), PRIMARY KEY (id) );

Слайд 20





Fill Merchant Table
INSERT INTO merchant 
(name, charge, period, minSum, 
 bankName, swift, account) 
VALUES('Jim Smith Ltd.', 5.1, 1, 100.0, 
           'Chase Manhatten', 'AA245BXW',      
           '247991002');
Описание слайда:
Fill Merchant Table INSERT INTO merchant (name, charge, period, minSum, bankName, swift, account) VALUES('Jim Smith Ltd.', 5.1, 1, 100.0, 'Chase Manhatten', 'AA245BXW', '247991002');

Слайд 21





Display Merchant Data
Описание слайда:
Display Merchant Data

Слайд 22





Create Customer Table
Customer Info
Name
Address
Email
Credit card No
Credit card type
Credit card maturity date
Описание слайда:
Create Customer Table Customer Info Name Address Email Credit card No Credit card type Credit card maturity date

Слайд 23





Create Customer Table
CREATE TABLE customer
(
   id INT NOT NULL GENERATED ALWAYS AS IDENTITY,
   name VARCHAR(60) NOT NULL,
   address VARCHAR(300) NOT NULL,
   email VARCHAR(90) NOT NULL,
   ccNo VARCHAR(20) NOT NULL,
   ccType VARCHAR(60) NOT NULL,
   maturity DATE,
   PRIMARY KEY (id)
);
Описание слайда:
Create Customer Table CREATE TABLE customer ( id INT NOT NULL GENERATED ALWAYS AS IDENTITY, name VARCHAR(60) NOT NULL, address VARCHAR(300) NOT NULL, email VARCHAR(90) NOT NULL, ccNo VARCHAR(20) NOT NULL, ccType VARCHAR(60) NOT NULL, maturity DATE, PRIMARY KEY (id) );

Слайд 24





Fill Customer Table
INSERT INTO customer
(name, address, email, ccNo, ccType, maturity)
    values('Dan Nelis',
	'Vosselaar st. 19, Trnaut, Belgium', 'Dan@adw.com', 
	'11345694671214', 
	'MasterCard', 
	'2014-07-31');
Описание слайда:
Fill Customer Table INSERT INTO customer (name, address, email, ccNo, ccType, maturity) values('Dan Nelis', 'Vosselaar st. 19, Trnaut, Belgium', 'Dan@adw.com', '11345694671214', 'MasterCard', '2014-07-31');

Слайд 25





Display Customer Data
select * from customer
Описание слайда:
Display Customer Data select * from customer

Слайд 26





Create Payment Table
Payment info
Date
Customer
Merchant
Goods description
Sum
Описание слайда:
Create Payment Table Payment info Date Customer Merchant Goods description Sum

Слайд 27





Create Payment Table
CREATE TABLE payment
(
   id INT NOT NULL GENERATED ALWAYS AS IDENTITY,
   dt TIMESTAMP NOT NULL,
   merchantId INT CONSTRAINT mer_fk references merchant,
   customerId INT CONSTRAINT cust_fk references customer,
   goods VARCHAR(500),
   total DECIMAL(15,2),
   charge DECIMAL(15,2),
   PRIMARY KEY (id)
);
Описание слайда:
Create Payment Table CREATE TABLE payment ( id INT NOT NULL GENERATED ALWAYS AS IDENTITY, dt TIMESTAMP NOT NULL, merchantId INT CONSTRAINT mer_fk references merchant, customerId INT CONSTRAINT cust_fk references customer, goods VARCHAR(500), total DECIMAL(15,2), charge DECIMAL(15,2), PRIMARY KEY (id) );

Слайд 28





Fill Payment Table
insert into payment
(dt, merchantId, customerId, goods, total)
values('2012-07-12 10:00:14', 3, 1, 
           'CD Europe Maps', 12.08);
Описание слайда:
Fill Payment Table insert into payment (dt, merchantId, customerId, goods, total) values('2012-07-12 10:00:14', 3, 1, 'CD Europe Maps', 12.08);

Слайд 29





Display Payment Data
Select * from payment
Описание слайда:
Display Payment Data Select * from payment

Слайд 30





CM Database Schema
Описание слайда:
CM Database Schema

Слайд 31





Select Statement
Don’t use * in select!
Описание слайда:
Select Statement Don’t use * in select!

Слайд 32





Select Statement
SELECT dt, merchantId, customerId, goods, total FROM payment WHERE merchantId = 3;
Описание слайда:
Select Statement SELECT dt, merchantId, customerId, goods, total FROM payment WHERE merchantId = 3;

Слайд 33





Select Statement
SELECT dt, merchantId, customerId, goods, total FROM payment WHERE merchantId = 3;
Описание слайда:
Select Statement SELECT dt, merchantId, customerId, goods, total FROM payment WHERE merchantId = 3;

Слайд 34





Select Statement
SELECT dt, merchantId, customerId, goods, total FROM payment ORDER BY merchantId;
Описание слайда:
Select Statement SELECT dt, merchantId, customerId, goods, total FROM payment ORDER BY merchantId;

Слайд 35





Select Statement
SELECT dt, merchantId, customerId, goods, total FROM payment ORDER BY merchantId;
Описание слайда:
Select Statement SELECT dt, merchantId, customerId, goods, total FROM payment ORDER BY merchantId;

Слайд 36





Select Statement
SELECT sum(total) FROM payment WHERE customerId = 2;
Описание слайда:
Select Statement SELECT sum(total) FROM payment WHERE customerId = 2;

Слайд 37





Select Statement
SELECT sum(total) FROM payment WHERE customerId = 2;
Output is 2134.45
Описание слайда:
Select Statement SELECT sum(total) FROM payment WHERE customerId = 2; Output is 2134.45

Слайд 38





Select Statement
SELECT merchantId, count(*) as n, sum(total) as total FROM payment GROUP BY merchantId;
Описание слайда:
Select Statement SELECT merchantId, count(*) as n, sum(total) as total FROM payment GROUP BY merchantId;

Слайд 39





Select Statement
SELECT merchantId, count(*) as n, sum(total) as total FROM payment GROUP BY merchantId;
Описание слайда:
Select Statement SELECT merchantId, count(*) as n, sum(total) as total FROM payment GROUP BY merchantId;

Слайд 40





Select Statement
SELECT customerId, sum(total) FROM payment GROUP BY customerId HAVING count(*)>2;
Описание слайда:
Select Statement SELECT customerId, sum(total) FROM payment GROUP BY customerId HAVING count(*)>2;

Слайд 41





Select Statement
SELECT customerId, sum(total) FROM payment GROUP BY customerId HAVING count(*)>2;
Описание слайда:
Select Statement SELECT customerId, sum(total) FROM payment GROUP BY customerId HAVING count(*)>2;

Слайд 42





Join Operations
SELECT p.dt, m.name as merchant, c.name as customer,   
          p.goods, p.total 
FROM payment p
     LEFT OUTER JOIN merchant m on m.id = p.merchantId
     LEFT OUTER JOIN customer c on c.id = p.customerId;
SELECT p.dt, m.name as merchant, c.name as customer, p.goods, p.total 
FROM payment p, merchant m, customer c
WHERE m.id = p.merchantId and c.id = p.customerId;
Описание слайда:
Join Operations SELECT p.dt, m.name as merchant, c.name as customer, p.goods, p.total FROM payment p LEFT OUTER JOIN merchant m on m.id = p.merchantId LEFT OUTER JOIN customer c on c.id = p.customerId; SELECT p.dt, m.name as merchant, c.name as customer, p.goods, p.total FROM payment p, merchant m, customer c WHERE m.id = p.merchantId and c.id = p.customerId;

Слайд 43





Join Operations
Описание слайда:
Join Operations

Слайд 44





Update Payments
Описание слайда:
Update Payments

Слайд 45





Update Statement
UPDATE payment SET charge = total * 0.034 WHERE id = 1;
Описание слайда:
Update Statement UPDATE payment SET charge = total * 0.034 WHERE id = 1;

Слайд 46





Update Statement
UPDATE payment SET charge = total * 0.034 WHERE id = 1;
Описание слайда:
Update Statement UPDATE payment SET charge = total * 0.034 WHERE id = 1;

Слайд 47





Update Statement
UPDATE payment 
	SET charge = (SELECT p.total * m.charge / 100.0 
                          FROM payment p, merchant m 
                          WHERE m.id = p.merchantId and p.id = 2) 
	WHERE id = 2;
Описание слайда:
Update Statement UPDATE payment SET charge = (SELECT p.total * m.charge / 100.0 FROM payment p, merchant m WHERE m.id = p.merchantId and p.id = 2) WHERE id = 2;

Слайд 48





Update Statement
Описание слайда:
Update Statement

Слайд 49





Update Statement
UPDATE payment p SET charge = total * (SELECT charge FROM merchant m WHERE m.id = p.merchantId) / 100.0
Описание слайда:
Update Statement UPDATE payment p SET charge = total * (SELECT charge FROM merchant m WHERE m.id = p.merchantId) / 100.0

Слайд 50





Update Statement
Описание слайда:
Update Statement

Слайд 51





Update Merchants
Описание слайда:
Update Merchants

Слайд 52





Update Merchants
UPDATE merchant m SET total = 
		(SELECT sum(total - charge) 
		 FROM payment  p WHERE p.merchantId=m.id)
Описание слайда:
Update Merchants UPDATE merchant m SET total = (SELECT sum(total - charge) FROM payment p WHERE p.merchantId=m.id)

Слайд 53





Update Merchants
Описание слайда:
Update Merchants

Слайд 54





Manuals
http://docs.oracle.com/javadb/10.8.2.2/ref/refderby.pdf
http://docs.oracle.com/javadb/10.8.2.2/devguide/derbydev.pdf
Описание слайда:
Manuals http://docs.oracle.com/javadb/10.8.2.2/ref/refderby.pdf http://docs.oracle.com/javadb/10.8.2.2/devguide/derbydev.pdf



Похожие презентации
Mypresentation.ru
Загрузить презентацию