1 Exercises of SQL uAnswer the following questions, based on the database below. wSupplier (SNO, SNAME, STATUS, CITY) wPart(PNO, PNAME, COLOR, WEIGHT)

Slides:



Advertisements
Similar presentations
COP4540 Database Management System Midterm Review
Advertisements

1 Design Process - Where are we? Conceptual Design Conceptual Schema (ER Model) Logical Design Logical Schema (Relational Model) Step 1: ER-to-Relational.
Database Languages Chapter 7. The Relational Algebra.
Unit 5 The Network Model  5.1 The Network Model  5.2 IDMS.
DATA MODELS A collection of conceptual tools for describing data, data relationships, data semantics, and consistency constraints. Provide a way to describe.
The Hierarchical Model
 Definition  Components  Advantages  Limitations Contents  Definition Definition  Normal Forms Normal Forms  First Normal Form First Normal Form.
Database Administration, Integrity and Performance.
Chapter 3 An Introduction to Relational Databases.
N-dimensional space navigation is only possible in a logical rather han a physical world. They didn’t have any books to look after - their information.
SQL components In Oracle. SQL in Oracle SQL is made up of 4 components: –DDL Data Definition Language CREATE, ALTER, DROP, TRUNCATE. Creates / Alters.
1 SQL Authorization Privileges Grant and Revoke Grant Diagrams.
Security and Transaction Management Pertemuan 8 Matakuliah: T0413/Current Popular IT II Tahun: 2007.
Dec 15, 2003Murali Mani Transactions and Security B term 2004: lecture 17.
Cs3431 Transactions, Logging and Security. cs3431 Transactions: What and Why? A set of operations on a database must appear as one “unit”. Example: Consider.
1 Rewriting Intersect Queries Using In SELECT S.sid FROM Sailors S, Boats B, Reserves R WHERE S.sid = R.sid and R.bid = B.bid and B.color = ‘red’ INTERSECT.
Domains, Relations & Base RelVars (Ch
Database Principles Relational Database Design I.
Data Manipulation 11 After this lecture, you should be able to:  Understand the differences between SQL (Structured Query Language) and other programming.
6.8 Case Study: E-R for Supplier-and-Parts Database
Constraints  Constraints are used to enforce rules at table level.  Constraints prevent the deletion of a table if there is dependencies.  The following.
1 Structured Query Language (SQL) CIS*2450 Advanced Programming Concepts.
Logical Database Design ( 補 ) Unit 7 Logical Database Design ( 補 )
Chapter 10 Views. Topics in this Chapter What are Views For? View Retrievals View Updates Snapshots SQL Facilities.
Database Management COP4540, SCS, FIU Constraints and security in SQL (Ch. 8.6, Ch22.2)
Further Normalization I
1-1 Homework 3 Practical Implementation of A Simple Rational Database Management System.
Data Definition After this lecture, you should be able to:
CS 1308 Computer Literacy and the Internet
June 23, 2001Database Creation Review and Exercises1 Database Creation Review 10: :30 Team Building Exercise ……………………….. John 10: :30 Database.
Lecture No 14 Functional Dependencies & Normalization ( III ) Mar 04 th 2011 Database Systems.
Data Manipulation 21 After this lecture, you should be able to:  Use SQL SELECT statement effectively to retrieve the data from multiple related tables.
Unit 5 The Network Model  5.1 Data Modeling Issues  5.2 The Network Model  5.3 IDMS.
Algebra1 After this lecture, you should be able to:  Understand the differences between SQL (Structured Query Language) and Relational Algebra expressions.
© Pearson Education Limited, Normalization Bayu Adhi Tama, M.T.I. Faculty of Computer Science University of Sriwijaya.
A Framework for Testing Database Application Author: David Chays, Saikat Dan, Filippos I. Vokolos, Elaine J. Weyuker Presenter: Liping Liu.
Database Systems Conceptual to Relational Modeling II Lecture # 11 Feb 25 th 2011.
ADVANCED TOPICS IN RELATIONAL DATABASES Spring 2011 Instructor: Hassan Khosravi.
1 Access control. 2 GRANT statement 3 Access control GRANT statement GRANT statement may be used by a user to authorise various kinds of access to his/her.
COMP3030 Database Management System Final Review
Chapter 4 An Introduction to SQL. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.4-2 Topics in this Chapter SQL: History and Overview The.
SQL - miscellaneous D. Christozov / G.Tuparov INF 280 Database Systems: SQL – miscellaneous 1.
An Introduction to SQL For CS Overview of SQL  It is the standard language for relational systems, although imperfect  Supports data definition.
SQL.. AN OVERVIEW lecture3 1. Overview of SQL 2  Query: allow questions to be asked of the data and display only the information required. It can include.
1 Chapter 6 More SQL uDatabase Modification uDefining a Database Schema uViews.
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.
Views Prof. Yin-Fu Huang CSIE, NYUST Chapter 10. Advanced Database System Yin-Fu Huang 10.1Introduction Example: Var Good_Supplier View (S Where Status.
Objectives of Normalization  To create a formal framework for analyzing relation schemas based on their keys and on the functional dependencies among.
Microsoft Access CS 110 Fall Entity Relationship Model Entities Entities Principal data object about which information is to be collectedPrincipal.
Understand Data Definition Language (DDL) Database Administration Fundamentals LESSON 1.4.
Chapter 4 An Introduction to SQL. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.4-2 Topics in this Chapter SQL: History and Overview The.
SQL Exercises. 1) Names of suppliers. Suppliers(sid, sname, address) Parts(pid, pname, color) Catalog(sid, pid, cost)
Chapter 4 An Introduction to SQL.
STRUCTURE OF PRESENTATION :
Understand Data Manipulation Language (DML)
STRUCTURE OF PRESENTATION :
Chapter 12 Information Systems.
Understand Data Manipulation Language (DML)
پايگاه داده ها.
Authorization.
Session #, Speaker Name Database Privileges 11/29/2018.
אבטחת נתונים בסביבת SQL Data Security
SQL .. An overview lecture3.
Unit 7 Normalization (表格正規化).
STRUCTURE OF PRESENTATION :
실습 4주차.
Database Assignment Write down your answers in word document with file name highlighting your name, student number, and class. E.g “95002”+”_”+ “03 class”+”_”+”name”,
Updating Databases With Open SQL
STRUCTURE OF PRESENTATION :
Updating Databases With Open SQL
Presentation transcript:

1 Exercises of SQL uAnswer the following questions, based on the database below. wSupplier (SNO, SNAME, STATUS, CITY) wPart(PNO, PNAME, COLOR, WEIGHT) wProject(JNO, JNAME, CITY) wSPJ(SNO, PNO, JNO, QTY) uThe schema has four relations. The key attributes for each relation are shown in red.

2 u1.Give suitable declarations for each relation. u2.Write the following queries: w(1)Find the name and city of all the Supplier. w(2)Find the name, color and weight of all the parts. w(3)Find the number of all the projects using the parts that provided by S1. w(4)Find the name and quantity of all the parts used by J2. w(5)Find the number of all the parts made in ShangHai. w(6)Find the name of all the projects which have used the parts made in ShangHai.

3 w(7)Find the number of all the projects that didn’t used the parts made in TianJin. w(8)Update all the parts which color is red with blue. w(9)Update the Supplier S5 of the part P6 used by J4 with Supplier S3. w(10)Delete all the records about S2 from relation Supplier, and delete corresponding records from relation SPJ. w(11)Insert a new record(S2, J6, P4, 200) into relation Supplier. w(12)Grant the INSERT privilege on table Supplier to user John, and he includes the grant option with this privilege. w(13)Grant the SELECT privilege on table SPJ and UPDATE privilege on attribute QTY of SPJ to user Allice.

4 u3.Construct a view ThirdProj giving the Supplier number(Sno), part number(Pno), supporting quantity(QTY) of all Supplier who provide parts for “Third Project”. Write each of the queries using this view. w(1)Find the part number and supporting quantity of all parts used by “Third Project”. w(2)Find the supporting relation of S1.