# There are five fields or columns, with names and types as shown above.

Save this PDF as:

Size: px
Start display at page:

Download "There are five fields or columns, with names and types as shown above."

## Transcription

1 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. Answer 3.1 A relation schema can be thought of as the basic information describing a table or relation. This includes a set of column names, the data types associated with each column, and the name associated with the entire table. For example, a relation schema for the relation called Students could be expressed using the following representation: Students(sid: string, name: string, login: string, age: integer, gpa: real) There are five fields or columns, with names and types as shown above. A relational database schema is a collection of relation schemas, describing one or more relations. Domain is synonymous with data type. Attributes can be thought of as columns in a table. Therefore, an attribute domain refers to the data type associated with a column. A relation instance is a set of tuples (also known as rows or records) that each conform to the schema of the relation. The relation cardinality is the number of tuples in the relation. The relation degree is the number of fields (or columns) in the relation. Exercise 3.2 How many distinct tuples are in a relation instance with cardinality 22? 22

2 The Relational Model 23 Answer 3.2 Since a relation is formally defined as a set of tuples, if the cardinality is 22 (i.e., there are 22 tuples), there must be 22 distinct tuples. Exercise 3.3 Does the relational model, as seen by an SQL query writer, provide physical and logical data independence? Explain. Answer 3.3 The user of SQL has no idea how the data is physically represented in the machine. He or she relies entirely on the relation abstraction for querying. Physical data independence is therefore assured. Since a user can define views, logical data independence can also be achieved by using view definitions to hide changes in the conceptual schema. Exercise 3.4 What is the difference between a candidate key and the primary key for a given relation? What is a superkey? Answer 3.4 The primary key is the key selectedby the DBA fromamongthe groupof candidate keys, all of which uniquely identify a tuple. A superkey is a set of attributes that contains a key. FIELDS (ATTRIBUTES, COLUMNS) Field names TUPLES (RECORDS, ROWS) sid name login age gpa Dave Jones Smith Smith Madayan Guldu Figure 3.1 An Instance S1 of the Students Relation Exercise 3.5 Consider the instance of the Students relation shown in Figure Give an example of an attribute (or set of attributes) that you can deduce is not a candidate key, based on this instance being legal. 2. Is there any example of an attribute (or set of attributes) that you can deduce is a candidate key, based on this instance being legal?

3 24 Chapter 3 Answer 3.5 Examples of non-candidate keys include the following: {name}, {age}. (Note that {gpa} can not be declared as a non-candidate key from this evidence alone even though common sense tells us that clearly more than one student could have the same grade point average.) You cannot determine a key of a relation given only one instance of the relation. The fact that the instance is legal is immaterial. A candidate key, as defined here, is a key, not something that only might be a key. The instance shown is just one possible snapshot of the relation. At other times, the same relation may have an instance (or snapshot) that contains a totally different set of tuples, and we cannot make predictions about those instances based only upon the instance that we are given. Exercise 3.6 What is a foreign key constraint? Why are such constraints important? What is referential integrity? Answer 3.6 A foreign key constraint is a statement of the form that one or more fields of a relation, say R, together refer to a second relation, say S. That is, the values in these fields of a tuple in R are either null, or uniquely identify some tuple in S. Thus, these fields of R should be a (candidate or primary) key. For example, a student, uniquely identified by an sid, enrolled in a class must also be registered in the school s student database (say, in a relation called Students). Therefore, the sid of a legal entry in the Class Enrollment relation must match an existing sid in the Students relation. Foreign key constraints are important because they provide safeguards for insuring the integrity of data. Users are alerted/thwarted when they try to do something that does not make sense. This can help minimize errors in application programs or in data-entry. Referential integrity means all foreign key constraints are enforced. Exercise 3.7 Consider the relations Students, Faculty, Courses, Rooms, Enrolled, Teaches, and Meets In defined in Section List all the foreign key constraints among these relations. 2. Give an example of a (plausible) constraint involving one or more of these relations that is not a primary key or foreign key constraint. Answer 3.7 There is no reason for a foreign key constraint (FKC) on the Students, Faculty, Courses, or Rooms relations. These are the most basic relations and must be free-standing. Special care must be given to enteringdataintothesebaserelations.

