Relational Oracle 11g Tutorial Νίκος Πελέκης Εργαστήριο Πληροφοριακών Συστημάτων, Τμήμα Πληροφορικής, Πανεπιστήμιο Πειραιώς

Slides:



Advertisements
Similar presentations
Database Design Examples-1 22/03/ step design Conceptual Design Highest level design Issues: data types, relationships, constraints Uses ER model.
Advertisements

SQL Lecture 10 Inst: Haya Sammaneh. Example Instance of Students Relation  Cardinality = 3, degree = 5, all rows distinct.
Data Design The futureERD - CardinalityCODINGRelationshipsDefinition.
Accounting System Design
Chapter 12 Information Systems Chapter Goals Define the role of general information systems Explain how spreadsheets are organized Create spreadsheets.
CSE 190: Internet E-Commerce Lecture 10: Data Tier.
Murali Mani SQL DDL and Oracle utilities. Murali Mani Datatypes in SQL INT (or) INTEGER FLOAT (or) REAL DECIMAL (n, m) CHAR (n) VARCHAR (n) DATE, TIME.
Chapter 12 Information Systems Nell Dale John Lewis.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 4-1 David M. Kroenke Database Processing Chapter 7 Structured Query Language.
Data Model Examples USER SPECIFICATIONS.
Chapter 12 Information Systems. 2 Chapter Goals Define the role of general information systems Explain how spreadsheets are organized Create spreadsheets.
DAT702.  Standard Query Language  Ability to access and manipulate databases ◦ Retrieve data ◦ Insert, delete, update records ◦ Create and set permissions.
Database Systems Lecture 5 Natasha Alechina
Chapter 12 Information Systems. Spreadsheets Databases 12-2.
Oracle Data Definition Language (DDL)
CIS 270—App Dev II Big Java Chapter 22 Relational Databases.
More on E-R Diagrams After this lecture, you should be able to:
Chapter 5 Database Processing.
A Guide to SQL, Eighth Edition Chapter Three Creating Tables.
Object-Relational Oracle 11g Tutorial Νίκος Πελέκης Εργαστήριο Πληροφοριακών Συστημάτων, Τμήμα Πληροφορικής, Πανεπιστήμιο Πειραιώς
ASP.NET Programming with C# and SQL Server First Edition
C H A P T E R 4 Designing Database E-Commerce Hassanin M. Al-Barhamtoshy
PL/SQLPL/SQL Oracle10g Developer: PL/SQL Programming Chapter 11 Introduction to Dynamic SQL and Object Technology.
Irwin/McGraw-Hill Copyright © 2000 The McGraw-Hill Companies. All Rights reserved Whitten Bentley DittmanSYSTEMS ANALYSIS AND DESIGN METHODS5th Edition.
Databases in Visual Studio. Database in VisualStudio An MS SQL database are built in Visual studio The Name can be something like ”(localdb)\Projects”
Introduction to SQL Steve Perry
Your Name Here See Page Notes for Info about Hyperlinks.
SQL – Part II Yong Choi School of Business CSU, Bakersfield.
Copyright  Oracle Corporation, All rights reserved. 4 CMIS Powell Oracle Designer: Creating the Database Design CMIS Powell.
MIS 301 Information Systems in Organizations Dave Salisbury ( )
Oracle Data Definition Language (DDL) Dr. Bernard Chen Ph.D. University of Central Arkansas Fall 2008.
Dr. Chen, Business Database Systems JustLee DataBase Referential Integrity Jason C. H. Chen, Ph.D. Professor of MIS School of Business Administration Gonzaga.
Slide 1 Chapter 7 – Part 1 Data Definition Language & Data Manipulation Language.
Chapter 5 Database Processing. Neil uses software to query a database, but it has about 25 standard queries that don’t give him all he needs. He imports.
Customer Order Order Number Date Cust ID Last Name First Name State Amount Tax Rate Product 1 ID Product 1 Description Product 1 Quantity Product 2 ID.
SQL Basics. 5/27/2016Chapter 32 of 19 Naming SQL commands are NOT case sensitive SQL commands are NOT case sensitive But user identifier names ARE case.
FEN Introduction to the database field:  The Relational Model Seminar: Introduction to relational databases.
CS 1308 Computer Literacy and the Internet
Forms and Subforms 5.02 Understand database queries, forms, and reports used in business.
MySQL and JDBC Tutorial ECT 7130 Hong Cheng. Supplement on MySQL ement/Supplement4bMySQL.pdf.
IBS 520 Introduction to Internet Technology Database Fundamentals Week 4.
Visual Programing SQL Overview Section 1.
IMS 4212: Data Manipulation 1 Dr. Lawrence West, MIS Dept., University of Central Florida Additional Data Manipulation Statements INSERT.
SQL John Nowobilski. What is SQL? Structured Query Language Manages Data in Database Management Systems based on the Relational Model Developed in 1970s.
SQL Jan 20,2014. DBMS Stores data as records, tables etc. Accepts data and stores that data for later use Uses query languages for searching, sorting,
COMP3030 Database Management System Final Review
Agenda for Class 2/02/2006 Finish discussing constraints generated with the CREATE TABLE statement. Discuss DROP statement. Discuss INSERT, COMMIT, DELETE,
1 MySQL and SQL. 2 Topics  Introducing Relational Databases  Terminology  Managing Databases MySQL and SQL.
* Database is a group of related objects * Objects can be Tables, Forms, Queries or Reports * All data reside in Tables * A Row in a Table is a record.
Chapter 3: Relational Databases
Oracle Developer. Create Table SQL> create table catalog ( 2 cno varchar2(7), 3 ctitle varchar2(50), 4 primary key (cno)); Table created. SQL> describe.
Database Design lecture 3_2 Slide 1 Database Design Lecture 3_2 Data Manipulation in SQL Simple SQL queries References: Text Chapter 8 Oracle SQL Manual.
Data generators by Jan Kincl. Data Generators - Jan Kincl2 Outline Introduction Introduction Main features Main features MySQL Data Generators MySQL Data.
SAN DIEGO SUPERCOMPUTER CENTER Introduction to Database Design July 2006 Ken Nunes sdsc.edu.
Let try to identify the conectivity of these entity relationship
CS SQL.
Chapter 12 Information Systems.
Accounting System Design
Teaching slides Chapter 8.
5.02 Understand database queries, forms, and reports used in business.
RELATIONAL DATABASES AND XML
Data generators by Jan Kincl.
SQL DATA CONSTRAINTS.
Accounting System Design
Oracle Data Definition Language (DDL)
Introduction to Database Design
SALES RECEIPT Downloaded from
INVOICE Downloaded from
The University of Akron College of Applied Science & Technology Dept
MIS2502: Data Analytics Relational Data Modeling 3
Presentation transcript:

