For Project 1, Deliverable 4, you will add referential integrity (FOREIGN KEY) constraints to existing tables, as well as composing general assertions.

Slides:



Advertisements
Similar presentations
Relational Database. Relational database: a set of relations Relation: made up of 2 parts: − Schema : specifies the name of relations, plus name and type.
Advertisements

Database Management Systems, R. Ramakrishnan and J. Gehrke1 The Relational Model Chapter 3.
SQL Lecture 10 Inst: Haya Sammaneh. Example Instance of Students Relation  Cardinality = 3, degree = 5, all rows distinct.
Overview Begin 6:00 Quiz15 mins6:15 Review Table Terms25 mins6:40 Short Break10 mins6:50 SQL: Creating Tables60 mins7:50 Break10 mins8:00 Lab – Creating.
Cs3431 Constraints Sections 6.1 – 6.5. cs3431 Example CREATE TABLE Student ( sNum int, sName varchar (20), prof int, CONSTRAINT pk PRIMARY KEY (snum),
THE RELATIONAL DATABASE MODEL & THE DATABASE DEVELOPMENT PROCESS Fact of the Week: According to a Gartner study in ‘06, Microsoft SQL server had the highest.
Monday, 08 June 2015Dr. Mohamed Osman1 What is Database Administration A high level function (technical Function) that is responsible for ► physical DB.
Fundamentals, Design, and Implementation, 9/e COS 346 Day 8.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 3 The Basic (Flat) Relational Model.
Fundamentals, Design, and Implementation, 9/e Chapter 5 Database Design.
1 Relational Model. 2 Relational Database: Definitions  Relational database: a set of relations  Relation: made up of 2 parts: – Instance : a table,
SQL Keys and Constraints Justin Maksim. Key Declaration Key constraint defined within the CREATE TABLE command Key can be declared using either the PRIMARY.
Database Design Concepts INFO1408 Term 2 week 1 Data validation and Referential integrity.
The Relational Database Model. 2 Objectives How relational database model takes a logical view of data Understand how the relational model’s basic components.
CMPT 354, Simon Fraser University, Fall 2008, Martin Ester 157 Database Systems I SQL Constraints and Triggers.
Database Constraints. Database constraints are restrictions on the contents of the database or on database operations Database constraints provide a way.
Chapter 7 Constraints and Triggers Spring 2011 Instructor: Hassan Khosravi.
Database Systems Lecture 5 Natasha Alechina
Midterm 1 Concepts Relational Algebra (DB4) SQL Querying and updating (DB5) Constraints and Triggers (DB11) Unified Modeling Language (DB9) Relational.
Exam 2 Review Dr. Bernard Chen Ph.D. University of Central Arkansas.
The Relational Model These slides are based on the slides of your text book.
For Project 1, Deliverable 4, you will add referential integrity (FOREIGN KEY) constraints to existing tables, as well as composing general assertions.
Assume the following relational schema covering vehicle ownership data (forgive lack of key, or assume that all attributes form the key, for now). Name.
Learningcomputer.com SQL Server 2008 – Entity Relationships in a Database.
Chapter 9 Integrity. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.9-2 Topics in this Chapter Predicates and Propositions Internal vs.
1 CSE 480: Database Systems Lecture 5: Relational Data Model.
Lecture 7 Integrity & Veracity UFCE8K-15-M: Data Management.
DBMS Spring 2014 Database Integrity Sources: Security in Computing, Pfleeger and Pfleeger, Prentice Hall, 2003 Lecture Slides, CSE6243, MSU, Rayford B.
RDBMSSection Relational DBMS DATABASE DEVELOPMENT And Franchise Colleges By MANSHA NAWAZ.
For Project 1, Deliverable 4, you will add referential integrity (FOREIGN KEY) constraints to existing tables, as well as composing general assertions.
1 The Relational Model. 2 Why Study the Relational Model? v Most widely used model. – Vendors: IBM, Informix, Microsoft, Oracle, Sybase, etc. v “Legacy.
For Project 1, Deliverable 3, you will be stepping back from your designs and studying mine. You can edit this file and include your answers here. 120.
FALL 2004CENG 351 File Structures and Data Management1 Relational Model Chapter 3.
Slide Chapter 5 The Relational Data Model and Relational Database Constraints.
Intro to SQL| MIS 2502  Spacing not relevant › BUT… no spaces in an attribute name or table name  Oracle commands keywords, table names, and attribute.
Microsoft Access 2013 Design and Implement Powerful Relational Databases Chapter 6.
Creating Tables and Inserting Records -- Not easy to edit! -- check constraints! Create table test1 ( C1 char(5) primary key, C2 Varchar2(15) not null.
Dec 8, 2003Murali Mani Constraints B term 2004: lecture 15.
Chapter 9 Constraints. Chapter Objectives  Explain the purpose of constraints in a table  Distinguish among PRIMARY KEY, FOREIGN KEY, UNIQUE, CHECK,
Oracle 11g: SQL Chapter 4 Constraints.
7 1 Constraints & Triggers Chapter Constraints and triggers? Constraints: Certain properties that the DBMS is required to enforce –E.g. primary.
Chapter 4 Constraints Oracle 10g: SQL. Oracle 10g: SQL 2 Objectives Explain the purpose of constraints in a table Distinguish among PRIMARY KEY, FOREIGN.
Constraints and Triggers. What’s IC? Integrity Constraints define the valid states of SQL-data by constraining the values in the base tables. –Restrictions.
Chapter 9 Logical Database Design : Mapping ER Model To Tables.
Advanced SQL Concepts - Checking of Constraints CIS 4301 Lecture Notes Lecture /6/2006.
1 CS 430 Database Theory Winter 2005 Lecture 4: Relational Model.
CSE314 Database Systems Lecture 3 The Relational Data Model and Relational Database Constraints Doç. Dr. Mehmet Göktürk src: Elmasri & Navanthe 6E Pearson.
Constraints Lesson 8. Skills Matrix Constraints Domain Integrity: A domain refers to a column in a table. Domain integrity includes data types, rules,
CS34311 The Relational Model. cs34312 Why Relational Model? Currently the most widely used Vendors: Oracle, Microsoft, IBM Older models still used IBM’s.
Connecting (relating) Data Tables to get Custom Records (Queries) Database Basics.
Lecture 03 Constraints. Example Schema CONSTRAINTS.
Dorm Name PK Occupancy Dorm Name PK Occupancy HighResDorm StartDate HighResDorm StartDate LowResDorm StartDate WaterSensorID WaterOnLineDate ElecSensorID.
Constraints and Views Chap. 3-5 continued (7 th ed. 5-7)
Murali Mani Constraints. Murali Mani Keys: Primary keys and unique CREATE TABLE Student ( sNum int, sName varchar (20), dept char (2), CONSTRAINT key.
Constraints Advanced Database Systems Dr. AlaaEddin Almabhouh.
CDT/1 Creating data tables and Referential Integrity Objective –To learn about the data constraints supported by SQL2 –To be able to relate tables together.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 The Relational Model Chapter 3.
1 CS122A: Introduction to Data Management Lecture #4 (E-R  Relational Translation) Instructor: Chen Li.
CENG 351 File Structures and Data Management1 Relational Model Chapter 3.
1 Constraints and Triggers in SQL. 2 Constraints are conditions that must hold on all valid relation instances SQL2 provides a variety of techniques for.
Database Constraints ICT 011. Database Constraints Database constraints are restrictions on the contents of the database or on database operations Database.
Chapter 5 Database Design
Chapter 6: Integrity (and Security)
Constraints and Triggers
COS 346 Day 8.
The Relational Model Relational Data Model
Constraints.
Database Design: Relational Model
INSTRUCTOR: MRS T.G. ZHOU
Integrity 5/5/2019 See scm-intranet.
Presentation transcript:

For Project 1, Deliverable 4, you will add referential integrity (FOREIGN KEY) constraints to existing tables, as well as composing general assertions. TEAM ID: KEY TEAM Members: 1) Copy over your comments /*... */ from Deliverable 3, for each table definition, revised in accordance with my comments on the Deliverable 3 answer. 2) Add FOREIGN KEY constraints to the all table definitions for which they are appropriate. Explicitely show (i.e., no reliance on default settings) all ON DELETE and ON UPDATE actions (use the SQLite options at Explain why you chose these settings in C-style comments (/*... */) immediately after the table definition in which the foreign key constraint is declared. 3) Add any UNIQUE, and other attribute, tuple, and table constraints that you think appropriate. Explain why you chose these UNIQUE declarations in C-style comments (/*... */) immediately after the table definition in which the UNIQUE constraint is declared. 4) For each blank ASSERTION definition, fill in the definition to enforce the conditions as sepecified in header comments. /* Observer associates computer network identifiers (e.g., IP addresses) with campus dormitories. DormName can be NULL, thus allowing easy recording of off-campus (or otherwise non-dorm) network identifiers of virtual visitors to dorm web-based electricity and water usage summaries. */ CREATE TABLE Observer ( NetworkID CHAR(20), DormName VARCHAR(35), PRIMARY KEY (NetworkID), FOREIGN KEY (DormName) REFERENCES Dorm ON DELETE CASCADE ON UPDATE CASCADE ); Worth 100 points Yi: Check if any question Every group submission starts with a default of 85 points, from which grader will add or subtract points as outlined below. This FK constraint was not explicitly asked for, and if it is included in any form (with ON DELETE and ON UPDATE decisions of, then + 2 points (ANY of the ON DELETE and ON UPDATE choices are OK); add an additional +1 point (+3 total) if an explanation given for ON DELETE and ON UPDATE choices For purposes of this assignment, NO ACTION and RESTRICT are synonymous Unless otherwise stated, any ON DELETE and ON UPDATE actions are acceptable, if a reasonable explanation is given Give +3 for any usage (but not for each usage) of SET DEFAULT action, with a good explanation, if the default value for the attribute has been specified in the table definition

/* ADD FOREIGN KEY CONSTRAINT(s) TO THIS TABLE DEFINITION */ /* A record of visits to a Dorm’s (often assembled, on demand) Webpage, which displays statistics on electricity and water usage */ CREATE TABLE DormWebPage ( DWPageID INTEGER, CreateDate DATE NOT NULL, /* NOT NULL indicates field cannot be NULL in any record */ CreateTime TIME NOT NULL, ObserverNetworkID CHAR(20) NOT NULL, /* Corresponds to a NetworkID in Observer */ DormName VARCHAR(35) NOT NULL, /* Corresponds to a DormName in Dorm */ PRIMARY KEY (DWPageID), FOREIGN KEY (ObserverNetworkID) REFERENCES Observer (NetworkID) ON DELETE NO ACTION ON UPDATE CASCADE, // block attempts to DELETE entities FOREIGN KEY (DormName) REFERENCES Dorm // that have participated in observations ON DELETE NO ACTION ON UPDATE CASCADE ); /* Dorms can be high res and low res, and tables for each subtype have an FK reference to Dorm, which contains the common information that is inherited for each type of dorm. Dorms are also FK referenced by a number of other tables. */ CREATE TABLE Dorm ( DormName VARCHAR(35), MaxOccupancy SMALLINT, PRIMARY KEY (DormName) ); Only one of the following should be relevant for each FK constraint -5 for each missing of the two FK constraint; -4 if missing ON DELETE and/or ON UPDATE actions (see point below) -3 for each missing explanation Since ObserverNetworkID and DormName must both be NOT NULL, an action of SET NULL would cause an error. -2 for one or more uses of SET NULL above (not -2 per use of NOT NULL)

/* A table of time-stamped outdoor temperatures (required) and light conditions (optional) */ CREATE TABLE AmbientValues ( AmbientReadingsDate DATE, AmbientReadingsTime TIME, AmbientTemp TINYINT NOT NULL, AmbientLight CHAR(2), PRIMARY KEY (AmbientReadingsDate, AmbientReadingsTime) ); /* ADD FOREIGN KEY CONSTRAINT(s) TO THIS TABLE DEFINITION */ /* Every high res dorm is also a dorm */ CREATE TABLE HighResDorm ( DormName VARCHAR(35), /* Corresponds to a DormName in Dorm */ StartDate DATE, /* Date at which it became a HighResDorm */ PRIMARY KEY (DormName), FOREIGN KEY (DormName) REFERENCES Dorm ON DELETE CASCADE ON UPDATE CASCADE ); Only one of the following should be relevant for this FK constraint -5 if missing the FK constraint; -4 if missing ON DELETE and/or ON UPDATE actions (see point below) -3 for each missing explanation Since DormName is also the PK of this table, it must be NOT NULL, so an action of SET NULL would cause an error. -2 for one or more uses of SET NULL above (not -2 per use of NOT NULL)

/* ADD FOREIGN KEY CONSTRAINT(s) TO THIS TABLE DEFINITION */ /* A LowRes dorm is assumed to have a unique (NOT NULL) electricity sensor, but the definition allows water sensors to be shared across dorms (not unique) and none at all (allowed NULL) */ CREATE TABLE LowResDorm ( DormName VARCHAR(35), /* Corresponds to a DormName in Dorm */ StartDate DATE, /* Date at which it became a LowResDorm */ LRElecSensorID INTEGER NOT NULL, UNIQUE(LRElecSensorID), /* UNIQUE indicates a key; typically implies NOT NULL */ LRElecSensorOnLineDate DATE, LRWaterSensorOnLineDate DATE, LRWaterSensorID INTEGER, PRIMARY KEY (DormName), FOREIGN KEY (DormName) REFERENCES Dorm ON DELETE CASCADE ON UPDATE CASCADE ); /* This assertion insures that there is no Dorm in LowResDorm that is also in HighResDorm, and vice versa. The assertion is checked each time there is a change in LowResDorm or HighResDorm. If the assertion evaluates to TRUE, then there is no violation of the constraint. */ CREATE ASSERTION NoOverlapBetweenHighAndLowRes ( /* FILL IT IN */ CHECK (NOT EXISTS (SELECT * FROM LowResDorm L, HighResDorm H WHERE L.DormName=H.DormName) ); /* OR */ CREATE ASSERTION NoOverlapBetweenHighAndLowRes ( /* FILL IT IN */ CHECK (NOT EXISTS (SELECT DormName FROM LowResDorm INTERSECT SELECT DormName FROM HighResDorm) ); Only one of the following should be relevant for this FK constraint -5 if missing the FK constraint; -4 if missing ON DELETE and/or ON UPDATE actions (see point below) -3 for each missing explanation Since DormName is also the PK of this table, it must be NOT NULL, so an action of SET NULL would cause an error. -2 for one or more uses of SET NULL to left (not -2 per use of NOT NULL) + 3 for EITHER solution to the Assertion above, or another CORRECT ONE

/* ADD FOREIGN KEY CONSTRAINT(s) TO THIS TABLE DEFINITION */ /* For example, FloorNum = 3 and DormName = McGill is 3 rd floor of McGill */ CREATE TABLE Floor ( DormName VARCHAR(35), /* Corresponds to a DormName in HighResDorm */ FloorNum TINYINT, MaxOccupancy SMALLINT, PRIMARY KEY (DormName, FloorNum), FOREIGN KEY (DormName) REFERENCES HighResDorm ON DELETE CASCADE ON UPDATE CASCADE ); /* ADD FOREIGN KEY CONSTRAINT(s) TO THIS TABLE DEFINITION */ /* Similar meanings as DormWebPage, but for high res case */ CREATE TABLE FloorWebPage ( DormName VARCHAR(35), /* Corresponds to DormName in Floor */ FloorNum TINYINT, /* Corresponds to FloorNum in Floor */ FWPageID INTEGER, CreateDate DATE NOT NULL, CreateTime TIME NOT NULL, ObserverNetworkID CHAR(20) NOT NULL, /* Corresponds to NetworkID in Observer */ PRIMARY KEY (FWPageID), FOREIGN KEY (ObserverNetworkID) REFERENCES Observer (NetworkID), ON DELETE NO ATION ON UPDATE CASCADE, /* block deletes if Network ID has observation records */ FOREIGN KEY (DormName, FloorNum) REFERENCES Floor ON DELETE NO ACTION ON UPDATE CASCADE /* block deletes if floor has observation records */ ); Only one of the following should be relevant for each of the FK constraints on this page -5 if missing the FK constraint; -4 if missing ON DELETE and/or ON UPDATE actions (see point below) -3 for each missing explanation Since DormName is also IN the PK of this table, it must be NOT NULL, so an action of SET NULL would cause an error. -2 for one or more uses of SET NULL to left (not -2 per use of NOT NULL) Since ObserverNetworkID is NOT NULL an action of SET NULL would cause an error. -2 for one or more uses of SET NULL to left (not -2 per use of NOT NULL) +2 for making BOTH DormName and FloorNum NOT NULL

/* ADD FOREIGN KEY CONSTRAINT(s) TO THIS TABLE DEFINITION */ /* Definition allows multiple sensors per floor (thus, DormName,Floor not required UNIQUE) */ CREATE TABLE HRElecSensor ( DormName VARCHAR(35) NOT NULL, /* Corresponds to DormName in Floor */ FloorNum TINYINT NOT NULL, /* Corresponds to FloorNum in Floor */ HRElecSensorID INTEGER, HRElecSensorOnLineDate DATE, PRIMARY KEY (HRElecSensorID), FOREIGN KEY (DormName, FloorNum) REFERENCES Floor ON DELETE CASCADE ON UPDATE CASCADE ); /* ADD FOREIGN KEY CONSTRAINT(s) TO THIS TABLE DEFINITION */ /* If you bother to record a reading, the value should be NOT NULL (perhaps coupled special value(e.g., -999) indicating not read because not functional sensor */ CREATE TABLE HREReading ( HRElecSensorID INTEGER, /* Corresponds to HRElecSensorID in HRElecSensor */ HREReadingDate DATE, HREReadingTime TIME, HREValue INTEGER NOT NULL, PRIMARY KEY (HRElecSensorID, HREReadingDate, HREReadingTime), FOREIGN KEY (HRElecSensorID) REFERENCES HRElecSensor ON DELETE NO ACTION /* if readings associated with a sensor, then block delete */ ON UPDATE CASCADE ); Only one of the following should be relevant for each of the FK constraints on this page -5 if missing the FK constraint; -4 if missing ON DELETE and/or ON UPDATE actions (see point below) -3 for each missing explanation SET NULL is NOT an option for any of them (-2)

/* ADD FOREIGN KEY CONSTRAINT(s) TO THIS TABLE DEFINITION */ /* As with elect sensors in high res case, definition allows multiple sensors per floor (thus, DormName,Floor not required UNIQUE) */ CREATE TABLE HRWSensor ( DormName VARCHAR(35) NOT NULL, /* Corresponds to DormName in Floor */ FloorNum TINYINT NOT NULL, /* Corresponds to FloorNum in Floor */ HRWaterSensorID INTEGER, HRWaterSensorOnLineDate DATE, PRIMARY KEY (HRWaterSensorID), FOREIGN KEY (DormName, FloorNum) REFERENCES Floor ON DELETE CASCADE ON UPDATE CASCADE ); /* ADD FOREIGN KEY CONSTRAINT(s) TO THIS TABLE DEFINITION */ /* Comment here */ CREATE TABLE HRWReading ( HRWaterSensorID INTEGER, /* Corresponds to HRWaterSensorID in HRWaterSensor */ HRWReadingDate DATE, HRWReadingTime TIME, HRWValue INTEGER NOT NULL, PRIMARY KEY (HRWaterSensorID, HRWReadingDate, HRWReadingTime), FOREIGN KEY (HRWaterSensorID) REFERENCES HRWaterSensor ON DELETE NO ACTION /* if readings associated with a sensor, then block delete */ ON UPDATE CASCADE ); Only one of the following should be relevant for each of the FK constraints on this page -5 if missing the FK constraint; -4 if missing ON DELETE and/or ON UPDATE actions (see point below) -3 for each missing explanation SET NULL is NOT an option for any of them (-2)

/* ADD FOREIGN KEY CONSTRAINT(s) TO THIS TABLE DEFINITION */ /* The earlier definition of LowResDorm indicates exactly one sensor per low res dorm */ CREATE TABLE LREReading ( DormName VARCHAR(35), /* Corresponds to DormName in LowResDorm */ LREReadingDate DATE, LREReadingTime TIME, LREValue INTEGER NOT NULL, PRIMARY KEY (DormName, LREReadingDate, LREReadingTime), FOREIGN KEY (DormName) REFERENCES LowResDorm ON DELETE NO ACTION /* if readings associated with a low res dorm, then block delete */ ON UPDATE CASCADE ); /* ADD FOREIGN KEY CONSTRAINT(s) TO THIS TABLE DEFINITION */ /* The earlier definition of LowResDorm indicates at most one water sensor per low res dorm */ CREATE TABLE LRWReading ( DormName VARCHAR(35), /* Corresponds to DormName in LowResDorm */ LRWReadingDate DATE, LRWReadingTime TIME, LRWValue INTEGER NOT NULL, PRIMARY KEY (DormName, LRWReadingDate, LRWReadingTime) FOREIGN KEY (DormName) REFERENCES LowResDorm ON DELETE NO ACTION /* if readings associated with a sensor, then block delete */ ON UPDATE CASCADE ); Only one of the following should be relevant for each of the FK constraints on this page -5 if missing the FK constraint; -4 if missing ON DELETE and/or ON UPDATE actions (see point below) -3 for each missing explanation SET NULL is NOT an option for any of them (-2)

/* Insure all Dorms are Low Res or High Res; another assertion required to insure no overlap (exclusive or) */ CREATE ASSERTION CompleteCoverOverLowAndHighRes ( /* FILL IT IN */ CHECK (NOT EXISTS (SELECT D.DormName FROM Dorm D EXCEPT SELECT LRD.DormName FROM LowResDorm LRD) EXCEPT SELECT HRD.DormName FROM HighResDorm HRD ))); /* OR PERHAPS */ CREATE ASSERTION CompleteCoverOverLowAndHighRes ( /* FILL IT IN */ CHECK (NOT EXISTS (SELECT D.DormName FROM Dorm D EXCEPT (SELECT LRD.DormName FROM LowResDorm LRD) UNION SELECT HRD.DormName FROM HighResDorm HRD) ))); /* OR PERHAPS */ CREATE ASSERTION CompleteCoverOverLowAndHighRes ( /* FILL IT IN */ CHECK (NOT EXISTS (SELECT D.DormName FROM Dorm D WHERE D.DormName NOT IN (SELECT LRD.DormName FROM LowResDorm LRD) UNION SELECT HRD.DormName FROM HighResDorm HRD) ))); /* OR PERHAPS */ CREATE ASSERTION CompleteCoverOverLowAndHighRes ( /* FILL IT IN */ CHECK (NOT EXISTS (SELECT D.DormName FROM Dorm D WHERE D.DormName NOT IN (SELECT LRD.DormName FROM LowResDorm LRD) AND D.DormName NOT IN (SELECT HRD.DormName FROM HighResDorm HRD) ))); + 3 for ANY of THESE solution to the Assertion above, or another CORRECT ONE EVEN SMALL DIFFERENCES MAKE THESE ANSWERS WRONG (e.g., a missing NOT, and therefore no additional points)

/* Insure that each Floor of a high res dorm is associated with at least one electricity sensor */ CREATE ASSERTION FloorParticipatesHRElecSensor ( /* FILL IT IN */ CHECK (NOT EXISTS (SELECT * FROM Floor F WHERE (F.DormName, F.FloorNum) NOT IN (SELECT HRES.DormName, HRES.FloorNum FROM HRElecSensor HRES))) ); CREATE ASSERTION FloorParticipatesHRElecSensor CHECK (NOT EXISTS (SELECT F.DormName, F.FloorNum FROM Floor F EXCEPT SELECT HRES.DormName, HRES.FloorNum FROM HRElecSensor HRES) ); CREATE ASSERTION FloorParticipatesHRElecSensor ( /* A complicated version of first solution */ CHECK (NOT EXISTS (SELECT * FROM Floor F WHERE F.DormName NOT IN (SELECT HRES.DormName FROM HRElecSensor HRES WHERE HRES.FloorNum = F.FloorNum) OR F.FloorNum NOT IN (SELECT HRES.FloorNum FROM HRElecSensor HRES WHERE HRES.DormName = F.DormName) ); + 3 for ANY of THESE solution to the Assertion above, or another CORRECT ONE EVEN SMALL DIFFERENCES MAKE THESE ANSWERS WRONG (e.g., a missing NOT, and therefore no additional points)

/* Insure that each Floor of a high res dorm is associated with at least one electricity sensor */ Why don’t these work? CREATE ASSERTION FloorParticipatesHRElecSensor ( CHECK (EXISTS (SELECT F.DormName, F.FloorNum FROM HRElecSensor HRES, Floor F WHERE HRES.DormName = F.DormName AND HRES.FloorNum = F.FloorNum) ); CREATE ASSERTION FloorParticipatesHRElecSensor ( CHECK (EXISTS (SELECT * FROM Floor F WHERE (F.DormName, F.FloorNum) IN (SELECT HRES.DormName, HRES.FloorNum FROM HRElecSensor HRES)))

Reflect on these questions. You do NOT need to answer and submit them in writing, but they will be topics of discussion. a) If you try to delete a row in Observer that has one or more ‘associated’ entries in DormWebPage, what will happen? b) If you try to delete a Dorm, for which no one has ever looked at (Observed) a DormWebPage for it, what will happen? c) If you try to delete a Dorm, for which there have been one or more recorded views of DormWebPages for it, what will happen? d) How many electricity sensors are associated with a low res dorm (so far as the DB encodes)? And vice versa? e) How many electricity sensors are associated with a high res dorm (so far as the DB encodes)? f) Could the current database design (tables and assertions) support the situation of a low res dorm becoming a high res dorm WITHOUT losing past data from its low res days? If so, explain, and if not, explain what changes to the DB design you might make to support this (high likelihood eventuality) PRIOR to DB implementation. g) How could the DB design be changed to support records of room and plug level measurements of electricity (and perhaps faucet level water readings)? Use discretion in awarding up to 1 point more based on insightful constraint or explanation