4 The Relational Model 25 In the Enrolled relation, sid and cid should both have FKCs placed on them. (Real students must be enrolled in real courses.) Also, since real teachers must teach real courses, both the fid and the cid fields in the Teaches relation should have FKCs. Finally, Meets In should place FKCs on both the cid and rno fields. It would probably be wise to enforce a few other constraints on this DBMS: the length of sid, cid, and fid could be standardized; checksums could be added to these identification numbers; limits could be placed on the size of the numbers entered into the credits, capacity, and salary fields; an enumerated type should be assigned to the grade field (preventing a student from receiving a grade of G, among other things); etc. Exercise 3.8 Answer each of the following questions briefly. The questions are based on the following relational schema: Emp(eid: integer, ename: string, age: integer, salary: real) Works(eid: integer, did: integer, pcttime: integer) Dept(did: integer, dname: string, budget: real, managerid: integer) 1. Give an example of a foreign key constraint that involves the Dept relation. What are the options for enforcing this constraint when a user attempts to delete a Dept tuple? 2. Write the SQL statements required to create the preceding relations, including appropriate versions of all primary and foreign key integrity constraints. 3. Define the Dept relation in SQL so that every department is guaranteed to have a manager. 4. Write an SQL statement to add John Doe as an employee with eid = 101, age =32 and salary =15, Write an SQL statement to give every employee a 10 percent raise. 6. Write an SQL statement to delete the Toy department. Given the referential integrity constraints you chose for this schema, explain what happens when this statement is executed. Answer 3.8 Theanswersaregivenbelow: 1. Consider the following example. It is natural to require that the did field of Works should be a foreign key, and refer to Dept. CREATE TABLE Works ( eid INTEGER NOT NULL, did INTEGER NOT NULL,

5 26 Chapter 3 pcttime INTEGER, PRIMARY KEY (eid, did), UNIQUE (eid), FOREIGN KEY (did) REFERENCES Dept ) When a user attempts to delete a Dept tuple, There are four options: Also delete all Works tuples that refer to it. Disallow the deletion of the Dept tuple if some Works tuple refers to it. For every Works tuple that refers to it, set the did field to the did of some (existing) default department. For every Works tuple that refers to it, set the did field to null. 2. CREATE TABLE Emp ( eid INTEGER, ename CHAR(10), age INTEGER, salary REAL, PRIMARY KEY (eid) ) CREATE TABLE Works ( eid INTEGER, did INTEGER, pcttime INTEGER, PRIMARY KEY (eid, did), FOREIGN KEY (did) REFERENCES Dept, FOREIGN KEY (eid) REFERENCES Emp, ON DELETE CASCADE) CREATE TABLE Dept ( did INTEGER, budget REAL, managerid INTEGER, PRIMARY KEY (did), FOREIGN KEY (managerid) REFERENCES Emp, ON DELETE SET NULL) 3. CREATE TABLE Dept ( did INTEGER, budget REAL, managerid INTEGER NOT NULL, PRIMARY KEY (did), FOREIGN KEY (managerid) REFERENCES Emp) 4. INSERT INTO Emp (eid, ename, age, salary) VALUES (101, John Doe, 32, 15000) 5. UPDATE Emp E

