CS 327E Lecture 5. Shirley Cohen. September 14, 2016

Similar documents
CS 327E Lecture 12. Shirley Cohen. March 7, 2016

Database Design. CS 327E Feb 12, 2018

Lecture 9: Database Design. Wednesday, February 18, 2015

CS 327E Lecture 2. Shirley Cohen. January 27, 2016

CSE 344 JANUARY 5 TH INTRO TO THE RELATIONAL DATABASE

L12: ER modeling 5. CS3200 Database design (sp18 s2) 2/22/2018

CSE 544 Principles of Database Management Systems

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

GlobAl EDITION. Database Concepts SEVENTH EDITION. David M. Kroenke David J. Auer

MTAT Introduction to Databases

SQL (and MySQL) Useful things I have learnt, borrowed and stolen

Introduction to Data Management CSE 344

CS317 File and Database Systems

INF 315E Introduction to Databases School of Information Fall 2015

Announcements. Using Electronics in Class. Review. Staff Instructor: Alvin Cheung Office hour on Wednesdays, 1-2pm. Class Overview

CS 327E Lecture 3. Shirley Cohen. February 1, 2016

CS 327E Lecture 11. Shirley Cohen. March 2, 2016

More MySQL ELEVEN Walkthrough examples Walkthrough 1: Bulk loading SESSION

CSC 4710 / CSC 6710 Database Systems. Rao Casturi

user specifies what is wanted, not how to find it

Unit 11: Database Systems CS 101, Fall 2018

MTAT Introduction to Databases

CS 327E Lecture 10. Shirley Cohen. February 29, 2016

Announcements. JSon Data Structures. JSon Syntax. JSon Semantics: a Tree! JSon Primitive Datatypes. Introduction to Database Systems CSE 414

Lecture 0: Overview of cs1106/cs6503

CS 327E Lecture 5. Shirley Cohen. February 8, 2016

Introduction to Databases CSE 414. Lecture 2: Data Models

SQL DDL II. CS121: Relational Databases Fall 2017 Lecture 8

CSC 215 PROJECT 2 DR. GODFREY C. MUGANDA

Data! CS 133: Databases. Goals for Today. So, what is a database? What is a database anyway? From the textbook:

Fname A variable character field up to 15 characters in length. Must have a value Lname A variable character field up to 15

CSE 167: Introduction to Computer Graphics. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2016

CS / Cloud Computing. Recitation 7 October 7 th and 9 th, 2014

THE UNIVERSITY OF AUCKLAND

Carnegie Mellon Univ. Dept. of Computer Science /615 - DB Applications. Today's Party. Example Database. Faloutsos/Pavlo CMU /615

Lecture 2: Introduction to SQL

Course and Contact Information. Course Description. Course Objectives

CS317 File and Database Systems

CS143: Relational Model

2.9 Table Creation. CREATE TABLE TableName ( AttrName AttrType, AttrName AttrType,... )

Bases de Dades: introduction and organization

The Relational Data Model

CS50 Quiz Review. November 13, 2017

This lab will introduce you to MySQL. Begin by logging into the class web server via SSH Secure Shell Client

Test Generator is. TG Web Elements. TG Web Benefits. TG Web Services TG Web Technical TG Web Accounts. TG Web Support TG Web Sales

Module 3 MySQL Database. Database Management System

CMPT 354: Database System I. Lecture 1. Course Introduction

A Deeper Look at Data Modeling. Shan-Hung Wu & DataLab CS, NTHU

CSE 344 JANUARY 3 RD - INTRODUCTION

COSC Assignment 2

CS 564: DATABASE MANAGEMENT SYSTEMS. Spring 2018

UNIT 2B An Introduction to Programming. Announcements

} Evaluate the following expressions: 1. int x = 5 / 2 + 2; 2. int x = / 2; 3. int x = 5 / ; 4. double x = 5 / 2.

Integrity constraints, relationships. CS634 Lecture 2

Revised Guidelines for B.A. Programme Semester II Paper: Database Management System (Meeting held on 15 th Jan 2015)

CS 4400 Introduction to Database Systems 2002 Spring Term Project (Section A)

Today Learning outcomes LO2

MySQL Views & Comparing SQL to NoSQL

EE221 Databases Practicals Manual

CS2300: File Structures and Introduction to Database Systems

INFORMATION TECHNOLOGY NOTES

origin destination duration New York London 415 Shanghai Paris 760 Istanbul Tokyo 700 New York Paris 435 Moscow Paris 245 Lima New York 455

Web Programming Fall 2011

ALLAMA IQBAL OPEN UNIVERSITY, ISLAMABAD (Department of Computer Science)

