COP 5725 Project Submission 2 Relational Schema & SQL

Similar documents
Create a simple database with MySQL

EGCI 321: Database Systems. Dr. Tanasanee Phienthrakul

Translating an ER Diagram to a Relational Schema

Normalization Rule. First Normal Form (1NF) Normalization rule are divided into following normal form. 1. First Normal Form. 2. Second Normal Form

The DBMS accepts requests for data from the application program and instructs the operating system to transfer the appropriate data.

A7-R3: INTRODUCTION TO DATABASE MANAGEMENT SYSTEMS

Conceptual Design. The Entity-Relationship (ER) Model

Normalization. Murali Mani. What and Why Normalization? To remove potential redundancy in design

Normalization in DBMS

CONCEPTUAL DESIGN: ER TO RELATIONAL TO SQL

ACS-3902 Fall Ron McFadyen 3D21 Slides are based on chapter 5 (7 th edition) (chapter 3 in 6 th edition)

SQL - Subqueries and. Schema. Chapter 3.4 V4.0. Napier University

Chapter 3. Introduction to relational databases and MySQL. 2010, Mike Murach & Associates, Inc. Murach's PHP and MySQL, C3

COSC Assignment 2

HCW Human Centred Web. HuCEL: Keywords Experiment Manual. School of Computer Science. Information Management Group

Department of Computer Science University of Cyprus. EPL342 Databases. Lab 2

Introduction to relational databases and MySQL

MIDTERM EXAMINATION Spring 2010 CS403- Database Management Systems (Session - 4) Ref No: Time: 60 min Marks: 38

Computer Science 597A Fall 2008 First Take-home Exam Out: 4:20PM Monday November 10, 2008 Due: 3:00PM SHARP Wednesday, November 12, 2008

MTA Database Administrator Fundamentals Course

The Entity-Relationship Model. Overview of Database Design

Homework 3: Relational Database Design Theory (100 points)

CSE 544 Principles of Database Management Systems. Magdalena Balazinska Winter 2009 Lecture 4 - Schema Normalization

DATABASE MANAGEMENT SYSTEMS

Oracle Database 10g Express

Database Management Systems Paper Solution

Draw an ER diagram that encodes the following business rules. Clearly mark all key and participation constraints.

Babu Banarasi Das National Institute of Technology and Management

The University of Nottingham

Database Systems CSci 4380 Midterm Exam #2 March 25, 2018 SOLUTIONS

CSE 444 Midterm Test

CS 338: Computer Applications in Business: Databases

Chapter 4. Basic SQL. Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Introduction to SQL. IT 5101 Introduction to Database Systems. J.G. Zheng Fall 2011

Chapter 3 Introduction to relational databases and MySQL

Midterm Review. Winter Lecture 13

Tutorial 2: Relational Modelling

Database Management Systems (COP 5725) (Spring 2007)

CSE 544 Principles of Database Management Systems. Magdalena Balazinska Fall 2009 Lecture 3 - Schema Normalization

Where Are We? Next Few Lectures. Integrity Constraints Motivation. Constraints in E/R Diagrams. Keys in E/R Diagrams

The Relational Model. Week 2

Homework Assignment 3. November 11th, 2014 Due on November 25th, 12:30pm (noon) CS425 - Database Organization Results

1. Considering functional dependency, one in which removal from some attributes must affect dependency is called

Schema Normalization. 30 th August Submitted By: Saurabh Singla Rahul Bhatnagar

Data Storage and Query Answering. Data Storage and Disk Structure (4)

The Relational Model 2. Week 3

The Relational Model

Basic SQL. Basic SQL. Basic SQL

Database Design. Database Design I: The Entity-Relationship Model. Entity Type (con t) Representation in Relational Model.

High-Level Database Models (ii)

CSE 444, Winter 2011, Midterm Examination 9 February 2011

Midterm Exam #1 Version A CS 122A Winter 2017

Project Deliverable 2 Creating your Database

Midterm Exam #1 Version B CS 122A Winter 2017

Database Applications (15-415)

ER to Relational Model. Professor Jessica Lin

FUNCTIONAL DEPENDENCIES

