ISO6 Relational Databases Simon Booth Room Library S6 Tel: 7247.

Slides:



Advertisements
Similar presentations
Creating Tables. 2 home back first prev next last What Will I Learn? List and provide an example of each of the number, character, and date data types.
Advertisements

Microsoft Excel 2003 Illustrated Complete Excel Files and Incorporating Web Information Sharing.
Copyright  Oracle Corporation, All rights reserved. 10 Creating and Managing Tables.
Introduction To SQL Lynnwood Brown President System Managers LLC Copyright System Managers LLC 2003 all rights reserved.
Let’s try Oracle. Accessing Oracle The Oracle system, like the SQL Server system, is client / server. For SQL Server, –the client is the Query Analyser.
Writing Basic SQL statement 2 July July July Create By Pantharee Sawasdimongkol.
Chapter 4 Relational Databases Copyright © 2012 Pearson Education 4-1.
Introduction to DBMS and SQL Introduction to DBMS and SQL GUIDED BY : MR. YOGESH SAROJ (PGT-CS) MR. YOGESH SAROJ (PGT-CS) Presented By : JAYA XII –COM.
Session 5: Working with MySQL iNET Academy Open Source Web Development.
Copyright © 2003 by Prentice Hall Module 4 Database Management Systems 1.What is a database? Data hierarchy and data organization Field, record, file,
Copyright © 2003 by Prentice Hall Computers: Tools for an Information Age Chapter 13 Database Management Systems: Getting Data Together.
ASP.NET Programming with C# and SQL Server First Edition
PHP Programming with MySQL Slide 8-1 CHAPTER 8 Working with Databases and MySQL.
Database Technical Session By: Prof. Adarsh Patel.
Introduction to SQL Steve Perry
Chapter 7 Working with Databases and MySQL PHP Programming with MySQL 2 nd Edition.
1 Working with MS SQL Server Textbook Chapter 14.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 Working with MSSQL Server Code:G0-C# Version: 1.0 Author: Pham Trung Hai CTD.
Database Fred Durao What is a database? A database is any organized collection of data. Some examples of databases you may encounter in.
1 Theory, Practice & Methodology of Relational Database Design and Programming Copyright © Ellis Cohen Introduction to Relational Databases &
Chapter 6 Database Administration
Using Special Operators (LIKE and IN)
Unit 6 Data Storage Design. Key Concepts 1. Database overview 2. SQL review 3. Designing fields 4. Denormalization 5. File organization 6. Object-relational.
ACTION QUERIES (SQL COMMANDS ) STRUCTURED QUERY LANGUAGE.
1 Information Retrieval and Use (IRU) CE An Introduction To SQL Part 1.
SQL FUNDAMENTALS SQL ( Structured Query Language )
“INTRODUCTION TO DATABASE AND SQL”. Outlines 2  Introduction To Database  Database Concepts  Database Properties  What is Database Management System.
Instructor: Dema Alorini Database Fundamentals IS 422 Section: 7|1.
Lecture2: Database Environment Prepared by L. Nouf Almujally 1 Ref. Chapter2 Lecture2.
Oracle 11g DATABASE DEVELOPMENT LAB1. Introduction  Oracle 11g Database:-  Oracle 11g database is designed for some features, which helps to the organizations.
Databases. What is a database?  A database is used to store data. The word DATA is actually Latin for FACTS. A database is, therefore, a place, or thing.
Lecture # 3 & 4 Chapter # 2 Database System Concepts and Architecture Muhammad Emran Database Systems 1.
6 1 Lecture 8: Introduction to Structured Query Language (SQL) J. S. Chou, P.E., Ph.D.
Database Management COP4540, SCS, FIU Structured Query Language (Chapter 8)
SQL SeQueL -Structured Query Language SQL SQL better support for Algebraic operations SQL Post-Relational row and column types,
Database Concepts Track 3: Managing Information using Database.
SQL CREATING AND MANAGING TABLES lecture4 1. Database Objects ObjectDescription TableBasic unit of storage; composed of rows and columns ViewLogically.
Copyright  Oracle Corporation, All rights reserved. 12 Creating Views.
An Introduction To SQL Part 2 (Special thanks to Geoff Leese)
1 Information Retrieval and Use (IRU) An Introduction To SQL Part 2.
9-1 © Prentice Hall, 2007 Topic 9: Physical Database Design Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,
Starting with Oracle SQL Plus. Today in the lab… Connect to SQL Plus – your schema. Set up two tables. Find the tables in the catalog. Insert four rows.
Copyright س Oracle Corporation, All rights reserved. 12 Creating Views.
SQL Introduction to database and SQL. Chapter 1: Databases and Database Users 6 Introduction to Databases Databases touch all aspects of our lives. Examples:
11-1 © Prentice Hall, 2004 Chapter 11: Physical Database Design Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,
SQL: Structured Query Language It enables to create and operate on relational databases, which are sets of related information stored in tables. It is.
LECTURE TWO Introduction to Databases: Data models Relational database concepts Introduction to DDL & DML.
1 Section 1 - Introduction to SQL u SQL is an abbreviation for Structured Query Language. u It is generally pronounced “Sequel” u SQL is a unified language.
Concepts of Database Management, Fifth Edition Chapter 3: The Relational Model 2: SQL.
1 ORACLE I 3 – SQL 1 Salim Phone: YM: talim_bansal.
Data Resource Management Data Concepts Database Management Types of Databases Chapter 5 McGraw-Hill/Irwin Copyright © 2007 by The McGraw-Hill Companies,
Copyright س Oracle Corporation, All rights reserved. 1 Writing Basic SQL Statements.
SQL and SQL*Plus Interaction
Prepared by : Moshira M. Ali CS490 Coordinator Arab Open University
SQL Creating and Managing Tables
Subqueries.
Subqueries Schedule: Timing Topic 25 minutes Lecture
Aggregating Data Using Group Functions
Writing Correlated Subqueries
ORACLE SQL Developer & SQLPLUS Statements
SQL Creating and Managing Tables
Chapter 8 Working with Databases and MySQL
What Is a View? EMPNO ENAME JOB EMP Table EMPVU10 View
SQL Creating and Managing Tables
Aggregating Data Using Group Functions
Using SQL*Plus.
Subqueries Schedule: Timing Topic 25 minutes Lecture
Subqueries Schedule: Timing Topic 25 minutes Lecture
Presentation transcript:

