Relationele Databases 2002/2003



Similar documents
Relationele Databases 2002/2003

Introduction to SQL ( )

Chapter 6: Integrity Constraints

Exercise 1: Relational Model

SQL DATA DEFINITION: KEY CONSTRAINTS. CS121: Introduction to Relational Database Systems Fall 2015 Lecture 7

Chapter 6: Integrity and Security. Domain Constraints

SQL NULL s, Constraints, Triggers

Databases What the Specification Says

Review: Participation Constraints

DATABASE NORMALIZATION

How To Create A Table In Sql (Ahem)

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

Databasesystemer, forår 2005 IT Universitetet i København. Forelæsning 3: Business rules, constraints & triggers. 3. marts 2005

Lecture 6. SQL, Logical DB Design

COSC344 Database Theory and Applications. Lecture 9 Normalisation. COSC344 Lecture 9 1

Triggers & Packages. {INSERT [OR] UPDATE [OR] DELETE}: This specifies the DML operation.

The Relational Model. Why Study the Relational Model? Relational Database: Definitions

The Structured Query Language. De facto standard used to interact with relational DB management systems Two major branches

Outline. Data Modeling. Conceptual Design. ER Model Basics: Entities. ER Model Basics: Relationships. Ternary Relationships. Yanlei Diao UMass Amherst

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

14 Triggers / Embedded SQL

Database Design Overview. Conceptual Design ER Model. Entities and Entity Sets. Entity Set Representation. Keys

Scheme G. Sample Test Paper-I

Chapter 7: Relational Database Design

The Relational Model. Ramakrishnan&Gehrke, Chapter 3 CS4320 1

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

You can use command show database; to check if bank has been created.

The Relational Model. Why Study the Relational Model? Relational Database: Definitions. Chapter 3

The Relational Model. Why Study the Relational Model?

CS 377 Database Systems. Database Design Theory and Normalization. Li Xiong Department of Mathematics and Computer Science Emory University

Database Design Process. ER Model. Goals. Relational Model. SQL - The Language of Databases. IT420: Database Management and Organization

Data Modeling. Database Systems: The Complete Book Ch ,

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

AUTHENTICATION... 2 Step 1:Set up your LDAP server... 2 Step 2: Set up your username... 4 WRITEBACK REPORT... 8 Step 1: Table structures...

Conceptual Design Using the Entity-Relationship (ER) Model

New York University Computer Science Department Courant Institute of Mathematical Sciences

Boyce-Codd Normal Form

CSCI-GA Database Systems Lecture 7: Schema Refinement and Normalization

IT2304: Database Systems 1 (DBS 1)

SQL is capable in manipulating relational data SQL is not good for many other tasks

DATABASE MANAGEMENT SYSTEMS. Question Bank:

IT2305 Database Systems I (Compulsory)

CSC 443 Data Base Management Systems. Basic SQL

Graham Kemp (telephone , room 6475 EDIT) The examiner will visit the exam room at 15:00 and 17:00.

BCA. Database Management System

A basic create statement for a simple student table would look like the following.

1 Structured Query Language: Again. 2 Joining Tables

EECS 647: Introduction to Database Systems

MCQs~Databases~Relational Model and Normalization

Introduction to database management systems

Foreign and Primary Keys in RDM Embedded SQL: Efficiently Implemented Using the Network Model

Answer Key. UNIVERSITY OF CALIFORNIA College of Engineering Department of EECS, Computer Science Division

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

SQL Tables, Keys, Views, Indexes

Improving Data Quality in Relational Databases: Overcoming Functional Entanglements

ATTACHMENT 6 SQL Server 2012 Programming Standards

Schema Design and Normal Forms Sid Name Level Rating Wage Hours

Converting E-R Diagrams to Relational Model. Winter Lecture 17

Chapter 15 Basics of Functional Dependencies and Normalization for Relational Databases

Figure 4.12.Insurancedatabase.

Theory of Relational Database Design and Normalization

Chapter 1: Introduction. Database Management System (DBMS)

Normalization. Reduces the liklihood of anomolies

LiTH, Tekniska högskolan vid Linköpings universitet 1(7) IDA, Institutionen för datavetenskap Juha Takkinen

RELATIONAL DATABASE DESIGN

Relational model. Relational model - practice. Relational Database Definitions 9/27/11. Relational model. Relational Database: Terminology

Chapter 10. Functional Dependencies and Normalization for Relational Databases

Advance DBMS. Structured Query Language (SQL)

Part A: Data Definition Language (DDL) Schema and Catalog CREAT TABLE. Referential Triggered Actions. CSC 742 Database Management Systems

The Entity-Relationship Model

Introduction to Databases

Normalization in OODB Design

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

Chapter 5. SQL: Queries, Constraints, Triggers

Functional Dependencies and Finding a Minimal Cover

Chapter 5: Logical Database Design and the Relational Model Part 2: Normalization. Introduction to Normalization. Normal Forms.

More on SQL. Juliana Freire. Some slides adapted from J. Ullman, L. Delcambre, R. Ramakrishnan, G. Lindstrom and Silberschatz, Korth and Sudarshan

2. Basic Relational Data Model