Applied Databases. Sebastian Maneth. Lecture 5 ER Model, normal forms. University of Edinburgh - January 25 th, 2016

DATABASE DEVELOPMENT (H4)

Relational Algebra and SQL

Examination paper for TDT4145 Data Modelling and Database Systems

COSC344 Database Theory and Applications. Lecture 5 SQL - Data Definition Language. COSC344 Lecture 5 1

Chapter 1 SQL and Data

Introduction to ERwin

ER to Relational Mapping

From ER to Relational Model. Book Chapter 3 (part 2 )

Bachelor in Information Technology (BIT) O Term-End Examination

Basic SQL. Dr Fawaz Alarfaj. ACKNOWLEDGEMENT Slides are adopted from: Elmasri & Navathe, Fundamentals of Database Systems MySQL Documentation

CHAPTER 11. Data Normalization

COMP7640 Assignment 2

Keys are fields in a table which participate in below activities in RDBMS systems:

Advance Database Management System

Functional Dependencies CS 1270

CSE 562 Database Systems

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

Chapter 4. The Relational Model

Homework 2. Develop an EER model for the following situation using the EER diagram,

Chapter 7: Entity-Relationship Model

Relational model continued. Understanding how to use the relational model. Summary of board example: with Copies as weak entity

SOLUTIONS TO THE FINAL EXAMINATION Introduction to Database Design Spring 2011

Chapter 7: Entity-Relationship Model

High Level Database Models

Introduction to SQL Part 1 By Michael Hahsler based on slides for CS145 Introduction to Databases (Stanford)

Introduction to Data Management. Lecture #5 Relational Model (Cont.) & E-Rà Relational Mapping

Database Management Systems,

3ISY402 DATABASE SYSTEMS

Carnegie Mellon University Department of Computer Science /615 - Database Applications C. Faloutsos & A. Pavlo, Spring 2014.

Database Systems ( 資料庫系統 )

Learning outcomes. On successful completion of this unit you will: 1. Understand data models and database technologies.

Mobile MOUSe MTA DATABASE ADMINISTRATOR FUNDAMENTALS ONLINE COURSE OUTLINE

Review. S V T Ma Mo N A S. Mo Ma T

CS 461: Database Systems. Final Review. Julia Stoyanovich

Exam. Question: Total Points: Score:

Data about data is database Select correct option: True False Partially True None of the Above

CSCI 403: Databases 13 - Functional Dependencies and Normalization

Applied Databases. Sebastian Maneth. Lecture 5 ER Model, Normal Forms. University of Edinburgh - January 30 th, 2017

8) A top-to-bottom relationship among the items in a database is established by a

CSE-3421 Test #1 Design

One-to-One relationship - In this scenario both sides of the relationship have - unique values for every row.

Chapter 7: Entity-Relationship Model

Transcription:

COP 5725 Project Submission 2 Relational Schema & SQL Chandra Shekar Cherukuri 6610-6717 Nitin Gujral 4149-1481 Srirama Tejaswi 7521-6735 Rajesh Sindhu 4831-2035

QUESTION 1 : Persons Is a Is a Is a Is a Is a Analyst Subject Therapist Collector Attendee requests Plan for Manages Evaluation Info of Subject Record Conducts collector Treatment Plan has multiple Collection Period Occurred during may occur Behavioral Events Response to Behaviors Belong Behavior Category to

Entity Evaluations Collection Period Behavior Behavior Categories Plan Behavioral Events Subject Record Persons Attributes Evaluation Id EvaluationId, Start time, end time behaviorid, description categoryid, description Plan notes, subjectid Event Id, Occurred-at, response to, behavior Of, Duration record info Name, person Id, type, gender, email, DOB

Relational Schema for attached E-R Diagram

Relational Schema for Our E-R Diagram