ISO6 Relational Databases Simon Booth Room Library S6 Tel: 7247

PF Lecture 1 2 Course Aims Develop a basic proficiency in A relational database environment The SQL database language – Oracle SQL*Plus A forms-based 4GL programming tool – Access 97 Database design and Management

PF Lecture 1 3 Lectures and Workshops Lectures (A1)  Monday Workshop (2A19)  Monday 14-16

PF Lecture 1 4 Applications and Books SQL Plus Oracle 3.3/8.0 Oracle 8 database Access 97 Database Design and Management by Nick Dowling (Letts) £10.99

PF Lecture 1 5 Proposed Course Structure First half – SQL Plus version 3.3/8.0 running against Oracle 8 Second half – Access 97 Lecture on Monday – practical issues on the upcoming workshops

PF Lecture 1 6 Database Management Systems (DBMS) Definition “ A set of programs that act as an interface between application programs and the data in the database”

PF Lecture 1 7 users/programmers Software to process Queries/Programs Software to access Stored Data A Simplified Database System Environment Application Programs/Queries Database System DBMS Software Stored Database Definition (Meta-Data) Stored Database

PF Lecture primary functions of a DBMS Define, create and organize a database (Data Definition Language) Input data Process data (Data Manipulation Language) Maintain Data integrity and security Query database (Structured Query Language)

PF Lecture 1 9 Advantages of DBMS Data independence  Access to data based on its contents and its associations with other data Physical organization of data is independent of program using it Reduction in data redundancy Accessing and processing data more effective DATA users

PF Lecture 1 10 Disadvantages of DBMS Cost is the primary disadvantage Mainframe hardware expensive Even expensive with PC based databases  Licences  Training  Maintenance and Management

PF Lecture 1 11 Database Infrastructures Hierarchical Network Relational

PF Lecture 1 12 Hierarchical ROOT Father Son 2Son 1

PF Lecture 1 13 Network Owner Member

PF Lecture 1 14 Relational Model

PF Lecture 1 15 Structured Query Language (SQL) Programming language (4GL) Data definition and data manipulation language Used in all types of database applications Oracle and Access

PF Lecture 1 16 SQL (cont.) Provided a degree of homogeneity Industry standard Databases conforming to the SQL standard can also use applications from other SQL databases SQL standards approved by ANSI Incorporating SQL technology provides a strong selling point

PF Lecture 1 17 SQL Plus (Sequel Plus) SQL*Plus is a program for working with an ORACLE database  Create tables  Store information in the tables  Retrieve information in a form you choose, performing calculations on it and combining it in new ways  Maintain the database

Querying & Manipulating Databases Using SQL*Plus