MySQL: an application

Introduction to Database Systems CSE 414

Using a DBMS. Shan-Hung Wu & DataLab CS, NTHU

Modern Database Systems CS-E4610

Course and Contact Information. Course Description. Course Objectives

SQL DATA DEFINITION LANGUAGE

Lecture 4. Database design IV. INDs and 4NF Design wrapup

G64DBS Database Systems. G64DBS Module. Recommended Textbook. Assessment. Recommended Textbook. Recommended Textbook.

CSE3421 Fall Assignment #1: Due October 24, pm. Weight 7%

CREATE TABLE Observer ( NetworkID CHAR(20), DormName VARCHAR(35), PRIMARY KEY (NetworkID) );

Introduction to Data Management. Lecture #1 (The Course Trailer )

Introduction to SQL on GRAHAM ED ARMSTRONG SHARCNET AUGUST 2018

Chapter 4: Intermediate SQL

SQL DATA DEFINITION LANGUAGE

Data Security and Privacy. Topic 11: Virtual Private Databases Based on Prof. Bertino s Slides

Lecture 04: SQL. Wednesday, October 4, 2006

DATABASE MANAGEMENT SYSTEMS

CS157a Fall 2018 Sec3 Home Page/Syllabus

Database Management System

Databases TDA357/DIT620. Niklas Broberg

Bases de Dades: introduction to SQL (indexes and transactions)

CS 4604: Introduc0on to Database Management Systems. B. Aditya Prakash Lecture #4: SQL---Part 2

DATABASE SYSTEMS. Introduction to MySQL. Database System Course, 2016

The Relational Model Constraints and SQL DDL

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

D B M G. SQL language: basics. Managing tables. Creating a table Modifying table structure Deleting a table The data dictionary Data integrity

SQL DDL. Intro SQL CREATE TABLE ALTER TABLE Data types Service-based database in Visual Studio Database in PHPMyAdmin

CSE 344: Section 1 Git Setup for HW Introduction to SQLite. September 28, 2017

Database Concepts. CS 377: Database Systems

Introduction to Data Management CSE 344. Lecture 2: Data Models

San José State University College of Science / Department of Computer Science Introduction to Database Management Systems, CS157A-3-4, Fall 2017

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

Relational Database Design. Announcements. Database (schema) design. CPS 216 Advanced Database Systems. DB2 accounts have been set up

More on Arrays CS 16: Solving Problems with Computers I Lecture #13

Homework Assignment 2. Due Date: October 21th, :30pm (noon) CS425 - Database Organization Results

Textbook: Chapter 4. Chapter 5: Intermediate SQL. CS425 Fall 2016 Boris Glavic. Chapter 5: Intermediate SQL. View Definition.

Transcription:

CS 327E Lecture 5 Shirley Cohen September 14, 2016

Plan for Today Finish Normalization Reading Quiz (based on Chapter 2 of our SQL book) Lab 1 Requirements Git and Github Demo Mini Setup Session for Lab 1

Functional Dependencies Definition: If two records agree on the attributes A 1, A 2,, A n then they must also agree on the attributes B 1, B 2,, B n Formally: A 1, A 2,, A n B 1, B 2,, B n

1NF Drug drug_nbr drug_name drug_qty start_date end_date drug_price 48 Amoxicillin 500 01/01/13 03/31/15 0.30 48 Amoxicillin 500 04/01/15 01/15/16 3.00 48 Amoxicillin 500 01/16/16 3.50 50 Lipitor 150 10/01/12 03/31/14 0.75 50 Lipitor 150 04/01/14 1.00 72 Singulair 250 01/01/15 05/31/15 0.20 72 Singulair 250 06/01/15 07/31/15 0.80 72 Singulair 250 08/01/15 0.20 FDs: 1. drug_nbr drug_name, drug_qty 2. drug_nbr, start_date end_date, drug_price

1NF to 2NF Drug drug_nbr drug_name drug_qty start_date end_date drug_price 48 Amoxicillin 500 01/01/13 03/31/15 0.30 48 Amoxicillin 500 04/01/15 01/15/16 3.00 48 Amoxicillin 500 01/16/16 3.50 1NF FDs: drug_nbr drug_name, drug_qty drug_nbr, start_date end_date, drug_price Drug drug_nbr drug_name drug_qty 48 Amoxicillin 500 50 Lipitor 150 72 Singulair 250 2NF Price drug_nbr start_date end_date drug_price 48 01/01/13 03/31/15 0.30 48 04/01/15 01/15/16 3.00 48 01/16/16 3.50 2NF