QUESTION 4 : Advantages of our schema: 1. Our ER and Schema are more cleaner and more expressive in terms of entities and what role each entity is performing in the overall schema of things. Entities are more understandable and expressive and entities are very specific in defining the role i.e. there is no ambiguity in design. 2. In the schema presented in item 3, attributes are being duplicated i.e. in the presented schema StudentId, AnalystId, TherapistId and collector id are being used many times. Our schema has eliminated duplication of attributes. 3. In the presented ER, there is no possible way to monitor behaviors within a collection period, which is the major requirement of project. There should be some provision for this; our ER has provision to monitor behaviors within a collection period and generate detailed reports. 4. There is provision for treatment plan in our schema. This will help in maintaining treatment plan for the subject. It will keep records of the entire requirement for treatment of patient. 5. In the ER presented in item 2, since therapist is optional.there will be lots of null attributes in the schema. Presented schema s advantages: 1. Since there would be lesser joins to extract information from the schema, it would be more efficient during report generation. This is because SubjectId, Therapist Id and AnalystId are being used in most of the tables hence, reducing ambiguity. 2. There is a clear distinction between a subject and other entities because there is separate table for subject in the presented schema. 3. This schema would be efficient for collective analysis, for example: To find all the behavior s portrayed by the subject during a collection period.

QUESTION 5 : Given Schema Functional Dependencies : Person table: PersonId Name Subject table: PersonId SSN SSN DOB,Name CollectionPeriod table: EvaluationId,startTime TherapistId,endTime,CollecterId CollecterId, starttime TherapistId,endTime,EvaluationId Evaluation table: EvaluationId date,location,analystid,subjectid Behavior table: Name description Category table: Name description CollectionPeriod_Attendees table: EvaluationId,startTime AttendeeId Event table: EventId Description, date-time,subjectid,attendeeid Person_CollectionPeriod_Behavior table Personid,startTime,evaluationId,BehaviorName duration,time Subject_Behavior_Presents: SubjectId,startTime,evaluationId,BehaviorName duration,time,response Behavior_Category:

Our Schema Functional Dependencies : Person: PersonId Name,type,email,gender,DOB Evaluation: EvaluationId date, analystid,subjectid CollectionPeriod: CollectionPeriodId EvaluationId,TherapistId,CollectorId,startTime,endTime EvaluationId,startTime CollectionPeriodID EvaluationId,startTime TherapistId,CollectorId, endtime CollectionPeriod_Evaluation Behaviors: BehaviorId Behaviorname,Info Behavior_CollectionPeriod: BehavioralEvent: EventID CollectionPeriodId,response,duration,info,behaviorId,starttime CollectionPeriodId,starttime BehaviorId,response,duration,info Categories: CategoryId Categoryname,Info Behavior_Category Subject_Record: AttendeeId,SubjectId,EvaluationId RecordInfo TreatmentPlan: AnalystId,SubjectId PlanInfo,time Trivial Dependencies have been omitted.

QUESTION 6 : Given Schema : Person table: PersonId Name Subject table: PersonId SSN, DOB SSN DOB This table is not in BCNF because a non-key attribute SSN derives DOB attribute. This table is split into : Person_Subject{PersonId, SSN} Subject_Info{SSN, DOB} This resolves the Transitive Functional Dependencies. This table is now in BCNF Needs To be converted to BCNF. CollectionPeriod table: EvaluationId,startTime TherapistId,endTime,CollecterId Candidate Key Evaluation table: EvaluationId date,location,analystid,subjectid Behavior table: Name description Category table: Name description CollectionPeriod_Attendees table: EvaluationId,startTime AttendeeId Candidate Key

Event table: EventId Description, date-time,subjectid,attendeeid Person_CollectionPeriod_Behavior table Personid,startTime,evaluationId,BehaviorName duration,time Candidate Key Subject_Behavior_Presents: SubjectId,startTime,evaluationId,BehaviorName duration, Candidate Key Behavior_Category:

Our Schema : Person: PersonId Name,type,email,gender,DOB Evaluation: EvaluationId date, analystid,subjectid CollectionPeriod: EvaluationId, starttime TherapistId, CollectorId, endtime Candidate Key CollectionPeriod_Evaluation Behaviors: BehaviorId Behaviorname,Info Behavior_CollectionPeriod: BehavioralEvent: EventID evaluationid, starttime, response, duration, info, behaviorid Candidate Key EvaluationId, starttime BehaviorId, response, duration, info