7 28 Chapter 3 Answer 3.10 The constraint that the ssn field of Manages should not be null implies that for every tuple present in Manages, there should be a Manager. This does not however ensure that each department has an entry (or a tuple corresponding to that dept) in the Manages relation. Exercise 3.11 Suppose that we have a ternary relationship R between entity sets A, B, and C such that A has a key constraint and total participation and B has a key constraint; these are the only constraints. A has attributes a1 anda2, with a1 being the key; B and C are similar. R has no descriptive attributes. Write SQL statements that create tables corresponding to this information so as to capture as many of the constraints as possible. If you cannot capture some constraint, explain why. Answer 3.11 The following SQL statements create the corresponding relations. CREATE TABLE A( a1 CHAR(10), a2 CHAR(10), b1 CHAR(10), c1 CHAR(10), PRIMARY KEY (a1), UNIQUE (b1), FOREIGN KEY (b1) REFERENCES B, FOREIGN KEY (c1) REFERENCES C) CREATE TABLE B( b1 CHAR(10), b2 CHAR(10), PRIMARY KEY (b1) ) CREATE TABLE C( b1 CHAR(10), c2 CHAR(10), PRIMARY KEY (c1) ) The first SQL statement folds the relationship R into table A and thereby guarantees the participation constraint. Exercise 3.12 Consider the scenario from Exercise 2.2, where you designed an ER diagram for a university database. Write SQL statements to create the corresponding relations and capture as many of the constraints as possible. If you cannot capture some constraints, explain why. Answer 3.12 The following SQL statements create the corresponding relations.

### 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. 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

### The Relational Model. Why Study the Relational Model?

The Relational Model Chapter 3 Instructor: Vladimir Zadorozhny vladimir@sis.pitt.edu Information Science Program School of Information Sciences, University of Pittsburgh 1 Why Study the Relational Model?

### 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,

### DATABASE MANAGEMENT SYSTEMS SOLUTIONS MANUAL THIRD EDITION

DATABASE MANAGEMENT SYSTEMS SOLUTIONS MANUAL THIRD EDITION Raghu Ramakrishnan University of Wisconsin Madison, WI, USA Johannes Gehrke Cornell University Ithaca, NY, USA Jeff Derstadt, Scott Selikoff,

### 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

### 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

### DATABASE MANAGEMENT SYSTEMS SOLUTIONS MANUAL THIRD EDITION

DATABASE MANAGEMENT SYSTEMS SOLUTIONS MANUAL THIRD EDITION Raghu Ramakrishnan University of Wisconsin Madison, WI, USA Johannes Gehrke Cornell University Ithaca, NY, USA Jeff Derstadt, Scott Selikoff,

### 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

### Review Entity-Relationship Diagrams and the Relational Model. Data Models. Review. Why Study the Relational Model? Steps in Database Design

Review Entity-Relationship Diagrams and the Relational Model CS 186, Fall 2007, Lecture 2 R & G, Chaps. 2&3 Why use a DBMS? OS provides RAM and disk A relationship, I think, is like a shark, you know?

### DATABASE MANAGEMENT SYSTEMS SOLUTIONS MANUAL. Raghu Ramakrishnan et al. University of Wisconsin Madison, WI, USA

DATABASE MANAGEMENT SYSTEMS SOLUTIONS MANUAL Raghu Ramakrishnan et al. University of Wisconsin Madison, WI, USA 2 THE ENTITY-RELATIONSHIP MODEL Exercise 2.1 Explain the following terms briefly: attribute,

### DATABASE MANAGEMENT SYSTEMS SOLUTIONS MANUAL. Raghu Ramakrishnan et al. University of Wisconsin Madison, WI, USA

DATABASE MANAGEMENT SYSTEMS SOLUTIONS MANUAL Raghu Ramakrishnan et al. University of Wisconsin Madison, WI, USA CONTENTS PREFACE iii 1 INTRODUCTION TO DATABASE SYSTEMS 1 2 THE ENTITY-RELATIONSHIP MODEL

### 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

### Overview. Introduction to Database Systems. Motivation... Motivation: how do we store lots of data?

Introduction to Database Systems UVic C SC 370 Overview What is a DBMS? what is a relational DBMS? Why do we need them? How do we represent and store data in a DBMS? How does it support concurrent access

### Databases Model the Real World. The Entity- Relationship Model. Conceptual Design. Steps in Database Design. ER Model Basics. ER Model Basics (Contd.

The Entity- Relationship Model R &G - Chapter 2 A relationship, I think, is like a shark, you know? It has to constantly move forward or it dies. And I think what we got on our hands is a dead shark. Woody

### 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

### Winter 2003 1. Winter 2003 2

M Today s Lecture Database design through ER diagrams Creating and modifying relations, specifying integrity constraints using SQL Translate ER diagrams to relations A little on views Winter 2003 1 ai

### 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

