Database Design I (In-Class Exercise Answer) IST 210: Organization of Data IST2101.

Slides:



Advertisements
Similar presentations
Transform an ER Model into a Relational Database Schema
Advertisements

Lab Exercise This Week PHP Basics See last Friday’s slides for requirements Make sure you show the final results to TA to get credit 1IST210.
Data Modeling and Entity- Relationship Model II. IST2102 I want a database to maintain departments in my company. Store information about my employees,
Chapter 2. The Relational Model (cont.) IST2101. Review: Functional Dependency A relationship between attributes: some attribute(s) determine the value.
Entity PrimaryKey Attribute relationship Cardinality: zero to many Cardinality: one and only one Cardinality: one to many Explanation Entity Relationship.
Data Modeling and Entity- Relationship Model I IST2101.
COURSE REGISTRATION SYSTEM Case study IST2101. Case Study: Course Registration (1) IST2102 You are helping Penn State create a course registration system.
Structured Query Language (SQL) A2 Teacher Up skilling LECTURE 2.
Review Session What is data, what is information, and give a real world example to differentiate these two concepts.
Data Modeling ERM ERD.
1 Class Agenda (04/09 through 04/16)  Review HW #8  Present normalization process Enhance conceptual knowledge of database design. Improve practical.
1 ER Modeling BUAD/American University Entity Relationship (ER) Modeling.
DATABASE DESIGN I IST 210: Organization of Data IST210 1.
Database Design II (Case Studies: Step 2) IST 210: Organization of Data IST2101.
IST 210: ORGANIZATION OF DATA Chapter 1. Getting Started IST210 1.
Normalization Process: Exercise 1: Step 1 IST2101 Step 1. Identify all the candidate keys of the relation. StudentNumber.
Chapter 2. The Relational Model IST2101. Chapter 1 Review Potential problems with Lists – Deletion – Update – Insertion Avoid these problems using a relational.
IE 423 – Design of Decision Support Systems Data modeling and database development.
Chapter 2. The Relational Model (cont.)
THE RELATIONAL MODEL II IST 210: Organization of Data IST210 1.
Database Design I (In-Class Exercise Answer) IST 210: Organization of Data IST2101.
THE RELATIONAL MODEL I IST 210: Organization of Data IST210 1.
Functional dependencies and normalization 1 Normalization Functional dependencies NF + BCNF.
Prepare an ERD for the following scenario Renting a movie at Blockbuster: Each movie is described by an ID, name, genre (horror, comedy, drama, romantic,
* Database is a group of related objects * Objects can be Tables, Forms, Queries or Reports * All data reside in Tables * A Row in a Table is a record.
IE 423 – Design of Decision Support Systems Data modeling and database development.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 7: Entity-Relationship.
Data Modeling and Entity-Relationship Model I
Database Design I IST 210: Organization of Data IST2101.
Information System Design “Student Registration System Example”
Chapter 1. Getting Started IST 210: Organization of Data IST2101.
DATA MODELING AND ENTITY-RELATIONSHIP MODEL II IST 210: Organization of Data IST210 1.
Standards and Conventions
DATABASE DESIGN II IST 210: Organization of Data IST210 1.
Conceptual DB Design Conceptual database design ERD’s.
Entity Relationship Modeling
Entity-Relationship Model
MySQL S511.
Information System & Database Design
Database Constraints Ashima Wadhwa.
E-R Diagram (Cont.) Draw ER Diagram for the following scenario:
IST 210: Organization of Data
Entity-Relationship Model
COMP 430 Intro. to Database Systems
Lesson 7 Managing Data Creating a database with Web Matrix.
CSIS 115 Database Design and Applications for Business
Chapter 7 Entity-Relationship Model
Outline of the ER Model By S.Saha
ERD :: 19 / 1 / Entity-Relationship (ER) Modeling. ER Modeling is a top-down approach to database design. Entity Relationship (ER) Diagram –A.
Entity Relationship Diagram
Entity relationship diagrams
Microsoft Applications
Creating Tables & Inserting Values Using SQL
Chapter 2 Modeling Data in the Organization
Oracle Data Definition Language (DDL)
Weak Entity Sets An entity set that does not have a primary key is referred to as a weak entity set. The existence of a weak entity set depends on the.
MySQL.
MySQL S511.
MIS2502: Data Analytics Relational Data Modeling
Database Design: Relational Model
A Very Brief Introduction to Relational Databases
Logical Data Modeling – Attributes, Primary Keys, and Identity
Day 2 - Basic Database Backbone
INSTRUCTOR: MRS T.G. ZHOU
Conceptual modeling of databases
Conceptual Data Modeling
CSC 453 Database Technologies
SQL (Structured Query Language)
Database 2.
Chapter 3 The Relational Model
Presentation transcript:

Database Design I (In-Class Exercise Answer) IST 210: Organization of Data IST2101

In-class Exercise 1 IST2102 Transform this diagram into tables UserID Name SpotID Location MonthlyCost USER PARKING PARKING(SpotID, Location, MonthlyCost) USER(UserID, Name, , SpotID)

In-class Exercise 1: Notes IST2103 PARKING(SpotID, Location, MonthlyCost) USER(UserID, Name, , SpotID) PARKING(SpotID, Location, MonthlyCost, UserID) USER(UserID, Name, ) Note: both options are correct, but the first one is preferred because of the minimal cardinality of SpotID is mandatory.

In-class Exercise 2 IST2104 Transform this diagram into tables BUILDING(BuildingName, Address) APARTMENT(BuildingName, ApartmentID, NumberOfBedrooms, NumberofBaths, Rent)

In-class Exercise 2: Notes IST2105 BUILDING(BuildingName, Address) APARTMENT(BuildingName, ApartmentID, NumberOfBedrooms, NumberofBaths, Rent) Notes: * A common mistake is making ApartmentID as the only primary key. (BuildingName, ApartmentID) should a composite key for APARTMENT * Another common mistake is to create a duplicate attribute BuildingName in APARTMENT. Or forget to make BuildingName as the foreign key

In-class Exercise 3 IST2106 CourseID CourseName Instructor StudentID StudentName COURSE STUDENT Transform this diagram into tables STUDENT(StudentID, StudentName, ) COURSE(CourseID, CourseName, Instructor) REGISTRATION(StudentID, CourseID)

In-class Exercise 3: Notes IST2107 STUDENT(StudentID, StudentName, ) COURSE(CourseID, CourseName, Instructor) REGISTRATION(StudentID, CourseID) Notes: * In REGISTRATION table, StudetID and CourseID are both primary key and foreign key. So you should give both underline and italic (wave underline in hand-written format) to them.

In-class Exercise 4 IST2108 USER(UserID, Name, ) COMMENT(CommentID, Rating, Comment, UserID, MovieID) MOVIE(MovieID, MovieName, Director, Year) MovieID MovieName Director Year UserID Name MOVIE USER Transform this diagram into tables CommentID Rating Comment COMMENT

In-class Exercise 1 IST2109 PARKING(SpotID, Location, MonthlyCost) USER(UserID, Name, , SpotID)

IST21010 PARKING(SpotID, Location, MonthlyCost) USER(UserID, Name, , SpotID) PARKING table Column NameData Type KeyRequire d Remarks UserIDintPrimary keyYesSurrogate key: initial value = 1 Increment = 1 Namechar(100)Yes char(50)No SpotIDintForeign keyYesReference: PARKING USER table Column NameData Type KeyRequire d Remarks SpotIDintPrimary keyYesSurrogate key: initial value = 1 Increment = 1 Locationchar(50)Yes MonthlyCostintYesDefault: 50

IST21011 PARKING table Column NameData Type KeyRequire d Remarks UserIDintPrimary keyYesSurrogate key: initial value = 1 Increment = 1 Namechar(100)Yes char(50)No SpotIDintForeign keyYesReference: PARKING USER table Column NameData Type KeyRequire d Remarks SpotIDintPrimary keyYesSurrogate key: initial value = 1 Increment = 1 Locationchar(50)Yes MonthlyCostintYesDefault: 50 Notes: See the red parts Char is not a data type, char(50) is a data type. If you use char, you need to specify the max length When you can use other data types, do not use char. For example, it is better to use int for MonthlyCost instead of using char PARKING(SpotID, Location, MonthlyCost) USER(UserID, Name, , SpotID)

In-class Exercise 2 IST21012 Transform this diagram into tables BUILDING(BuildingName, Address) APARTMENT(BuildingName, ApartmentID, NumberOfBedrooms, NumberofBaths, Rent)

IST21013 BUILDING table Column NameData Type KeyRequiredRemarks BuildingNameChar(20)Primary key, foreign keyYesReference: BUILDING ApartmentIDintPrimary keyYes NumberOfBedfloatYes NumberOfBathfloatYes RentfloatYes APARTMENT table Column NameData Type KeyRequiredRemarks BuildingNameChar(20)Primary keyYes AddressChar(100)YesFormat: street, city, state, zip code BUILDING(BuildingName, Address) APARTMENT(BuildingName, ApartmentID, NumberOfBedrooms, NumberofBaths, Rent)

IST21014 BUILDING table Column NameData Type KeyRequiredRemarks BuildingNameChar(20)Primary key, foreign keyYesReference: BUILDING ApartmentIDintPrimary keyYes NumberOfBedfloatYes NumberOfBathfloatYes RentfloatYes APARTMENT table Column NameData Type KeyRequiredRemarks BuildingNameChar(20)Primary keyYes AddressChar(100)YesFormat: street, city, state, zip code Notes: ApartmentID should NOT be a surrogate key. In real scenarios, we are using some meaningful ApartmentIDs, such as 100 or 201 instead of a meaningless system- generated id. Use float for #ofBed, #ofBath, and Rent. Because #ofBath could be 1.5 and rent could be $890.50, which are not integers.

In-class Exercise 3 IST21015 Transform this diagram into tables STUDENT(StudentID, StudentName, ) COURSE(CourseID, CourseName, Instructor) REGISTRATION(StudentID, CourseID)

IST21016 STUDENT(StudentID, StudentName, ) COURSE(CourseID, CourseName, Instructor) REGISTRATION(StudentID, CourseID) STUDENT table Column NameData Type KeyRequiredRemarks CourseIDChar(20)Primary keyYesFormat: DepartmentName + CourseNumber CourseNameChar(50)Yes InstructorChar(100)No COURSE table Column NameData Type KeyRequiredRemarks StudentIDintPrimary keyYesSurrogate key: initial value = 1 Increment = 1 StudentNameChar(100)Yes Char(50)No Column NameData Type KeyRequiredRemarks StudentIDintPrimary key, foreign keyYesReference: STUDENT CourseIDChar(20)Primary key, foreign keyYesReference: COURSE REGISTRATION table

IST21017 STUDENT table Column NameData Type KeyRequiredRemarks CourseIDChar(20)Primary keyYesFormat: DepartmentName + CourseNumber CourseNameChar(50)Yes InstructorChar(100)No COURSE table Column NameData Type KeyRequiredRemarks StudentIDintPrimary keyYesSurrogate key: initial value = 1 Increment = 1 StudentNameChar(100)Yes Char(50)No Column NameData Type KeyRequiredRemarks StudentIDintPrimary key, foreign keyYesReference: STUDENT CourseIDChar(20)Primary key, foreign keyYesReference: COURSE REGISTRATION table Notes: A CourseID should not be integer, for example, “IST210” is a courseID. CourseName for IST210 is “Organization of the data”.