Relational Oracle 11g Tutorial Νίκος Πελέκης Εργαστήριο Πληροφοριακών Συστημάτων, Τμήμα Πληροφορικής, Πανεπιστήμιο Πειραιώς

Outline of seminar Part II  Introduction to Oracle Relational  Creating a schema  Connecting to Oracle  Bulk loading using SQLloader  A Sample Application Using Relational Features 2

Creating your schema 3 EM at UNIPI: SID= ORCL Server name=KITTIE User “DMUSERX” password=userX

Connecting to Oracle 4

Bulk loading using SQLloader CREATE TABLE trucks_final (obj_id NUMBER(*,0), id NUMBER(*,0), t_day NUMBER(*,0), t_month NUMBER(*,0), t_year NUMBER(*,0), t_hour NUMBER(*,0), t_min NUMBER(*,0), t_sec NUMBER(*,0), lat NUMBER(*,10), lon NUMBER(*,10), x NUMBER(*,10), y NUMBER(*,10)) PCTFREE 10 INITRANS 1 MAXTRANS 255 TABLESPACE users STORAGE ( INITIAL MINEXTENTS 1 MAXEXTENTS ) 6

Bulk loading using SQLloader 7 Download “ Trucks.ctl” from 0Tutorials/SQLloader/ 0Tutorials/SQLloader/ sqlldr control=Trucks.ctl log=log.txt Access table from SQLDeveloper Do the following queries:  How many records does the “ trucks_final” table has?  Where was I at “10/09/2002 – 09:15:59”?  How many days was I travelling?

E-R Diagram for Purchase Order Application 8

Purchase Order Application The figure shows the entity relationships among the following four relational entities or tables:  Customer  Purchase Order  Line Item of a purchase order  Stock Item A customer places zero or more purchase orders, but a purchase order has at most one customer. A purchase order can contain many line items, but a given line item occurs on exactly one purchase order. Each line item refers to exactly one stock item; a stock item can occur in zero or many different line items. 9