### Topics. Introduction to Database Management System. What Is a DBMS? DBMS Types

Introduction to Database Management System Linda Wu (CMPT 354 2004-2) Topics What is DBMS DBMS types Files system vs. DBMS Advantages of DBMS Data model Levels of abstraction Transaction management DBMS

### 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),

### Database Design. Marta Jakubowska-Sobczak IT/ADC based on slides prepared by Paula Figueiredo, IT/DB

Marta Jakubowska-Sobczak IT/ADC based on slides prepared by Paula Figueiredo, IT/DB Outline Database concepts Conceptual Design Logical Design Communicating with the RDBMS 2 Some concepts Database: an

### University of Massachusetts Amherst Department of Computer Science Prof. Yanlei Diao

University of Massachusetts Amherst Department of Computer Science Prof. Yanlei Diao CMPSCI 445 Midterm Practice Questions NAME: LOGIN: Write all of your answers directly on this paper. Be sure to clearly

### 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

### Assignment 3: SQL Queries. Questions 1. The following relations keep track of airline flight information:

Database Systems Instructors: Hao-Hua Chu Winston Hsu Fall Semester, 2007 Assignment 3: SQL Queries Questions 1. The following relations keep track of airline flight information: Flightsflno: integer,

### Databases and BigData

Eduardo Cunha de Almeida eduardo.almeida@uni.lu 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)

### 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)

### 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

### 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, CONSTRAINTS, TRIGGERS

5 SQL: QUERIES, CONSTRAINTS, TRIGGERS Online material is available for all exercises in this chapter on the book s webpage at http://www.cs.wisc.edu/~dbbook This includes scripts to create tables for each

### www.gr8ambitionz.com

Data Base Management Systems (DBMS) Study Material (Objective Type questions with Answers) Shared by Akhil Arora Powered by www. your A to Z competitive exam guide Database Objective type questions Q.1

### 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

### Scheme G. Sample Test Paper-I

Scheme G Sample Test Paper-I Course Name : Computer Engineering Group Course Code : CO/CM/IF/CD/CW Marks : 25 Hours: 1 Hrs. Q.1 Attempt Any THREE. 09 Marks a) List any six applications of DBMS. b) Define

### 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

### Conceptual Design Using the Entity-Relationship (ER) Model