PF Lecture 1 19 Accessing SQL*Plus 3.3 To access Oracle SQL*Plus you must first log-on in the normal way. In Windows NT go to START, PROGRAMS, ORACLE, ORACLE WinNT, SQL Plus 3.3.

PF Lecture 1 20 Accessing SQL Enter your oracle username and password. You will also be asked for a ‘host string’ enter ora1a11

PF Lecture 1 21 Accessing SQL Having entered these, you will then see the SQL prompt from Oracle: SQL> You are now ready to type SQL commands

PF Lecture 1 22 Accessing SQL SQL>SELECT job FROM emp 2 Note: Oracle itself is not case- sensitive. I have used a mixture of upper and lower case to indicate SQL commands (uppercase) and the components I select (lowercase)

PF Lecture 1 23 Accessing SQL SQL>SELECT job FROM emp 2 Note: Oracle inserts the “2” to indicate that we are on the second line. To properly terminate the command, enter ;. Oracle will now process the command.

PF Lecture 1 24 A table ArtistTitleFormat VerveUrban HymnsCD OasisBe Here NowCassette RadioheadBendsCD The above is a table named called “music” with three columns: Artist, Title and Format. There are presently three rows.

PF Lecture 1 25 The Select command To list the columns Artist and Format from the table music: SQL> SELECT artist, format FROM music;

PF Lecture 1 26 The WHERE clause We can select based on rows that meet a certain condition. For instance, only CD’s: SQL> SELECT * FROM music 2 WHERE format LIKE ‘CD’; * means all columns

PF Lecture 1 27 The WHERE clause(2) Another Example: SQL> SELECT ename, deptno, sal 2 FROM emp 3 WHERE sal >= 1500; Columns are listed in the order they appear and can appear more than once

PF Lecture 1 28 The ORDER BY clause Oracle will list back the information we ask in order it appears in the table. If we want it alphabetically or by numerical order we must add an ORDER BY and specify the column(s) to order by.

PF Lecture 1 29 The ORDER BY clause(2) Example: SQL> SELECT ename, deptno, sal 2 FROM emp 3 ORDER BY sal DESC;

PF Lecture 1 30 SQL Group Functions These functions (AVG, MAX, MIN, etc) can act on entire tables or subsets of the table SELECT AVG(sal) FROM emp; SELECT MAX(sal) FROM emp WHERE job = ‘MANAGER’; SELECT COUNT(*) FROM emp WHERE deptno = 20;

PF Lecture 1 31 GROUP BY Group functions can also be used with the GROUP BY clause, which splits the table into specified groups, returning one row for each group SELECT AVG(sal), deptno FROM emp GROUP BY deptno;

PF Lecture 1 32 Clauses Clauses can be combined: SQL> SELECT ename, deptno, sal 2 FROM emp 3 WHERE sal > ORDER BY sal DESC;

PF Lecture 1 33 Second example Rows maybe selected by WHERE SELECT AVG(sal), deptno FROM emp WHERE job != ‘MANAGER’ GROUP BY deptno;

PF Lecture 1 34 Update The SQL command update is used to modify all or some rows in the table: UPDATE table SET column = expr [, column = expr] [WHERE condition];

PF Lecture 1 35 Update Example: correct name for employee 7369 UPDATE emp SET ename = ‘jones’ WHERE empno = 7369;

PF Lecture 1 36 Delete The SQL command delete is used to remove all or some rows in the table: DELETE FROM table [WHERE condition];

PF Lecture 1 37 Delete Example: remove employee 7369 DELETE FROM emp WHERE empno = 7369;

PF Lecture 1 38 Copying Tables We can copy tables existing tables: CREATE TABLE stolen_table AS SELECT * FROM another_table;

PF Lecture 1 39 Creating Tables(2) If we only want specific columns, we name them in the select; If we only want specific rows, we use a WHERE clause: CREATE TABLE stolen_table AS SELECT video_no, title FROM video WHERE title = ‘T%’;

PF Lecture 1 40 Populating Tables To place data in a table we use the INSERT command: INSERT INTO table [(column-name, …)] VALUES (value, … ); Which adds one row to the table. To add more, we have more INSERT commands

PF Lecture 1 41 Populating Tables Examples: INSERT INTO dept (deptno, dname) VALUES (50, ‘Marketing’); INSERT INTO dept VALUES (50, ‘Marketing’, ‘Stirling’);

PF Lecture 1 42 Summary of SQL commands SQL  SELECT  UPDATE  DELETE  CREATE AS  INSERT