Categories: CategoryId Categoryname,Info Behavior_Category Subject_Record: AttendeeId,SubjectId,EvaluationId RecordInfo Candidate Key TreatmentPlan: AnalystId,SubjectId PlanInfo,time Candidate Key * Trivial Functional Dependencies have been omitted.

QUESTION 7 : Advantages of our schema after BCNF: 1. Our schema has more clearer attributes and fulfills the specification much better than the BCNF schema derived from the ER diagram given in the question. 2. Schema derived from the ER diagram given in the question has split the behavioral events of Subject and Persons other than subject). Our schema stored it based on behavioral events rather than basing it on Persons. We believe our schema will be easier to query when we have to select the events of a given collection period. Presented schema s advantages after BCNF: 1. The maintainence of the tables will be easier as the Schema derived from the ER diagram given in the question has split the behavioral events of Subject and Persons other than subject).

QUESTION 8 : SQL Script to generate our schema : CREATE TABLE Person name VARCHAR2 20) NOT NULL, personid INTEGER PRIMARY KEY, SSN VARCHAR2 10) UNIQUE NOT NULL, type VARCHAR2 20) CHECK type in 'ANALYST', 'THERAPIST', 'SUBJECT', 'COLLECTOR', 'ATTENDEE')), email VARCHAR2 20), gender CHAR 1) CHECK gender in 'M','F')), DOB DATE NOT NULL, check email like '%@%.%' and SSN like '%-%-%') ); CREATE TABLE Evaluation analystid INTEGER REFERENCES PersonpersonId), evaluationid INTEGER PRIMARY KEY, subjectid INTEGER NOT NULL REFERENCES PersonpersonId), "date" DATE NOT NULL ); CREATE TABLE CollectionPeriod evaluationid INTEGER REFERENCES EvaluationevaluationId) NOT NULL, therapistid INTEGER REFERENCES PersonpersonId), collectorid INTEGER REFERENCES PersonpersonId) NOT NULL, starttime DATE NOT NULL, endtime DATE NOT NULL, Constraint CollectionPeriod_PK PRIMARY KEY evaluationid, starttime ) ); CREATE TABLE Behaviors behaviorid INTEGER PRIMARY KEY, behaviorname DATE NOT NULL, behaviorinfo VARCHAR2 100) ); CREATE TABLE Behavior_CollectionPeriod behaviorid INTEGER REFERENCES BehaviorsbehaviorId), evaluationid INTEGER, collectionperiodstarttime DATE, CONSTRAINT bcp_fk FOREIGN KEYevaluationId, collectionperiodstarttime) REFERENCES CollectionPeriodevaluationId, starttime), CONSTRAINT bcp_pk PRIMARY KEYevaluationId, collectionperiodstarttime) ) ; CREATE TABLE Behavioral_Event behavioral_eventid INTEGER PRIMARY KEY,

response INTEGER, duration INTEGER NOT NULL, information VARCHAR2 100), behaviorid INTEGER REFERENCES BehaviorsbehaviorId) NOT NULL, time TIMESTAMP 0) NOT NULL ); CREATE TABLE Categories categoryid INTEGER PRIMARY KEY, category_name VARCHAR2 20) UNIQUE NOT NULL, category_info VARCHAR2 100) NOT NULL ); CREATE TABLE Category_Behavior categoryid INTEGER REFERENCES CategoriescategoryId) NOT NULL, behaviorid INTEGER REFERENCES BehaviorsbehaviorId) NOT NULL ) ; CREATE TABLE Subject_Record attendeeid INTEGER REFERENCES PersonpersonId) NOT NULL, subjectid INTEGER REFERENCES PersonpersonId) NOT NULL, recordinfo VARCHAR2 100) NOT NULL, evaluationid INTEGER REFERENCES EvaluationevaluationId) NOT NULL, CONSTRAINT Subject_Record_PK PRIMARY KEY attendeeid, subjectid, evaluationid ) ) ; CREATE TABLE TreatmentPlan analystid INTEGER REFERENCES PersonpersonId) NOT NULL, subjectid INTEGER REFERENCES PersonpersonId) NOT NULL, planinfo VARCHAR2 100) NOT NULL, time TIMESTAMP 0) NOT NULL ) ;