Creating Tables Under the Relational Model CREATE TABLE Customer_reltab ( CustNo NUMBER NOT NULL, CustName VARCHAR2(200) NOT NULL, Street VARCHAR2(200) NOT NULL, City VARCHAR2(200) NOT NULL, State CHAR(2) NOT NULL, Zip VARCHAR2(20) NOT NULL, Phone1 VARCHAR2(20), Phone2 VARCHAR2(20), Phone3 VARCHAR2(20), PRIMARY KEY (CustNo)); 10

Creating Tables Under the Relational Model CREATE TABLE PurchaseOrder_reltab ( PONo NUMBER, /* purchase order no */ Custno NUMBER references Customer_reltab, /* Foreign KEY referencing customer */ OrderDate DATE, /* date of order */ ShipDate DATE, /* date to be shipped */ ToStreet VARCHAR2(200), /* shipto address */ ToCity VARCHAR2(200), ToState CHAR(2), ToZip VARCHAR2(20), PRIMARY KEY(PONo)); 11

Creating Tables Under the Relational Model CREATE TABLE Stock_reltab ( StockNo NUMBER PRIMARY KEY, Price NUMBER, TaxRate NUMBER); CREATE TABLE LineItems_reltab ( LineItemNo NUMBER, PONo NUMBER REFERENCES PurchaseOrder_reltab, StockNo NUMBER REFERENCES Stock_reltab, Quantity NUMBER, Discount NUMBER, PRIMARY KEY (PONo, LineItemNo)); 12

Inserting Values Under the Relational Model INSERT INTO Stock_reltab VALUES(1004, , 2); INSERT INTO Stock_reltab VALUES(1011, , 2); INSERT INTO Stock_reltab VALUES(1534, , 2); INSERT INTO Stock_reltab VALUES(1535, , 2); INSERT INTO Customer_reltab VALUES (1, 'Jean Nance', '2 Avocet Drive', 'Redwood Shores', 'CA', '95054', ' ', NULL, NULL); INSERT INTO Customer_reltab VALUES (2, 'John Nike', '323 College Drive', 'Edison', 'NJ', '08820', ' ', ' ', NULL); INSERT INTO PurchaseOrder_reltab VALUES (1001, 1, SYSDATE, '10/05/1997', NULL, NULL, NULL, NULL); INSERT INTO PurchaseOrder_reltab VALUES (2001, 2, SYSDATE, '20/05/1997', '55 Madison Ave', 'Madison', 'WI', '53715'); INSERT INTO LineItems_reltab VALUES(01, 1001, 1534, 12, 0); INSERT INTO LineItems_reltab VALUES(02, 1001, 1535, 10, 10); INSERT INTO LineItems_reltab VALUES(01, 2001, 1004, 1, 0); INSERT INTO LineItems_reltab VALUES(02, 2001, 1011, 2, 1); 13

Get Customer and Line Item Data for a Specific Purchase Order SELECT C.CustNo, C.CustName, C.Street, C.City, C.State, C.Zip, C.phone1, C.phone2, C.phone3, P.PONo, P.OrderDate, L.StockNo, L.LineItemNo, L.Quantity, L.Discount FROM Customer_reltab C, PurchaseOrder_reltab P, LineItems_reltab L WHERE C.CustNo = P.CustNo AND P.PONo = L.PONo AND P.PONo = 1001; 14

Get the Total Value of Purchase Orders SELECT P.PONo, SUM(S.Price * L.Quantity) FROM PurchaseOrder_reltab P, LineItems_reltab L, Stock_reltab S WHERE P.PONo = L.PONo AND L.StockNo = S.StockNo GROUP BY P.PONo; 15

Get the Purchase Order and Line Item Data for Stock Item 1004 SELECT P.PONo, P.CustNo, L.StockNo, L.LineItemNo, L.Quantity, L.Discount FROM PurchaseOrder_reltab P, LineItems_reltab L WHERE P.PONo = L.PONo AND L.StockNo = 1004; 16

Update – Delete statements UPDATE LineItems_reltab SET Quantity = 20 WHERE PONo = 1001 AND StockNo = 1534; DELETE FROM LineItems_reltab WHERE PONo = 1001; DELETE FROM PurchaseOrder_reltab WHERE PONo = 1001; 17

Υλικό Tutorials at UNIPI: Tutorials at OTN: SQL Developer: db_otn.htm EM at UNIPI:  SID= ORCL  Server name=KITTIE  User “DMUSERX” password=userX Oracle download: Video tutorials: tutorials.htm# 18

19 Νίκος Πελέκης Επικοινωνία University of Piraeus, Information Systems Laboratory Zeas Str., Piraeus, Greece 3rd Floor Phone: (+30)