1NF to 2NF Rule: A database schema is in 2NF iff it is in 1NF and there exists no partial FDs on the primary key (i.e. all non-key attributes must be dependent on the entire PK) Student_Semester EID Semester Course Grade GPA alice1 Fall15 Stats A 3.9 alice1 Fall15 DB A 3.9 alice1 Fall15 Alg A- 3.9 bob20 Fall15 DB A 3.7 bob20 Fall15 Alg B+ 3.7 carol30 Fall15 Stats A- 3.5 carol30 Fall15 Alg B+ 3.5 1NF FDs: 1. EID, Semester, Course Grade 2. EID, Semester GPA Student_Semester_Grade EID Semester Course Grade alice1 Fall15 Stats A alice1 Fall15 DB A alice1 Fall15 Alg A- bob20 Fall15 DB A bob20 Fall15 Alg B+ carol30 Fall15 Stats A- carol30 Fall15 Alg B+ Student_Semester_GPA EID Semester GPA alice1 Fall15 3.9 bob20 Fall15 3.7 2NF 2NF carol30 Fall15 3.5

2NF to 3NF Rule: A database schema is in 3NF iff it is in 2NF and there exists no non-key attributes that depend on other non-key attributes. Student_Major EID Name Major College alice1 Alice Math Natural Sciences bob20 Bob CS Natural Sciences FDs: EID Name, Major, College Major College carol30 Carol Math Natural Sciences 2NF Student_Major EID Name Major alice1 Alice Math Major_College Major College Math Natural Sciences bob20 Bob CS carol30 Carol Math 3NF CS Natural Sciences 3NF

Concept Question 1 Suppose we add a drug_description field to the Drug table as shown below and then discover that drug_name drug_description. Does this change the normal form for this table? If so, which normal form is the table in now? Drug drug_nbr drug_name drug_description drug_qty 48 Amoxicillin Treats bacterial infections 500 50 Lipitor Reduces cholesterol levels 150 72 Singulair Prevents asthma symptoms 250 FDs: drug_nbr drug_name, drug_description, drug_qty drug_name drug_description A. 1NF B. 2NF C. 3NF D. None of the above

Solution CQ 1 Drug drug_nbr drug_name drug_description drug_qty 48 Amoxicillin Treats bacterial infections 500 50 Lipitor Reduces cholesterol levels 150 72 Singulair Prevents asthma symptoms 250 2NF FDs: drug_nbr drug_name, drug_description, drug_qty drug_name drug_description Drug drug_nbr drug_name drug_qty 48 Amoxicillin 500 50 Lipitor 150 72 Singulair 250 3NF Drug_Description drug_name drug_description Amoxicillin Treats bacterial infections Lipitor Reduces cholesterol levels Singulair Prevents asthma symptoms 3NF

Quiz Question 1 Although the text is system-agnostic, what relational database system is used in the examples of Beaulieu s Learning SQL? A. PostgreSQL B. MySQL C. Microsoft SQL Server D. Oracle Database

Quiz Question 2 What MySQL data type is used to store fixed-length strings? A. CHAR B. VARCHAR C. STRING D. STR

Quiz Question 3 Why would you choose a TIMESTAMP over a DATE type? A. TIMESTAMP is more precise than a DATE B. Only for representing the time C. TIMESTAMP is for representing a date and time (year, month, day, hour, minute, second) while DATE is for representing a date (year, month, day) D. Never DATE should always be used instead of TIMESTAMP

Quiz Question 4 What SQL statement would you use to create a new row in a table? A. APPEND B. NEW C. INSERT D. ALTER

Quiz Question 5 Below is the output from executing a MySQL command: mysql>?????????????? +-----------+----------------------+------+-----+---------+----------------+ Field Type Null Key Default Extra +-----------+----------------------+------+-----+---------+----------------+ branch_id smallint(5) unsigned NO PRI NULL auto_increment name varchar(20) NO NULL address varchar(30) YES NULL city varchar(20) YES NULL state varchar(2) YES NULL zip varchar(12) YES NULL +-----------+----------------------+------+-----+---------+----------------+ What is the command that was executed? A. SHOW CUSTOMER; B. DESCRIBE CUSTOMER; C. SELECT * FROM CUSTOMER; D. UPDATE CUSTOMER;

Lab 1 Requirements http://www.cs.utexas.edu/~scohen/labs/lab1.pdf

Next Steps Complete set up for Lab 1 this weekend Use Chapter 6 from our Wrangling text to find datasets Work on Lab 1 during class time next week (and outside of class time) Use sign-up sheet during class time next week if your team needs support Use Piazza or come to office hours if your team needs help outside of class time Submit Lab 1 by 11:59pm next Friday