Question 1. Relational Data Model [17 marks] Question 2. SQL and Relational Algebra [31 marks]

IENG2004 Industrial Database and Systems Design. Microsoft Access I. What is Microsoft Access? Architecture of Microsoft Access

Chapter 8. Database Design II: Relational Normalization Theory

Theory of Relational Database Design and Normalization

Schema Refinement and Normalization

Database Management System

Tutorial on Relational Database Design

public class ResultSetTable implements TabelModel { ResultSet result; ResultSetMetaData metadata; int num cols;

CS2Bh: Current Technologies. Introduction to XML and Relational Databases. The Relational Model. The relational model

Database Management Systems 2015

Database Design. Goal: specification of database schema Methodology: E-R Model is viewed as a set of

Functional Dependencies

Using SQL Server Management Studio

CPS352 Database Systems: Design Project

Instant SQL Programming

Chapter 1: Introduction

Oracle Database 10g Express

3. Relational Model and Relational Algebra


Normalisation to 3NF. Database Systems Lecture 11 Natasha Alechina

Database Management Systems. Redundancy and Other Problems. Redundancy

Transcription:

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 ( 7.1 7.7). RDB Design 2 3 Docenten: Huishoudelijke Zaken 1. Jaap Kamps, Email: kamps@science.uva.nl 2. Maarten de Rijke, Email: mdr@science.uva.nl URL voor de cursus: http://www.science.uva.nl/~kamps/rdb/, of http://www.science.uva.nl/~mdr/teaching/rdb/0203/ Practicum http://www.science.uva.nl/~borkur/teaching/rdb0203/ Tweede inleveropdracht wordt nagekeken... Deadline derde inleveropdracht: 20 juni 2002! 6.2 Consider the following relational database: employee(employee-name,street,city) works(employee-name, company-name, salary) company(company-name, city) manages(employee-name, manager-name) Give an SQL DDL definition of this database. Identify referentialintegrity constraints that should hold, and include them in the DDL definition. Er zijn alternatieve data typen, en andere keuzes voor not null mogelijk. 4 5 create table employee (employee-name char(20), street char(30), city char(30), primary key (employee-name)) create table works (employee-name char(20), company-name char(15), salary integer, primary key (employee-name), foreign key (employee-name) references employee, foreign key (company-name) references company) create table company (company-name char(15), city char(30), primary key (company-name)) create table manages (employee-name char(20), manager-name char(20), primary key (employee-name), foreign key (employee-name) references employee, foreign key (manager-name) references employee) 6 7 6.3 Referential-integrity constraints as defined in this chapter involve exactly two relations. Consider a database that includes the following relations: salaried-worker(name, office, phone, salary) hourly-worker(name, hourly-wage) address(name, street, city) Suppose that we wish to require that every name that appears in address appear in either salaried-worker or hourly-worker, but not necessarily in both. a Propose a syntax for expressing such constraints. b Discuss the actions that the system must take to enforce a constraint of this form. 6.3 (a) Propose a syntax for expressing such constraints. For simplicity, we present a variant of the SQL syntax. As part of the create table expression for address we include foreign key (name) references salaried-worker or hourly-worker 6.3 (b) Discuss the actions that the system must take to enforce a constraint of this form. To enforce this constraint, whenever a tuple is inserted into the address relation, a lookup on the name valuemust bemade on the salaried-worker relation and (if that lookup failed) on the hourlyworker relation (or vice-versa).

8 9 6.5 Suppose there are two relations r and s, such that the foreign key B of r references the primary key A of s. Describe how the trigger mechanism can be used to implement the on delete cascade option, when a tuple is deleted from s. We define triggers for each relation whose primary-key is referred to by the foreign-key of some other relation. The trigger would be activated whenever a tuple is deleted from the referred-to relation. The action performed by the trigger would be to visit all the referring relations, and delete all the tuples in them whose foreignkey attribute value is the same as the primary-key attribute value of the deleted tuple in the referred-to relation. These set of triggers will take care of the on delete cascade operation. 6.7 Write an SQL trigger to carry out the following action: On delete of an account, for each owner of the account, check if the owner has any remaining accounts, and if she does not, delete her from the depositor relation. create trigger check-delete-trigger after delete on account referencing old row as orow for each row delete from depositor where depositor.customer-name not in (select customer-name from depositor where account-number <> orow.account-number ) end 10 11 Database System Concepts Hoofdstuk 7 Over Relationele Database Design. Wat is een goede database? Loss-less join decomposition Functionele afhankelijkheden Normaalvormen: BCNF en 3NF 12 13 14 15

16 17 18 19 20 21 22 23

24 25 26 27 28 29 30 31

32 33 34 35 36 37 38 39

40 41 42 43 44 45 46 47

48 49 50 51 52 53 54 55

56 57 58 59 60 61 Overzicht Vandaag Database System Concepts. Hoofdstuk 7: RDB Design ( 7.1 7.7). Opgaven: 6.2 6.3 6.5 6.7 62 63 Volgende Week bij Relationele Databases End! Opgaven voor volgende week: 7.1, 7.3, 7.5, 7.9, 7.12, 7.16, 7.20, 7.21, 7.23, en 7.24 Database System Concepts. XML (Hoofdstuk 10).