Intermediate SQL C H A P T E R4. Practice Exercises. 4.1 Write the following queries in SQL:
|
|
|
- Domenic Mason
- 9 years ago
- Views:
Transcription
1 C H A P T E R4 Intermediate SQL Practice Exercises 4.1 Write the following queries in SQL: a. Display a list of all instructors, showing their ID, name, and the number of sections that they have taught. Make sure to show the number of sections as 0 for instructors who have not taught any section. Your query should use an outerjoin, and should not use scalar subqueries. b. Write the same query as above, but using a scalar subquery, without outerjoin. c. Display the list of all course sections offered in Spring 2010, along with the names of the instructors teaching the section. If a section has more than one instructor, it should appear as many times in the result as it has instructors. If it does not have any instructor, it should still appear in the result with the instructor name set to. d. Display the list of all departments, with the total number of instructors in each department, without using scalar subqueries. Make sure to correctly handle departments with no instructors. a. Display a list of all instructors, showing their ID, name, and the number of sections that they have taught. Make sure to show the number of sections as 0 for instructors who have not taught any section. Your query should use an outerjoin, and should not use scalar subqueries. select ID, name, count(course id, section id, year,semester) as Number of sections from instructor natural left outer join teaches group by ID, name The above query should not be written using count(*) since count * counts null values also. It could be written using count(section id), or 19
2 20 Chapter 4 Intermediate SQL any other attribute from teaches which does not occur in instructor, which would be correct although it may be confusing to the reader. (Attributes that occur in instructor would not be null even if the instructor has not taught any section.) b. Write the same query as above, but using a scalar subquery, without outerjoin. select ID, name, (select count(*) as Number of sections from teaches T where T.id = I.id) from instructor I c. Display the list of all course sections offered in Spring 2010, along with the names of the instructors teaching the section. If a section has more than one instructor, it should appear as many times in the result as it has instructors. If it does not have any instructor, it should still appear in the result with the instructor name set to. select course id, section id, ID, decode(name, NULL,, name) from (section natural left outer join teaches) natural left outer join instructor where semester= Spring and year= 2010 The query may also be written using the coalesce operator, by replacing decode(..) by coalesce(name, ). A more complex version of the query can be written using union of join result with another query that uses a subquery to find courses that do not match; refer to exercise 4.2. d. Display the list of all departments, with the total number of instructors in each department, without using scalar subqueries. Make sure to correctly handle departments with no instructors. select dept name, count(id) from department natural left outer join instructor group by dept name 4.2 Outer join expressions can be computed in SQL without using the SQL outer join operation. To illustrate this fact, show how to rewrite each of the following SQL queries without using the outer join expression. a. select * from student natural left outer join takes b. select * from student natural full outer join takes a. select * from student natural left outer join takes can be rewritten as:
3 Exercises 21 select * from student natural join takes union select ID, name, dept name, tot cred, NULL, NULL, NULL, NULL, NULL from student S1 where not exists (select ID from takes T1 where T1.id = S1.id) b. select * from student natural full outer join takes can be rewritten as: (select * from student natural join takes) union (select ID, name, dept name, tot cred, NULL, NULL, NULL, NULL, NULL from student S1 where not exists (select ID from takes T1 where T1.id = S1.id)) union (select ID, NULL, NULL, NULL, course id, section id, semester, year, grade from takes T1 where not exists (select ID from student S1 wheret1.id = S1.id)) 4.3 Suppose we have three relations r(a, B), s(b, C), and t(b, D), with all attributes declared as not null. Consider the expressions r natural left outer join (s natural left outer join t), and (r natural left outer join s) natural left outer join t a. Give instances of relations r, s and t such that in the result of the second expression, attribute C has a null value but attribute D has a non-null value. b. Is the above pattern, with C null and D not null possible in the result of the first expression? Explain why or why not. a. Consider r = (a,b), s = (b1,c1), t = (b,d). The second expression would give (a,b,null,d). b. It is not possible for D to be not null while C is null in the result of the first expression, since in the subexpression s natural left outer join t, it is not possible for C to be null while D is not null. In the overall expression C can be null if and only if some r tuple does not have a matching B value in s. However in this case D will also be null. 4.4 Testing SQL queries: To test if a query specified in English has been correctly written in SQL, the SQL query is typically executed on multiple test
4 22 Chapter 4 Intermediate SQL databases, and a human checks if the SQL query result on each test database matches the intention of the specification in English. a. In Section Section 3.3.3The Natural Joinsubsection we saw an example of an erroneous SQL query which was intended to find which courses had been taught by each instructor; the query computed the natural join of instructor, teaches, and course, and as a result unintentionally equated the dept name attribute of instructor and course. Give an example of a dataset that would help catch this particular error. b. When creating test databases, it is important to create tuples in referenced relations that do not have any matching tuple in the referencing relation, for each foreign key. Explain why, using an example query on the university database. c. When creating test databases, it is important to create tuples with null values for foreign key attributes, provided the attribute is nullable (SQL allows foreign key attributes to take on null values, as long as they are not part of the primary key, and have not been declared as not null). Explain why, using an example query on the university database. Hint: use the queries from Exercise Exercise 4.1Item.138. a. Consider the case where a professor in Physics department teaches an Elec. Eng. course. Even though there is a valid corresponding entry in teaches, it is lost in the natural join of instructor, teaches and course, since the instructors department name does not match the department name of the course. A dataset corresponding to the same is: instructor ={(12345, Guass, Physics, 10000)} teaches = {(12345, EE321, 1, Spring, 2009)} course ={( EE321, Magnetism, Elec. Eng., 6)} b. The query in question 0.a is a good example for this. Instructors who have not taught a single course, should have number of sections as 0 in the query result. (Many other similar examples are possible.) c. Consider the query select * from teaches natural join instructor; In the above query, we would lose some sections if teaches.id is allowed to be NULL and such tuples exist. If, just because teaches.id is a foreign key to instructor, we did not create such a tuple, the error in the above query would not be detected. 4.5 Show how to define the view student grades (ID, GPA) giving the gradepoint average of each student, based on the query in Exercise??; recall that we used a relation grade points(grade, points) to get the numeric points
5 Exercises 23 associated with a letter grade. Make sure your view definition correctly handles the case of null values for the grade attribute of the takes relation. We should not add credits for courses with a null grade; further to to correctly handle the case where a student has not completed any course, we should make sure we don t divide by zero, and should instead return a null value. We break the query into a subquery that finds sum of credits and sum of credit-grade-points, taking null grades into account The outer query divides the above to get the average, taking care of divide by 0. create view student grades(id, GPA) as select ID, credit points / decode(credit sum, 0, NULL, credit sum) from ((select ID, sum(decode(grade, NULL, 0, credits)) as credit sum, sum(decode(grade, NULL, 0, credits*points)) as credit points from(takes natural join course) natural left outer join grade points group by ID) union select ID, NULL from student where ID not in (select ID from takes)) The view defined above takes care of NULL grades by considering the creditpoints to be 0, and not adding the corresponding credits in credit sum. The query above ensures that if the student has not taken any course with non-null credits, and has credit sum = 0 gets a gpa of NULL. This avoid the division by 0, which would otherwise have resulted. An alternative way of writing the above query would be to use student natural left outer join gpa, in order to consider students who have not taken any course. 4.6 Complete the SQL DDL definition of the university database of Figure Figure 4.8Referential Integrityfigcnt.50 to include the relations student, takes, advisor, and prereq. create table student (ID varchar (5), name varchar (20) not null, dept name varchar (20), tot cred numeric (3,0) check (tot cred >= 0), primary key (ID), foreign key (dept name) references department on delete set null);
6 24 Chapter 4 Intermediate SQL create table takes (ID varchar (5), course id varchar (8), section id varchar (8), semester varchar (6), year numeric (4,0), grade varchar (2), primary key (ID, course id, section id, semester, year), foreign key (course id, section id, semester, year) references section on delete cascade, foreign key (ID) references student on delete cascade); create table advisor (i id varchar (5), s id varchar (5), primary key (s ID), foreign key (i ID) references instructor (ID) on delete set null, foreign key (s ID) references student (ID) on delete cascade); create table prereq (course id varchar(8), prereq id varchar(8), primary key (course id, prereq id), foreign key (course id) references course on delete cascade, foreign key (prereq id) references course); 4.7 Consider the relational database of Figure Figure 4.11figcnt.53. Give an SQL DDL definition of this database. Identify referential-integrity constraints that should hold, and include them in the DDL definition. create table employee (person name char(20), street char(30), city char(30), primary key (person name) )
7 Exercises 25 create table works (person name char(20), company name char(15), salary integer, primary key (person name), foreign key (person name) references employee, foreign key (company name) references company) create table company (company name char(15), city char(30), primary key (company name)) ppcreate table manages (person name char(20), manager name char(20), primary key (person name), foreign key (person name) references employee, foreign key (manager name) references employee) Note that alternative datatypes are possible. Other choices for not null attributes may be acceptable. 4.8 As discussed in Section Section 4.4.7Complex Check Conditions and Assertionssubsection.4.4 we expect the constraint an instructor cannot teach sections in two different classrooms in a semester in the same time slot to hold. a. Write an SQL query that returns all (instructor, section) combinations that violate this constraint. b. Write an SQL assertion to enforce this constraint (as discussed in Section Section 4.4.7Complex Check Conditions and Assertionssubsection.4.4.7, current generation database systems do not support such assertions, although they are part of the SQL standard). a. select ID, name, section id, semester, year, time slot id, count(distinct building, room number) from instructor natural join teaches natural join section group by (ID, name, section id, semester, year, time slot id) having count(building, room number) > 1 Note that the distinct keyword is required above. This is to allow two different sections to run concurrently in the same time slot and are
8 26 Chapter 4 Intermediate SQL b. taught by the same instructor, without being reported as a constraint violation. create assertion check not exists ( select ID, name, section id, semester, year, time slot id, count(distinct building, room number) from instructor natural join teaches natural join section group by (ID, name, section id, semester, year, time slot id) having count(building, room number) > 1) 4.9 SQL allows a foreign-key dependency to refer to the same relation, as in the following example: create table manager (employee name char(20), manager name char(20), primary key employee name, foreign key (manager name) references manager on delete cascade ) Here, employee name is a key to the table manager, meaning that each employee has at most one manager. The foreign-key clause requires that every manager also be an employee. Explain exactly what happens when a tuple in the relation manager is deleted. The tuples of all employees of the manager, at all levels, get deleted as well! This happens in a series of steps. The initial deletion will trigger deletion of all the tuples corresponding to direct employees of the manager. These deletions will in turn cause deletions of second level employee tuples, and so on, till all direct and indirect employee tuples are deleted SQL-92 provides an n-ary operation called coalesce, which is defined as follows: coalesce(a 1, A 2,..., A n ) returns the first nonnull A i in the list A 1, A 2,..., A n, and returns null if all of A 1, A 2,..., A n are null. Let a and b be relations with the schemas A(name, address, title) and B(name, address, salary), respectively. Show how to express a natural full outer join b using the full outer-join operation with an on condition and the coalesce operation. Make sure that the result relation does not contain two copies of the attributes name and address, and that the solution is correct even if some tuples in a and b have null values for attributes name or address.
9 Exercises 27 select coalesce(a.name, b.name) as name, coalesce(a.address, b.address) as address, a.title, b.salary from a full outer join b on a.name = b.name and a.address = b.address 4.11 Some researchers have proposed the concept of marked nulls. A marked null i is equal to itself, but if i j, then i j. One application of marked nulls is to allow certain updates through views. Consider the view instructor info (Section Section 4.2Viewssection.4.2). Show how you can use marked nulls to allow the insertion of the tuple (99999, Johnson, Music ) through instructor info. To insert the tuple (99999, ( Johnson), Music ) into the view instructor info, we can do the following: instructor (99999, Johnson, k, ) instructor department ( k, Music, ) department such that k is a new marked null not already existing in the database. Note: Music here is the name of a building and may or may not be related to Music department.
Exercise 1: Relational Model
Exercise 1: Relational Model 1. Consider the relational database of next relational schema with 3 relations. What are the best possible primary keys in each relation? employ(person_name, street, city)
SQL NULL s, Constraints, Triggers
CS145 Lecture Notes #9 SQL NULL s, Constraints, Triggers Example schema: CREATE TABLE Student (SID INTEGER PRIMARY KEY, name CHAR(30), age INTEGER, GPA FLOAT); CREATE TABLE Take (SID INTEGER, CID CHAR(10),
Introduction to SQL C H A P T E R3. Exercises
C H A P T E R3 Introduction to SQL Exercises 3.1 Write the following queries in SQL, using the university schema. (We suggest you actually run these queries on a database, using the sample data that we
Exercises. a. Find the total number of people who owned cars that were involved in accidents
42 Chapter 4 SQL Exercises 4.1 Consider the insurance database of Figure 4.12, where the primary keys are underlined. Construct the following SQL queries for this relational database. a. Find the total
Chapter 6: Integrity Constraints
Chapter 6: Integrity Constraints Domain Constraints Referential Integrity Assertions Triggers Functional Dependencies Database Systems Concepts 6.1 Silberschatz, Korth and Sudarshan c 1997 Domain Constraints
Databasesystemer, forår 2005 IT Universitetet i København. Forelæsning 3: Business rules, constraints & triggers. 3. marts 2005
Databasesystemer, forår 2005 IT Universitetet i København Forelæsning 3: Business rules, constraints & triggers. 3. marts 2005 Forelæser: Rasmus Pagh Today s lecture Constraints and triggers Uniqueness
COMP 5138 Relational Database Management Systems. Week 5 : Basic SQL. Today s Agenda. Overview. Basic SQL Queries. Joins Queries
COMP 5138 Relational Database Management Systems Week 5 : Basic COMP5138 "Relational Database Managment Systems" J. Davis 2006 5-1 Today s Agenda Overview Basic Queries Joins Queries Aggregate Functions
There are five fields or columns, with names and types as shown above.
3 THE RELATIONAL MODEL Exercise 3.1 Define the following terms: relation schema, relational database schema, domain, attribute, attribute domain, relation instance, relation cardinality, andrelation degree.
SQL Tables, Keys, Views, Indexes
CS145 Lecture Notes #8 SQL Tables, Keys, Views, Indexes Creating & Dropping Tables Basic syntax: CREATE TABLE ( DROP TABLE ;,,..., ); Types available: INT or INTEGER REAL or FLOAT CHAR( ), VARCHAR( ) DATE,
Part A: Data Definition Language (DDL) Schema and Catalog CREAT TABLE. Referential Triggered Actions. CSC 742 Database Management Systems
CSC 74 Database Management Systems Topic #0: SQL Part A: Data Definition Language (DDL) Spring 00 CSC 74: DBMS by Dr. Peng Ning Spring 00 CSC 74: DBMS by Dr. Peng Ning Schema and Catalog Schema A collection
Graham Kemp (telephone 772 54 11, room 6475 EDIT) The examiner will visit the exam room at 15:00 and 17:00.
CHALMERS UNIVERSITY OF TECHNOLOGY Department of Computer Science and Engineering Examination in Databases, TDA357/DIT620 Tuesday 17 December 2013, 14:00-18:00 Examiner: Results: Exam review: Grades: Graham
Lecture 6. SQL, Logical DB Design
Lecture 6 SQL, Logical DB Design Relational Query Languages A major strength of the relational model: supports simple, powerful querying of data. Queries can be written intuitively, and the DBMS is responsible
The Relational Model. Why Study the Relational Model? Relational Database: Definitions
The Relational Model Database Management Systems, R. Ramakrishnan and J. Gehrke 1 Why Study the Relational Model? Most widely used model. Vendors: IBM, Microsoft, Oracle, Sybase, etc. Legacy systems in
EECS 647: Introduction to Database Systems
EECS 647: Introduction to Database Systems Instructor: Luke Huan Spring 2013 Administrative Take home background survey is due this coming Friday The grader of this course is Ms. Xiaoli Li and her email
The Relational Model. Why Study the Relational Model? Relational Database: Definitions. Chapter 3
The Relational Model Chapter 3 Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 1 Why Study the Relational Model? Most widely used model. Vendors: IBM, Informix, Microsoft, Oracle, Sybase,
Introduction to SQL (3.1-3.4)
CSL 451 Introduction to Database Systems Introduction to SQL (3.1-3.4) Department of Computer Science and Engineering Indian Institute of Technology Ropar Narayanan (CK) Chatapuram Krishnan! Summary Parts
Data Modeling. Database Systems: The Complete Book Ch. 4.1-4.5, 7.1-7.4
Data Modeling Database Systems: The Complete Book Ch. 4.1-4.5, 7.1-7.4 Data Modeling Schema: The structure of the data Structured Data: Relational, XML-DTD, etc Unstructured Data: CSV, JSON But where does
CSC 443 Fall 2011 Dr. R. M. Siegfried. Answers to Assignment #1
Answers to Assignment #1 1.14. Consider the Database below: If the name of the 'CS' (Computer Science) Department changes to 'CSSE' (Computer Science and Software Engineering) Department and the corresponding
Lab Manual. Database Systems COT-313 & Database Management Systems Lab IT-216
Lab Manual Database Systems COT-313 & Database Management Systems Lab IT-216 Lab Instructions Several practicals / programs? Whether an experiment contains one or several practicals /programs One practical
Chapter 5 More SQL: Complex Queries, Triggers, Views, and Schema Modification
Chapter 5 More SQL: Complex Queries, Triggers, Views, and Schema Modification Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 5 Outline More Complex SQL Retrieval Queries
Chapter 13: Query Optimization
Chapter 13: Query Optimization Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Chapter 13: Query Optimization Introduction Transformation of Relational Expressions Catalog
The Relational Model. Ramakrishnan&Gehrke, Chapter 3 CS4320 1
The Relational Model Ramakrishnan&Gehrke, Chapter 3 CS4320 1 Why Study the Relational Model? Most widely used model. Vendors: IBM, Informix, Microsoft, Oracle, Sybase, etc. Legacy systems in older models
SQL DATA DEFINITION: KEY CONSTRAINTS. CS121: Introduction to Relational Database Systems Fall 2015 Lecture 7
SQL DATA DEFINITION: KEY CONSTRAINTS CS121: Introduction to Relational Database Systems Fall 2015 Lecture 7 Data Definition 2 Covered most of SQL data manipulation operations Continue exploration of SQL
CHAPTER 8: SQL-99: SCHEMA DEFINITION, BASIC CONSTRAINTS, AND QUERIES
Chapter 8: SQL-99: Schema Definition, Basic Constraints, and Queries 1 CHAPTER 8: SQL-99: SCHEMA DEFINITION, BASIC CONSTRAINTS, AND QUERIES Answers to Selected Exercises 8. 7 Consider the database shown
CS2Bh: Current Technologies. Introduction to XML and Relational Databases. The Relational Model. The relational model
CS2Bh: Current Technologies Introduction to XML and Relational Databases Spring 2005 The Relational Model CS2 Spring 2005 (LN6) 1 The relational model Proposed by Codd in 1970. It is the dominant data
SQL: Queries, Programming, Triggers
SQL: Queries, Programming, Triggers Chapter 5 Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 1 R1 Example Instances We will use these instances of the Sailors and Reserves relations in
The Structured Query Language. De facto standard used to interact with relational DB management systems Two major branches
CSI 2132 Tutorial 6 The Structured Query Language (SQL) The Structured Query Language De facto standard used to interact with relational DB management systems Two major branches DDL (Data Definition Language)
Example Instances. SQL: Queries, Programming, Triggers. Conceptual Evaluation Strategy. Basic SQL Query. A Note on Range Variables
SQL: Queries, Programming, Triggers Chapter 5 Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 1 Example Instances We will use these instances of the Sailors and Reserves relations in our
CS2Bh: Current Technologies. Introduction to XML and Relational Databases. Introduction to Databases. Why databases? Why not use XML?
CS2Bh: Current Technologies Introduction to XML and Relational Databases Spring 2005 Introduction to Databases CS2 Spring 2005 (LN5) 1 Why databases? Why not use XML? What is missing from XML: Consistency
The Relational Model. Why Study the Relational Model?
The Relational Model Chapter 3 Instructor: Vladimir Zadorozhny [email protected] Information Science Program School of Information Sciences, University of Pittsburgh 1 Why Study the Relational Model?
SQL: Queries, Programming, Triggers
SQL: Queries, Programming, Triggers CSC343 Introduction to Databases - A. Vaisman 1 R1 Example Instances We will use these instances of the Sailors and Reserves relations in our examples. If the key for
A basic create statement for a simple student table would look like the following.
Creating Tables A basic create statement for a simple student table would look like the following. create table Student (SID varchar(10), FirstName varchar(30), LastName varchar(30), EmailAddress varchar(30));
Databases What the Specification Says
Databases What the Specification Says Describe flat files and relational databases, explaining the differences between them; Design a simple relational database to the third normal form (3NF), using entityrelationship
Chapter 1: Introduction. Database Management System (DBMS) University Database Example
This image cannot currently be displayed. Chapter 1: Introduction Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Database Management System (DBMS) DBMS contains information
IT2304: Database Systems 1 (DBS 1)
: Database Systems 1 (DBS 1) (Compulsory) 1. OUTLINE OF SYLLABUS Topic Minimum number of hours Introduction to DBMS 07 Relational Data Model 03 Data manipulation using Relational Algebra 06 Data manipulation
Question 1. Relational Data Model [17 marks] Question 2. SQL and Relational Algebra [31 marks]
EXAMINATIONS 2005 MID-YEAR COMP 302 Database Systems Time allowed: Instructions: 3 Hours Answer all questions. Make sure that your answers are clear and to the point. Write your answers in the spaces provided.
New York University Computer Science Department Courant Institute of Mathematical Sciences
New York University Computer Science Department Courant Institute of Mathematical Sciences Homework #5 Solutions Course Title: Database Systems Instructor: Jean-Claude Franchitti Course Number: CSCI-GA.2433-001
Chapter 5. SQL: Queries, Constraints, Triggers
Chapter 5 SQL: Queries, Constraints, Triggers 1 Overview: aspects of SQL DML: Data Management Language. Pose queries (Ch. 5) and insert, delete, modify rows (Ch. 3) DDL: Data Definition Language. Creation,
IT2305 Database Systems I (Compulsory)
Database Systems I (Compulsory) INTRODUCTION This is one of the 4 modules designed for Semester 2 of Bachelor of Information Technology Degree program. CREDITS: 04 LEARNING OUTCOMES On completion of this
CSC 443 Data Base Management Systems. Basic SQL
CSC 443 Data Base Management Systems Lecture 6 SQL As A Data Definition Language Basic SQL SQL language Considered one of the major reasons for the commercial success of relational databases SQL Structured
5. CHANGING STRUCTURE AND DATA
Oracle For Beginners Page : 1 5. CHANGING STRUCTURE AND DATA Altering the structure of a table Dropping a table Manipulating data Transaction Locking Read Consistency Summary Exercises Altering the structure
CPS352 Database Systems: Design Project
CPS352 Database Systems: Design Project Purpose: Due: To give you experience with designing and implementing a database to model a real domain Various milestones due as shown in the syllabus Requirements
Introduction to Triggers using SQL
Introduction to Triggers using SQL Kristian Torp Department of Computer Science Aalborg University www.cs.aau.dk/ torp [email protected] November 24, 2011 daisy.aau.dk Kristian Torp (Aalborg University) Introduction
LiTH, Tekniska högskolan vid Linköpings universitet 1(7) IDA, Institutionen för datavetenskap Juha Takkinen 2007-05-24
LiTH, Tekniska högskolan vid Linköpings universitet 1(7) IDA, Institutionen för datavetenskap Juha Takkinen 2007-05-24 1. A database schema is a. the state of the db b. a description of the db using a
IINF 202 Introduction to Data and Databases (Spring 2012)
1 IINF 202 Introduction to Data and Databases (Spring 2012) Class Meets Times: Tuesday 7:15 PM 8:35 PM Thursday 7:15 PM 8:35 PM Location: SS 134 Instructor: Dima Kassab Email: [email protected] Office
SQL Server Database Coding Standards and Guidelines
SQL Server Database Coding Standards and Guidelines http://www.sqlauthority.com Naming Tables: Stored Procs: Triggers: Indexes: Primary Keys: Foreign Keys: Defaults: Columns: General Rules: Rules: Pascal
Database Design and the E-R Model
C H A P T E R 7 Database Design and the E-R Model Practice Exercises 7.1 Answer: The E-R diagram is shown in Figure 7.1. Payments are modeled as weak entities since they are related to a specific policy.
INFO/CS 330: Applied Database Systems
INFO/CS 330: Applied Database Systems Introduction to Database Security Johannes Gehrke [email protected] http://www.cs.cornell.edu/johannes Introduction to DB Security Secrecy:Users should not be
The Relational Data Model and Relational Database Constraints
The Relational Data Model and Relational Database Constraints Chapter Outline Relational Model Concepts Relational Model Constraints and Relational Database Schemas Update Operations and Dealing with Constraint
Using Temporary Tables to Improve Performance for SQL Data Services
Using Temporary Tables to Improve Performance for SQL Data Services 2014- Informatica Corporation. No part of this document may be reproduced or transmitted in any form, by any means (electronic, photocopying,
Review: Participation Constraints
Review: Participation Constraints Does every department have a manager? If so, this is a participation constraint: the participation of Departments in Manages is said to be total (vs. partial). Every did
SQL Simple Queries. Chapter 3.1 V3.0. Copyright @ Napier University Dr Gordon Russell
SQL Simple Queries Chapter 3.1 V3.0 Copyright @ Napier University Dr Gordon Russell Introduction SQL is the Structured Query Language It is used to interact with the DBMS SQL can Create Schemas in the
ATTACHMENT 6 SQL Server 2012 Programming Standards
ATTACHMENT 6 SQL Server 2012 Programming Standards SQL Server Object Design and Programming Object Design and Programming Idaho Department of Lands Document Change/Revision Log Date Version Author Description
Oracle Database: SQL and PL/SQL Fundamentals
Oracle University Contact Us: +966 12 739 894 Oracle Database: SQL and PL/SQL Fundamentals Duration: 5 Days What you will learn This Oracle Database: SQL and PL/SQL Fundamentals training is designed to
More on SQL. Juliana Freire. Some slides adapted from J. Ullman, L. Delcambre, R. Ramakrishnan, G. Lindstrom and Silberschatz, Korth and Sudarshan
More on SQL Some slides adapted from J. Ullman, L. Delcambre, R. Ramakrishnan, G. Lindstrom and Silberschatz, Korth and Sudarshan SELECT A1, A2,, Am FROM R1, R2,, Rn WHERE C1, C2,, Ck Interpreting a Query
SQL Server. 2012 for developers. murach's TRAINING & REFERENCE. Bryan Syverson. Mike Murach & Associates, Inc. Joel Murach
TRAINING & REFERENCE murach's SQL Server 2012 for developers Bryan Syverson Joel Murach Mike Murach & Associates, Inc. 4340 N. Knoll Ave. Fresno, CA 93722 www.murach.com [email protected] Expanded
Instant SQL Programming
Instant SQL Programming Joe Celko Wrox Press Ltd. INSTANT Table of Contents Introduction 1 What Can SQL Do for Me? 2 Who Should Use This Book? 2 How To Use This Book 3 What You Should Know 3 Conventions
Database Design. Database Design I: The Entity-Relationship Model. Entity Type (con t) Chapter 4. Entity: an object that is involved in the enterprise
Database Design Database Design I: The Entity-Relationship Model Chapter 4 Goal: specification of database schema Methodology: Use E-R R model to get a high-level graphical view of essential components
Databases and BigData
Eduardo Cunha de Almeida [email protected] Outline of the course Introduction Database Systems (E. Almeida) Distributed Hash Tables and P2P (C. Cassagnes) NewSQL (D. Kim and J. Meira) NoSQL (D. Kim)
Guide to SQL Programming: SQL:1999 and Oracle Rdb V7.1
Guide to SQL Programming: SQL:1999 and Oracle Rdb V7.1 A feature of Oracle Rdb By Ian Smith Oracle Rdb Relational Technology Group Oracle Corporation 1 Oracle Rdb Journal SQL:1999 and Oracle Rdb V7.1 The
Outline. Data Modeling. Conceptual Design. ER Model Basics: Entities. ER Model Basics: Relationships. Ternary Relationships. Yanlei Diao UMass Amherst
Outline Data Modeling Yanlei Diao UMass Amherst v Conceptual Design: ER Model v Relational Model v Logical Design: from ER to Relational Slides Courtesy of R. Ramakrishnan and J. Gehrke 1 2 Conceptual
Duration Vendor Audience 5 Days Oracle End Users, Developers, Technical Consultants and Support Staff
D80198GC10 Oracle Database 12c SQL and Fundamentals Summary Duration Vendor Audience 5 Days Oracle End Users, Developers, Technical Consultants and Support Staff Level Professional Delivery Method Instructor-led
The SQL Query Language. Creating Relations in SQL. Referential Integrity in SQL. Basic SQL Query. Primary and Candidate Keys in SQL
COS 597A: Principles of Database and Information Systems SQL: Overview and highlights The SQL Query Language Structured Query Language Developed by IBM (system R) in the 1970s Need for a standard since
Database Security. Chapter 21
Database Security Chapter 21 Introduction to DB Security Secrecy: Users should not be able to see things they are not supposed to. E.g., A student can t see other students grades. Integrity: Users should
CSCE 156H/RAIK 184H Assignment 4 - Project Phase III Database Design
CSCE 156H/RAIK 184H Assignment 4 - Project Phase III Database Design Dr. Chris Bourke Spring 2016 1 Introduction In the previous phase of this project, you built an application framework that modeled the
Triggers & Packages. {INSERT [OR] UPDATE [OR] DELETE}: This specifies the DML operation.
Triggers & Packages An SQL trigger is a mechanism that automatically executes a specified PL/SQL block (referred to as the triggered action) when a triggering event occurs on the table. The triggering
Database Constraints and Design
Database Constraints and Design We know that databases are often required to satisfy some integrity constraints. The most common ones are functional and inclusion dependencies. We ll study properties of
Oracle 10g PL/SQL Training
Oracle 10g PL/SQL Training Course Number: ORCL PS01 Length: 3 Day(s) Certification Exam This course will help you prepare for the following exams: 1Z0 042 1Z0 043 Course Overview PL/SQL is Oracle's Procedural
How To Create A Table In Sql 2.5.2.2 (Ahem)
Database Systems Unit 5 Database Implementation: SQL Data Definition Language Learning Goals In this unit you will learn how to transfer a logical data model into a physical database, how to extend or
public class ResultSetTable implements TabelModel { ResultSet result; ResultSetMetaData metadata; int num cols;
C H A P T E R5 Advanced SQL Practice Exercises 5.1 Describe the circumstances in which you would choose to use embedded SQL rather than SQL alone or only a general-purpose programming language. Writing
Oracle Database: SQL and PL/SQL Fundamentals
Oracle University Contact Us: 1.800.529.0165 Oracle Database: SQL and PL/SQL Fundamentals Duration: 5 Days What you will learn This course is designed to deliver the fundamentals of SQL and PL/SQL along
Information Systems SQL. Nikolaj Popov
Information Systems SQL Nikolaj Popov Research Institute for Symbolic Computation Johannes Kepler University of Linz, Austria [email protected] Outline SQL Table Creation Populating and Modifying
CS143 Notes: Views & Authorization
CS143 Notes: Views & Authorization Book Chapters (4th) Chapter 4.7, 6.5-6 (5th) Chapter 4.2, 8.6 (6th) Chapter 4.4, 5.3 Views What is a view? A virtual table created on top of other real tables Almost
Relational Databases
Relational Databases Jan Chomicki University at Buffalo Jan Chomicki () Relational databases 1 / 18 Relational data model Domain domain: predefined set of atomic values: integers, strings,... every attribute
3. Relational Model and Relational Algebra
ECS-165A WQ 11 36 3. Relational Model and Relational Algebra Contents Fundamental Concepts of the Relational Model Integrity Constraints Translation ER schema Relational Database Schema Relational Algebra
Oracle SQL. Course Summary. Duration. Objectives
Oracle SQL Course Summary Identify the major structural components of the Oracle Database 11g Create reports of aggregated data Write SELECT statements that include queries Retrieve row and column data
Database Management Systems. Chapter 1
Database Management Systems Chapter 1 Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 2 What Is a Database/DBMS? A very large, integrated collection of data. Models real-world scenarios
Database Programming with PL/SQL: Learning Objectives
Database Programming with PL/SQL: Learning Objectives This course covers PL/SQL, a procedural language extension to SQL. Through an innovative project-based approach, students learn procedural logic constructs
History of SQL. Relational Database Languages. Tuple relational calculus ALPHA (Codd, 1970s) QUEL (based on ALPHA) Datalog (rule-based, like PROLOG)
Relational Database Languages Tuple relational calculus ALPHA (Codd, 1970s) QUEL (based on ALPHA) Datalog (rule-based, like PROLOG) Domain relational calculus QBE (used in Access) History of SQL Standards:
Relational model. Relational model - practice. Relational Database Definitions 9/27/11. Relational model. Relational Database: Terminology
COS 597A: Principles of Database and Information Systems elational model elational model A formal (mathematical) model to represent objects (data/information), relationships between objects Constraints
Chapter 14: Query Optimization
Chapter 14: Query Optimization Database System Concepts 5 th Ed. See www.db-book.com for conditions on re-use Chapter 14: Query Optimization Introduction Transformation of Relational Expressions Catalog
Schema Evolution in SQL-99 and Commercial (Object-)Relational DBMS
Schema Evolution in SQL-99 and Commercial (Object-)Relational DBMS Can Türker Swiss Federal Institute of Technology (ETH) Zurich Institute of Information Systems, ETH Zentrum CH 8092 Zurich, Switzerland
Advanced SQL. Lecture 3. Outline. Unions, intersections, differences Subqueries, Aggregations, NULLs Modifying databases, Indexes, Views
Advanced SQL Lecture 3 1 Outline Unions, intersections, differences Subqueries, Aggregations, NULLs Modifying databases, Indexes, Views Reading: Textbook chapters 6.2 and 6.3 from SQL for Nerds : chapter
A Comparison of Database Query Languages: SQL, SPARQL, CQL, DMX
ISSN: 2393-8528 Contents lists available at www.ijicse.in International Journal of Innovative Computer Science & Engineering Volume 3 Issue 2; March-April-2016; Page No. 09-13 A Comparison of Database
Chapter 8. SQL-99: SchemaDefinition, Constraints, and Queries and Views
Chapter 8 SQL-99: SchemaDefinition, Constraints, and Queries and Views Data Definition, Constraints, and Schema Changes Used to CREATE, DROP, and ALTER the descriptions of the tables (relations) of a database
5.1 Database Schema. 5.1.1 Schema Generation in SQL
5.1 Database Schema The database schema is the complete model of the structure of the application domain (here: relational schema): relations names of attributes domains of attributes keys additional constraints
Oracle Database: SQL and PL/SQL Fundamentals NEW
Oracle University Contact Us: + 38516306373 Oracle Database: SQL and PL/SQL Fundamentals NEW Duration: 5 Days What you will learn This Oracle Database: SQL and PL/SQL Fundamentals training delivers the
Boats bid bname color 101 Interlake blue 102 Interlake red 103 Clipper green 104 Marine red. Figure 1: Instances of Sailors, Boats and Reserves
Tutorial 5: SQL By Chaofa Gao Tables used in this note: Sailors(sid: integer, sname: string, rating: integer, age: real); Boats(bid: integer, bname: string, color: string); Reserves(sid: integer, bid:
Programming with SQL
Unit 43: Programming with SQL Learning Outcomes A candidate following a programme of learning leading to this unit will be able to: Create queries to retrieve information from relational databases using
Structured Query Language (SQL)
Objectives of SQL Structured Query Language (SQL) o Ideally, database language should allow user to: create the database and relation structures; perform insertion, modification, deletion of data from
Database Design--from E-R Diagram to SQL Statement
Database Design--from E-R Diagram to SQL Statement Problem Set 3 In problem set 3 * you will: Create an entity-relationship diagram for a database Construct a simple database design Input records into
Answers included WORKSHEET: INTEGRITY CONTROL IN RELATIONAL DATABASES
CS27020: Modelling Persistent Data WORKSHEET: INTEGRITY CONTROL IN RELATIONAL DATABASES Time allowed: 40 minutes Calculators are not allowed in this worksheet. Answer all questions 1. Briefly explain what
3.GETTING STARTED WITH ORACLE8i
Oracle For Beginners Page : 1 3.GETTING STARTED WITH ORACLE8i Creating a table Datatypes Displaying table definition using DESCRIBE Inserting rows into a table Selecting rows from a table Editing SQL buffer
Maintaining Stored Procedures in Database Application
Maintaining Stored Procedures in Database Application Santosh Kakade 1, Rohan Thakare 2, Bhushan Sapare 3, Dr. B.B. Meshram 4 Computer Department VJTI, Mumbai 1,2,3. Head of Computer Department VJTI, Mumbai
SUBQUERIES AND VIEWS. CS121: Introduction to Relational Database Systems Fall 2015 Lecture 6
SUBQUERIES AND VIEWS CS121: Introduction to Relational Database Systems Fall 2015 Lecture 6 String Comparisons and GROUP BY 2! Last time, introduced many advanced features of SQL, including GROUP BY! Recall:
CMU - SCS 15-415/15-615 Database Applications Spring 2013, C. Faloutsos Homework 1: E.R. + Formal Q.L. Deadline: 1:30pm on Tuesday, 2/5/2013
CMU - SCS 15-415/15-615 Database Applications Spring 2013, C. Faloutsos Homework 1: E.R. + Formal Q.L. Deadline: 1:30pm on Tuesday, 2/5/2013 Reminders - IMPORTANT: Like all homeworks, it has to be done
Database Design Overview. Conceptual Design ER Model. Entities and Entity Sets. Entity Set Representation. Keys
Database Design Overview Conceptual Design. The Entity-Relationship (ER) Model CS430/630 Lecture 12 Conceptual design The Entity-Relationship (ER) Model, UML High-level, close to human thinking Semantic
Relationele Databases 2002/2003
1 Relationele Databases 2002/2003 Hoorcollege 7 12 juni 2003 Jaap Kamps & Maarten de Rijke April Juli 2003 Praktische dingen 6.2 6.3 6.5 6.7 Plan voor Vandaag Theorie Silberschatz et al: hoofdstuk 7 (
SQL Data Definition. Database Systems Lecture 5 Natasha Alechina
Database Systems Lecture 5 Natasha Alechina In This Lecture SQL The SQL language SQL, the relational model, and E/R diagrams CREATE TABLE Columns Primary Keys Foreign Keys For more information Connolly
In This Lecture. Security and Integrity. Database Security. DBMS Security Support. Privileges in SQL. Permissions and Privilege.
In This Lecture Database Systems Lecture 14 Natasha Alechina Database Security Aspects of security Access to databases Privileges and views Database Integrity View updating, Integrity constraints For more