Conceptual Design Using the Entity-Relationship (ER) Model Module 5, Lectures 1 and 2 Database Management Systems, R. Ramakrishnan 1 Overview of Database Design Conceptual design: (ER Model is used at

### 2. Conceptual Modeling using the Entity-Relationship Model

ECS-165A WQ 11 15 Contents 2. Conceptual Modeling using the Entity-Relationship Model Basic concepts: entities and entity types, attributes and keys, relationships and relationship types Entity-Relationship

### AVOIDANCE OF CYCLICAL REFERENCE OF FOREIGN KEYS IN DATA MODELING USING THE ENTITY-RELATIONSHIP MODEL

AVOIDANCE OF CYCLICAL REFERENCE OF FOREIGN KEYS IN DATA MODELING USING THE ENTITY-RELATIONSHIP MODEL Ben B. Kim, Seattle University, bkim@seattleu.edu ABSTRACT The entity-relationship (ER model is clearly

### 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

### COMP 378 Database Systems Notes for Chapter 7 of Database System Concepts Database Design and the Entity-Relationship Model

COMP 378 Database Systems Notes for Chapter 7 of Database System Concepts Database Design and the Entity-Relationship Model The entity-relationship (E-R) model is a a data model in which information stored

### 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

### Ch.5 Database Security. Ch.5 Database Security Review

User Authentication Access Control Database Security Ch.5 Database Security Hw_Ch3, due today Hw_Ch4, due on 2/23 Review Questions: 4.1, 4.3, 4.6, 4.10 Problems: 4.5, 4.7, 4.8 How about the pace of the

### Chapter 9, More SQL: Assertions, Views, and Programming Techniques

Chapter 9, More SQL: Assertions, Views, and Programming Techniques 9.2 Embedded SQL SQL statements can be embedded in a general purpose programming language, such as C, C++, COBOL,... 9.2.1 Retrieving

### Elena Baralis, Silvia Chiusano Politecnico di Torino. Pag. 1. Physical Design. Phases of database design. Physical design: Inputs.

Phases of database design Application requirements Conceptual design Database Management Systems Conceptual schema Logical design ER or UML Physical Design Relational tables Logical schema Physical design

### 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

### Introduction to Databases

Page 1 of 5 Introduction to Databases An introductory example What is a database? Why do we need Database Management Systems? The three levels of data abstraction What is a Database Management System?

### DataBase Management Systems Lecture Notes

1 SHRI VISHNU ENGINEERING COLLEGE FOR WOMEN::BHIMAVARAM DEPARTMENT OF INFORMATION TECHNOLOGY DataBase Management Systems Lecture Notes UNIT-1 Data: It is a collection of information. The facts that can

### Database Implementation: SQL Data Definition Language

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

### 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,

### 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

### Database Systems. Lecture 1: Introduction

Database Systems Lecture 1: Introduction General Information Professor: Leonid Libkin Contact: libkin@ed.ac.uk Lectures: Tuesday, 11:10am 1 pm, AT LT4 Website: http://homepages.inf.ed.ac.uk/libkin/teach/dbs09/index.html

### 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

### 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));

### Basic Concepts of Database Systems

CS2501 Topic 1: Basic Concepts 1.1 Basic Concepts of Database Systems Example Uses of Database Systems - account maintenance & access in banking - lending library systems - airline reservation systems

### The Entity-Relationship Model

The Entity-Relationship Model 221 After completing this chapter, you should be able to explain the three phases of database design, Why are multiple phases useful? evaluate the significance of the Entity-Relationship

### 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

### 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

### The process of database development. Logical model: relational DBMS. Relation

The process of database development Reality (Universe of Discourse) Relational Databases and SQL Basic Concepts The 3rd normal form Structured Query Language (SQL) Conceptual model (e.g. Entity-Relationship

### B2.2-R3: INTRODUCTION TO DATABASE MANAGEMENT SYSTEMS

B2.2-R3: INTRODUCTION TO DATABASE MANAGEMENT SYSTEMS NOTE: 1. There are TWO PARTS in this Module/Paper. PART ONE contains FOUR questions and PART TWO contains FIVE questions. 2. PART ONE is to be answered

### 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

### 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,

### Intermediate SQL C H A P T E R4. Practice Exercises. 4.1 Write the following queries in SQL:

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.

### 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

### 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

### ECS 165A: Introduction to Database Systems

ECS 165A: Introduction to Database Systems Todd J. Green based on material and slides by Michael Gertz and Bertram Ludäscher Winter 2011 Dept. of Computer Science UC Davis ECS-165A WQ 11 1 1. Introduction

### 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

### 6 QUERY-BY-EXAMPLE (QBE)

6 QUERY-BY-EXAMPLE (QBE) Example is always more efficacious than precept. Samuel Johnson 6.1 INTRODUCTION Query-by-Example (QBE) is another language for querying (and, like SQL, for creating and modifying)

### Physical Design. Meeting the needs of the users is the gold standard against which we measure our success in creating a database.

Physical Design Physical Database Design (Defined): Process of producing a description of the implementation of the database on secondary storage; it describes the base relations, file organizations, and

### 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

### SQL Programming. CS145 Lecture Notes #10. Motivation. Oracle PL/SQL. Basics. Example schema:

CS145 Lecture Notes #10 SQL Programming Example schema: CREATE TABLE Student (SID INTEGER PRIMARY KEY, name CHAR(30), age INTEGER, GPA FLOAT); CREATE TABLE Take (SID INTEGER, CID CHAR(10), PRIMARY KEY(SID,

### 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

### Review of Business Information Systems Third Quarter 2013 Volume 17, Number 3

Maintaining Database Integrity Using Data Macros In Microsoft Access Ali Reza Bahreman, Oakland University, USA Mohammad Dadashzadeh, Oakland University, USA ABSTRACT The introduction of Data Macros in

### 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

### SQL DDL. DBS Database Systems Designing Relational Databases. Inclusion Constraints. Key Constraints

DBS Database Systems Designing Relational Databases Peter Buneman 12 October 2010 SQL DDL In its simplest use, SQL s Data Definition Language (DDL) provides a name and a type for each column of a table.

### 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

### Oracle Database 10g Express

Oracle Database 10g Express This tutorial prepares the Oracle Database 10g Express Edition Developer to perform common development and administrative tasks of Oracle Database 10g Express Edition. Objectives

### Physical Database Design Process. Physical Database Design Process. Major Inputs to Physical Database. Components of Physical Database Design

Physical Database Design Process Physical Database Design Process The last stage of the database design process. A process of mapping the logical database structure developed in previous stages into internal

### 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

### 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

### Computer Security: Principles and Practice

Computer Security: Principles and Practice Chapter 5 Database Security First Edition by William Stallings and Lawrie Brown Lecture slides by Lawrie Brown Database Security 1 Relational Databases constructed

### BCA. Database Management System

BCA IV Sem Database Management System Multiple choice questions 1. A Database Management System (DBMS) is A. Collection of interrelated data B. Collection of programs to access data C. Collection of data

### 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)

### Elena Baralis, Silvia Chiusano Politecnico di Torino. Pag. 1. Active database systems. Triggers. Triggers. Active database systems.

Active database systems Database Management Systems Traditional DBMS operation is passive Queries and updates are explicitly requested by users The knowledge of processes operating on data is typically

### 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,

### 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

### 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

### DBMS Questions. 3.) For which two constraints are indexes created when the constraint is added?

DBMS Questions 1.) Which type of file is part of the Oracle database? A.) B.) C.) D.) Control file Password file Parameter files Archived log files 2.) Which statements are use to UNLOCK the user? A.)

