Introduction to SQL 1 Lecture 5. Introduction to SQL 2 Note in different implementations the syntax might slightly differ different features might be.

Slides:



Advertisements
Similar presentations
TWO STEP EQUATIONS 1. SOLVE FOR X 2. DO THE ADDITION STEP FIRST
Advertisements

Slide 1 Insert your own content. Slide 2 Insert your own content.
Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill Technology Education Copyright © 2006 by The McGraw-Hill Companies,
Author: Graeme C. Simsion and Graham C. Witt Chapter 8 Organizing the Data Modeling Task.
Copyright: ©2005 by Elsevier Inc. All rights reserved. 1 Author: Graeme C. Simsion and Graham C. Witt Chapter 3 The Entity-Relationship Approach.
1 Copyright © 2010, Elsevier Inc. All rights Reserved Fig 2.1 Chapter 2.
1 Chapter 40 - Physiology and Pathophysiology of Diuretic Action Copyright © 2013 Elsevier Inc. All rights reserved.
By D. Fisher Geometric Transformations. Reflection, Rotation, or Translation 1.
Structured Query Language (SQL)
Database Design: Normalization J.G. Zheng June 29 th 2005 DB Chapter 4.
Relational Database and Data Modeling
Business Transaction Management Software for Application Coordination 1 Business Processes and Coordination.
1 Copyright © 2005, Oracle. All rights reserved. Introduction.
Jeopardy Q 1 Q 6 Q 11 Q 16 Q 21 Q 2 Q 7 Q 12 Q 17 Q 22 Q 3 Q 8 Q 13
Jeopardy Q 1 Q 6 Q 11 Q 16 Q 21 Q 2 Q 7 Q 12 Q 17 Q 22 Q 3 Q 8 Q 13
0 - 0.
ALGEBRAIC EXPRESSIONS
DIVIDING INTEGERS 1. IF THE SIGNS ARE THE SAME THE ANSWER IS POSITIVE 2. IF THE SIGNS ARE DIFFERENT THE ANSWER IS NEGATIVE.
MULTIPLYING MONOMIALS TIMES POLYNOMIALS (DISTRIBUTIVE PROPERTY)
ADDING INTEGERS 1. POS. + POS. = POS. 2. NEG. + NEG. = NEG. 3. POS. + NEG. OR NEG. + POS. SUBTRACT TAKE SIGN OF BIGGER ABSOLUTE VALUE.
MULTIPLICATION EQUATIONS 1. SOLVE FOR X 3. WHAT EVER YOU DO TO ONE SIDE YOU HAVE TO DO TO THE OTHER 2. DIVIDE BY THE NUMBER IN FRONT OF THE VARIABLE.
SUBTRACTING INTEGERS 1. CHANGE THE SUBTRACTION SIGN TO ADDITION
MULT. INTEGERS 1. IF THE SIGNS ARE THE SAME THE ANSWER IS POSITIVE 2. IF THE SIGNS ARE DIFFERENT THE ANSWER IS NEGATIVE.
Addition Facts
Year 6 mental test 10 second questions Numbers and number system Numbers and the number system, fractions, decimals, proportion & probability.
Relational data objects 1 Lecture 6. Relational data objects 2 Answer to last lectures activity.
Introduction to Relational Database Systems 1 Lecture 4.
Views-basics 1. 2 Introduction a view is a perspective of the database different users may need to see the database differently; this is achieved through.
Active database concepts
Relational operators 1 Lecture 7 Relational Operators.
Relational data integrity
Normal forms - 1NF, 2NF and 3NF
1 Term 2, 2004, Lecture 6, Views and SecurityMarian Ursu, Department of Computing, Goldsmiths College Views and Security 3.
1 Term 2, 2004, Lecture 9, Distributed DatabasesMarian Ursu, Department of Computing, Goldsmiths College Distributed databases 3.
Data Definition and Integrity Constraints
Dr. Alexandra I. Cristea CS 252: Fundamentals of Relational Databases: SQL5.
ZMQS ZMQS
SQL: The Query Language Part 2
Information Systems Today: Managing in the Digital World
ABC Technology Project
Chapter 5 Normalization of Database Tables
© Abdou Illia MIS Spring 2014
ER to Relational Mapping. Logical DB Design: ER to Relational Entity sets to tables. CREATE TABLE Employees (ssn CHAR (11), name CHAR (20), lot INTEGER,
R ELATIONAL M ODEL TO SQL Data Model. 22 C ONCEPTUAL D ESIGN : ER TO R ELATIONAL TO SQL How to represent Entity sets, Relationship sets, Attributes, Key.
Chapter 7 © 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 Modern Database Management 11 th Edition Jeffrey A. Hoffer, V. Ramesh, Heikki Topi.
Microsoft Office Illustrated Fundamentals Unit K: Working with Data.
Chapter Information Systems Database Management.
State of Connecticut Core-CT Project Query 8 hrs Updated 6/06/2006.
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.
© S Haughton more than 3?
8 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Using Explicit Cursors.
Twenty Questions Subject: Twenty Questions
Linking Verb? Action Verb or. Question 1 Define the term: action verb.
Energy & Green Urbanism Markku Lappalainen Aalto University.
Relational Database Design Via ER Modelling
Past Tense Probe. Past Tense Probe Past Tense Probe – Practice 1.
Fundamentals of Database Systems Fourth Edition El Masri & Navathe
1 First EMRAS II Technical Meeting IAEA Headquarters, Vienna, 19–23 January 2009.
Functional Dependencies and Normalization for Relational Databases
Addition 1’s to 20.
25 seconds left…...
Test B, 100 Subtraction Facts
11 = This is the fact family. You say: 8+3=11 and 3+8=11
Week 1.
We will resume in: 25 Minutes.
Chapter 15 A Table with a View: Database Queries.
1 Unit 1 Kinematics Chapter 1 Day
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Huiswerk Lees delen 3.2, 3.3 van hoofdstuk 3. opgaven voor hoofdstuk 2: modelleeropgave 5.
Introduction –All information systems create, read, update and delete data. This data is stored in files and databases. Files are collections of similar.
SE305 Database System Technology 23/10/2014 Quiz-2.
Presentation transcript:

Introduction to SQL 1 Lecture 5

Introduction to SQL 2 Note in different implementations the syntax might slightly differ different features might be available in certain implementations non-relational operators might be supported certain relational operations might not be possible to be performed

Introduction to SQL 3 Operations create table restrict, project and join (via SELECT) insert, update, delete create view, query view

Introduction to SQL 4 CREATE TABLE CREATE TABLE Depts ( Dept_idCHAR(2), Dept_nameCHAR(20), BudgetDECIMAL(8), PRIMARY KEY (Dept_id));

Introduction to SQL 5 CREATE TABLE CREATE TABLE Emps ( E_idCHAR(2), E_nameCHAR(20), Dept_idCHAR(2), SalaryDECIMAL(5), PRIMARY KEY (E_id), FOREIGN KEY (Dept_id) REFERENCES Depts);

Introduction to SQL 6 restrict (via SELECT) SELECT ( E_id, E_name, Dept_id, Salary ) FROM Emps WHERE Salary > 33000;

Introduction to SQL 7 project (via SELECT) SELECT ( E_name, Salary ) FROM Emps ;

Introduction to SQL 8 join (via SELECT) SELECT ( Depts.Dept_id, Dept_name, Budget, E_id, E_name, Salary ) FROM Emps, Depts WHERE Depts.Dept_id = Emps.Dept_id ;

Introduction to SQL 9 restrict, project and join (via SELECT) SELECT ( Dept_name, E_name, Salary ) FROM Emps, Depts WHERE Depts.Dept_id = Emps.Dept_id AND Salary > 33000;

Introduction to SQL 10 INSERT single row INSERT INTO Emps ( E_id, E_name, Dept_id, Salary ) VALUES ( E1, Smith, D1, ) ;

Introduction to SQL 11 INSERT multiple rows INSERT INTO Temp (Id, Name, Salary ) SELECT ( E_id, E_name, Salary) FROM Emps WHERE Salary > 33000; CREATE TABLE Temp ( IdCHAR(2), NameCHAR(20), SalaryDECIMAL(5), PRIMARY KEY (Id) );

Introduction to SQL 12 UPDATE UPDATE Emps SET Salary = Salary WHERE Salary < 40000;

Introduction to SQL 13 DELETE FROM Depts WHERE Budget < ;

Introduction to SQL 14 CREATE VIEW CREATE VIEW All_emps AS SELECT (Dept_name, E_name, Salary) FROM Depts, Emps WHERE Depts.Dept_id = Emps.Dept_id

Introduction to SQL 15 query a view SELECT ( E_name, Salary ) FROM All_emps WHERE Salary < 40000

Introduction to SQL 16 Intermediate conclusion you now know a small set of operators by means of which you can create, query and modify a database; you can now implement your own database (even though, it probably will be far from a good design)

Introduction to SQL 17 Activity A4 You are the database administrator of your company. Your company is supplied with different parts by a set of supplying companies. You need to create and maintain a database with information about the supplied parts and the supplying companies. 1. given the ER (entity relationship) diagram, identify the attributes of each entity (NOTE: treat the relationship as an entity, i.e. find its attribute(s)) 2. design the corresponding tables 3. write the data definition statements in SQL

Introduction to SQL 18 ER for the suppliers-parts problem SupplierParts Contracted

Introduction to SQL 19 Conclusion summary introduction to database systems introduction to the relational model introduction to SQL from next lecture the relational model