### 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

### Overview. Physical Database Design. Modern Database Management McFadden/Hoffer Chapter 7. Database Management Systems Ramakrishnan Chapter 16

HNC Computing - s HNC Computing - s Physical Overview Process What techniques are available for physical design? Physical Explain one physical design technique. Modern Management McFadden/Hoffer Chapter

### Entity Relationship Diagram

Yufei Tao Department of Computer Science and Engineering Chinese University of Hong Kong A primary goal of database design is to decide what tables to create. Usually, there are two principles: 1 Capture

### Principles of Database Management Systems. Overview. Principles of Data Layout. Topic for today. "Executive Summary": here.

Topic for today Principles of Database Management Systems Pekka Kilpeläinen (after Stanford CS245 slide originals by Hector Garcia-Molina, Jeff Ullman and Jennifer Widom) How to represent data on disk

### Database Design. Adrienne Watt. Port Moody

Database Design Database Design Adrienne Watt Port Moody Except for third party materials and otherwise stated, content on this site is made available under a Creative Commons Attribution 2.5 Canada License.

### 1. SELECT DISTINCT f.fname FROM Faculty f, Class c WHERE f.fid = c.fid AND c.room = LWSN1106

Database schema: Department(deptid, dname, location) Student(snum, sname, deptid, slevel, age) Faculty(fid, fname, deptid) Class(cname, time, room, fid) Enrolled(snum, cname) SQL queries: 1. Get the names

### 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

### Programming Database lectures for mathema

Programming Database lectures for mathematics students April 25, 2015 Functions Functions are defined in Postgres with CREATE FUNCTION name(parameter type,...) RETURNS result-type AS \$\$ function-body \$\$

### 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

### The core theory of relational databases. Bibliography

The core theory of relational databases Slide 1 La meilleure pratique... c est une bonne théorie Bibliography M.Levene, G.Loizou, Guided Tour of Relational Databases and Beyond, Springer, 625 pages,1999.

### In This Lecture. SQL Data Definition SQL SQL. Notes. Non-Procedural Programming. Database Systems Lecture 5 Natasha Alechina

This Lecture Database Systems Lecture 5 Natasha Alechina The language, the relational model, and E/R diagrams CREATE TABLE Columns Primary Keys Foreign Keys For more information Connolly and Begg chapter

### 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