DATABASE DESIGN I IST 210: Organization of Data IST210 1.

Slides:



Advertisements
Similar presentations
Designing tables from a data model (Chapter 6) One base table for each entity.
Advertisements

Database Lecture Notes Mapping ER Diagrams to Tables 2 Dr. Meg Murray
(wrapping up from last week)
Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 5/1 Copyright © 2004 Please……. No Food Or Drink in the class.
Ch5: ER Diagrams - Part 1 Much of the material presented in these slides was developed by Dr. Ramon Lawrence at the University of Iowa.
Data Modeling and Entity- Relationship Model II. IST2102 I want a database to maintain departments in my company. Store information about my employees,
Copyright © 2015 Pearson Education, Inc. Database Design Chapters 17 and
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 5-1 COS 346 Day 9.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-1 David M. Kroenke Database Processing Chapter 6 Transforming Data.
Entity-Relationship Model and Diagrams (continued)
© 2008 Pearson Prentice Hall, Experiencing MIS, David Kroenke
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-1 David M. Kroenke’s Chapter Six: Transforming Data Models into Database.
© 2002 by Prentice Hall 1 David M. Kroenke Database Processing Eighth Edition Chapter 6 Database Design Using Entity- Relationship Models.
Information Resources Management January 30, 2001.
Database Design Chapter 2. Goal of all Information Systems  To add value –Reduce costs –Increase sales or revenue –Provide a competitive advantage.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-1 David M. Kroenke’s Chapter Six: Transforming ER Models into Database.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-1 David M. Kroenke’s Chapter Six: Transforming ER Models into Database.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Reduction of an E-R Schema to Tables A database which conforms to an E-R diagram can be represented.
Slide 1 Chapter 05 – Part 1 Data Modeling with the Entity-Relationship Model.
Transforming Data Models into Database Designs
Data Modeling and Entity- Relationship Model I IST2101.
Entity-Relationship Design
Database Design.  Define a table for each entity  Give the table the same name as the entity  Make the primary key the same as the identifier of the.
COURSE REGISTRATION SYSTEM Case study IST2101. Case Study: Course Registration (1) IST2102 You are helping Penn State create a course registration system.
Data Modeling and the Entity-Relationship Model Chapter Four DAVID M. KROENKE’S DATABASE CONCEPTS, 2 nd Edition.
Chapter 5 1 © Prentice Hall, 2002 Chapter 5: Transforming EER Diagrams into Relations Mapping Regular Entities to Relations 1. Simple attributes: E-R attributes.
Part 06 – A More Complex Data Model Entity Framework and MVC NTPCUG Tom Perkins.
Database Design Chapter Five DAVID M. KROENKE’S DATABASE CONCEPTS, 2 nd Edition.
Chapter Six Professor Adams’ Slides. Note that entities are shadowed, tables are not. Note that entities have no physical existence (blueprint) Note.
1 ER Modeling BUAD/American University Entity Relationship (ER) Modeling.
Principles of Database Design, Part II AIMS 2710 R. Nakatsu.
Concepts and Terminology Introduction to Database.
Chapter 3: Relational Model I Structure of Relational Databases Structure of Relational Databases Convert a ER Design to a Relational Database Convert.
© 2002 by Prentice Hall 1 Database Design David M. Kroenke Database Concepts 1e Chapter 5 5.
Normalization Process: Exercise 1: Step 1 IST2101 Step 1. Identify all the candidate keys of the relation. StudentNumber.
Database Design IST210 Class Lecture
Data Modeling IST210 Class Lecture.
Next Back A-1 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights.
C-1 Management Information Systems for the Information Age Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Extended Learning Module.
IE 423 – Design of Decision Support Systems Data modeling and database development.
Chapter 9: Logical Database Design and the Relational Model (ERD Mapping)
Description and exemplification of entity-relationship modelling.
Carnegie Mellon University © Robert T. Monroe Management Information Systems Data Modeling Management Information Systems Robert.
Chapter 2. The Relational Model (cont.)
ICOM 5016 – Introduction to Database Systems Lecture 9 Dr. Manuel Rodriguez Department of Electrical and Computer Engineering University of Puerto Rico,
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan Lecture-03 Introduction –Data Models Lectured by, Jesmin Akhter.
CS263 Lecture 5: Logical Database Design Can express the structure of a relation by a Tuple, a shorthand notation Name of the relation is followed (in.
Information Access Mgt09/12/971 Entity-Relationship Design Information Level Design.
Gegevens Analyse Les 5: van ERD naar DSD.
Database Design I (In-Class Exercise Answer) IST 210: Organization of Data IST2101.
THE RELATIONAL MODEL I IST 210: Organization of Data IST210 1.
The Entity-Relationship Model, P. I R. Nakatsu. Data Modeling A data model is the relatively simple representation, usually graphic, of the structure.
Database Design. Database Design Process Data Model Requirements Application 1 Database Requirements Application 2 Requirements Application 4 Requirements.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-1 David M. Kroenke’s Chapter Six: Transforming Data Models into Database.
IE 423 – Design of Decision Support Systems Data modeling and database development.
Chapter 2: Entity-Relationship Model. 3.2 Chapter 2: Entity-Relationship Model Design Process Modeling Constraints E-R Diagram Design Issues Weak Entity.
©Silberschatz, Korth and Sudarshan7.1Database System Concepts - 6 th Edition Chapter 7: Entity-Relationship Model.
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.
Chapter 1. Getting Started IST 210: Organization of Data IST2101.
DATA MODELING AND ENTITY-RELATIONSHIP MODEL II IST 210: Organization of Data IST210 1.
DATABASE DESIGN II IST 210: Organization of Data IST210 1.
Database Design I (In-Class Exercise Answer) IST 210: Organization of Data IST2101.
IST 210: Organization of Data
Chapter 7 Entity-Relationship Model
Database Processing: David M. Kroenke’s Chapter Six:
Database Processing: David M. Kroenke’s Chapter Six:
Database Processing: David M. Kroenke’s Chapter Six:
Presentation transcript:

DATABASE DESIGN I IST 210: Organization of Data IST210 1

2 I want a database to maintain departments in my company. Store information about my employees, their projects and assignments. I want …. $$$ User requirement A database YOUR JOB! Data Modeling (Ch.4) Data Modeling (Ch.4) Database Design (Ch.5)

Two-Step Approach: Step 1 IST210 3 Input: User requirement; Output: E-R Diagram Use Entity-Relationship Diagram (E-R Diagram) to capture all user requirements Data Modeling (Ch.4) Data Modeling (Ch.4) Database Design (Ch.5)

Two-Step Approach: Step 2 IST210 4 Data Modeling (Ch.4) Data Modeling (Ch.4) Database Design (Ch.5) Input: E-R diagram; Output: A database Transferring a data model to a relational database Entities  Relations Relationships  Foreign keys and extra

Chapter Key Objective Data Model (E-R Diagram)  Relational Model (Tables) IST Entity  Table Entity name  Table name Identifier  Primary key Attributes  Attributes 2.Relationship  Foreign key or a new table Determined by the maximal cardinality 3.Specify the attribute properties Data type Key Required Determined by the minimal cardinality Remarks

E-R Diagram  Tables IST Entity  Table Entity name  Table name Identifier  Primary key Attributes  Attributes 2.Relationship  Foreign key or a new table 3.Specify the attribute properties

Example IST210 7 LockerID LockerRoom LockerSize EmployeeID Name OfficeNumber OfficePhone LOCKER EMPLOYEE 1)Entity name  Table name 2)Identifier  Primary key 3)Attributes  Attributes EMPLOYEE(EmployeeID, Name, OfficeNumber, OfficePhone) LOCKER(LockerID, LockerRoom, LockerSize) *primary key: use underline

E-R Diagram  Tables IST Entity  Table Entity name  Table name Identifier  Primary key Attributes  Attributes 2.Relationship  Foreign key or a new table Determined by the maximal cardinality 3.Specify the attribute properties

Maximal Cardinality 1:1 (one-to-one) Relationship 1:N (one-to-many) Relationship N:M (many-to-many) Relationship IST210 9 Entity AEntity B Entity AEntity B Entity A Entity B

1:1 Relationship IST Locker ID Locker Room Locker Size 1#210 5#25 EMPLOYEE LOCKER Relationship is not captured yet! Add foreign key ? Employee ID NameOffice Number Office Phone 4Tom EMPLOYEE(EmployeeID, Name, OfficeNumber, OfficePhone) LOCKER(LockerID, LockerRoom, LockerSize)

IST Employe e ID NameOffice Number Office Phone Locker ID 4Tom Locker ID Locker Room Locker Size 1#210 5#25 EMPLOYEELOCKER Employee 4 owns locker 1; locker 1 belongs to employee 4. Employe e ID NameOffice Number Office Phone 4Tom Locker ID Locker Room Locker Size Employe eID 1#2104 5#25 EMPLOYEELOCKER Locker ID Locker Room Locker Size Employe eID 1#2104 5#25 EMPLOYEELOCKER Employe e ID NameOffice Number Office Phone Locker ID 4Tom Option A Option B Option C

1:1 Relationship IST EMPLOYEE(EmployeeID, Name, OfficeNumber, OfficePhone, LockerID) LOCKER(LockerID, LockerRoom, LockerSize) EMPLOYEE(EmployeeID, Name, OfficeNumber, OfficePhone) LOCKER(LockerID, LockerRoom, LockerSize, EmployeeID) Option A Option B Both options are correct. Option A is preferred. If choosing Option A, since every employee has one locker, LockerID must have a value in EMPLOYEE table. If choosing Option B, since some lockers does not belong to anyone, EmployeeID will be NULL value for some lockers and it takes extra space. (See the previous slide, Option B needs one more cell.) *foreign key: italic

1:1 Relationship The maximum cardinality determines how a relationship is represented 1:1 relationship The key from one relation is placed in the other as a foreign key It does not matter which table receives the foreign key We prefer the option taking less space IST210 13

1:N Relationship IST Employe e ID Last Name First Name Office Number Office Phone 4GreenTom Locker ID Locker Room Locker Size 1#210 5#25 EMPLOYEE LOCKER Relationship is not captured yet!Add foreign key ? LockerID LockerRoom LockerSize EmployeeID Name OfficeNumber OfficePhone LOCKER EMPLOYEE Assume one-to-many relationship

IST Employe e ID NameOffice Number Office Phone Locker ID 4Tom , 5 Locker ID Locker Room Locker Size 1#210 5#25 EMPLOYEELOCKER Employee 4 owns locker 1 and 5. Employe e ID NameOffice Number Office Phone 4Tom Locker ID Locker Room Locker Size Employee ID 1#2104 5#254 EMPLOYEELOCKER EMPLOYEELOCKER Employ eeID NameOffice Number Office Phone Locker ID 4Tom , 5 Option A Option B Option C Locker ID Locker Room Locker Size Employee ID 1#2104 5#254

1:N Relationship IST EMPLOYEE(EmployeeID, Name, OfficeNumber, OfficePhone) LOCKER(LockerID, LockerRoom, LockerSize, EmployeeID)

1:N Relationship Like a 1:1 relationship, a 1:N relationship is saved by placing the key from one table into another as a foreign key However, in a 1:N the foreign key always goes into the many-side of the relationship The 1 side is called the parent The N side is called the child IST210 17

N:M Relationship IST Employe e ID NameOffice Number Office Phone 4Tom John Locker ID Locker Room Locker Size 1#210 5#25 EMPLOYEE LOCKER Relationship is not captured yet! Add foreign key ? LockerID LockerRoom LockerSize EmployeeID Name OfficeNumber OfficePhone LOCKER EMPLOYEE Assume many-to-many relationship

IST Employe e ID NameOffice Number Office Phone Locker ID 4Tom , 5 10John Locker Number Locker Room Locker Size 1#210 5#25 EMPLOYEELOCKER Employee 4 owns locker 1 and 5. Employee 10 owns locker 1. Employe e ID NameOffice Number Office Phone 4Tom John Locker ID Locker Room Locker Size Employe eID 1#2104, 10 5#254 EMPLOYEELOCKER Option A Option B

IST Employe e ID NameOffice Number Office Phone 4Tom John Locker ID Locker Room Locker Size 1#210 5#25 EMPLOYEELOCKER Employee ID Locker ID ASSIGNMENT NOT SIMPLY ADDING FOREIGN KEYS! CREATE ANOTHER TABLE! Employee 4 owns locker 1 and 5. Employee 10 owns locker 1.

N:M Relationship IST EMPLOYEE(EmployeeID, LastName, FirstName, OfficeNumber, OfficePhone) LOCKER(LockerID, LockerRoom, LockerSize) ASSIGNMENT(EmployeeID, LockerID) Note: EmployeeID and LockerID are both primary keys and foreign keys in ASSIGNMENT table

N:M Relationship To represent a N:M relationship in relational design, a new table must be created. This table is called an intersection table An intersection table has a composite key consisting of the keys from each of the tables that it connects IST210 22

Relationship Summary IST EMPLOYEE(EmployeeID, Name, OfficeNumber, OfficePhone, LockerID) LOCKER(LockerID, LockerRoom, LockerSize) EMPLOYEE(EmployeeID, Name, OfficeNumber, OfficePhone) LOCKER(LockerID, LockerRoom, LockerSize, EmployeeID) N:M  add an intersection table EMPLOYEE(EmployeeID, Name, OfficeNumber, OfficePhone) LOCKER(LockerID, LockerRoom, LockerSize) ASSIGNMENT(EmployeeID, LockerID) EMPLOYEE(EmployeeID, Name, OfficeNumber, OfficePhone) LOCKER(LockerID, LockerRoom, LockerSize, EmployeeID) 1:N  add a foreign key to the many-side table 1:1  add a foreign key to either table or

In-class Exercise 1 IST Transform this diagram into tables UserID Name SpotID Location MonthlyCost USER PARKING

In-class Exercise 1 IST 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 IST 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 IST BuildingName ApartmentID NumberOfBed NumberOfBath Rent BuildingName Address APARTMENT BUILDING Transform this diagram into tables

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

In-class Exercise 2: Notes IST 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 IST CourseID CourseName Instructor StudentID StudentName COURSE STUDENT Transform this diagram into tables

In-class Exercise 3 IST 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 IST 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.

E-R Diagram  Tables IST Entity  Table Entity name  Table name Identifier  Primary key Attributes  Attributes 2.Relationship  Foreign key or a new table Determined by the maximal cardinality 1:1  add a foreign key to either table 1:N  add a foreign key to the many-side table N:M  add an intersection table 3.Specify the attribute properties

E-R Diagram  Tables IST Entity  Table Entity name  Table name Identifier  Primary key Attributes  Attributes 2.Relationship  Foreign key or a new table Determined by the maximal cardinality 3.Specify the attribute properties Data type Key Required Determined by the minimal cardinality Remarks

IST EMPLOYEE(EmployeeID, Name, OfficeNumber, OfficePhone, LockerID) LOCKER(LockerID, LockerRoom, LockerSize) EMPLOYEE table Column NameData TypeKeyRequiredRemarks LockerID LockerRoom LockerSize LOCKER table Column NameData TypeKeyRequiredRemarks EmployeeID Name OfficeNumber OfficePhone LockerID

IST EMPLOYEE(EmployeeID, Name, OfficeNumber, OfficePhone, LockerID) LOCKER(LockerID, LockerRoom, LockerSize) EMPLOYEE table Column NameData Type LockerIDint LockerRoomchar(10) LockerSizefloat LOCKER table Column NameData Type EmployeeIDint Namechar(50) OfficeNumberchar(20) OfficePhonechar(12) LockerIDint Data Type Determine the data types based on the type of these attributes Data types must be the types defined in SQL us/library/ms aspxhttp://technet.microsoft.com/en- us/library/ms aspx Data type of a foreign key must be the same type as its referred primary key LockerID in EMPLOYEE table must have the same data type as LockerID in LOCKER because LockerID is a foreign key in EMPLOYEE

IST EMPLOYEE(EmployeeID, Name, OfficeNumber, OfficePhone, LockerID) LOCKER(LockerID, LockerRoom, LockerSize) EMPLOYEE table Column NameData Type LockerIDPrimary key LockerRoom LockerSize LOCKER table Column NameKey EmployeeIDPrimary key Name OfficeNumber OfficePhone LockerIDForeign key Key Specify primary key and foreign key(s) in the table

IST EMPLOYEE(EmployeeID, Name, OfficeNumber, OfficePhone, LockerID) LOCKER(LockerID, LockerRoom, LockerSize) EMPLOYEE table Column NameRequired LockerIDYes LockerRoomYes LockerSizeYes LOCKER table Column NameRequired EmployeeIDYes NameYes OfficeNumberNo OfficePhoneNo LockerIDYes Required Whether an attribute is required or not determines whether we allow NULL value for this attribute Primary key must be required Normal attributes are determined based on requirements or common sense “not required” is preferred Foreign key is determined by minimum cardinality An employee must have at least one locker. So LockerID is required in EMPLOYEE

IST EMPLOYEE(EmployeeID, Name, OfficeNumber, OfficePhone, LockerID) LOCKER(LockerID, LockerRoom, LockerSize) EMPLOYEE table Column Name Remarks LockerIDSurrogate key: initial value = 1 Increment = 1 LockerRoom LockerSizeDefault value: 10 LOCKER table Column Name Remarks EmployeeIDSurrogate key: initial value = 1 Increment = 1 Name OfficeNumber OfficePhoneFormat: ###-###-#### LockerIDReference: LOCKER Remarks If a primary key is a surrogate key, specify the initial value and increment If an attribute is a foreign key, specify which table it refers to If an attribute has a required format, specify the format If an attribute has a default value, specify the value

IST EMPLOYEE(EmployeeID, Name, OfficeNumber, OfficePhone, LockerID) LOCKER(LockerID, LockerRoom, LockerSize) EMPLOYEE table Column Name Data Type KeyRequire d Remarks LockerIDintPrimary key YesSurrogate key: initial value = 1 Increment = 1 LockerRoomchar(10)Yes LockerSizefloatYesDefault value: 10 LOCKER table Column Name Data Type KeyRequiredRemarks EmployeeIDintPrimary key YesSurrogate key: initial value = 1 Increment = 1 Namechar(50)Yes OfficeNumberchar(20)No OfficePhonechar(12)NoFormat: ###-###-#### LockerIDintForeign key YesReference: LOCKER Now we complete converting an E-R diagram to tables Next, we can use SQL to create a real database

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

IST PARKING(SpotID, Location, MonthlyCost) USER(UserID, Name, , SpotID) PARKING table Column Name Data Type KeyRequiredRemarks UserID Name SpotID USER table Column Name Data Type KeyRequiredRemarks SpotID Location MonthlyCost In-class Exercise 1

IST PARKING table Column Name Data Type KeyRequiredRemarks UserIDintPrimary key YesSurrogate key: initial value = 1 Increment = 1 Namechar(100)Yes char(50)No SpotIDintForeign key YesReference: PARKING USER table Column Name Data Type KeyRequiredRemarks SpotIDintPrimary key YesSurrogate key: initial value = 1 Increment = 1 Locationchar(50)Yes MonthlyCostintYesDefault: 50 PARKING(SpotID, Location, MonthlyCost) USER(UserID, Name, , SpotID)

IST PARKING table Column Name Data Type KeyRequire d Remarks UserIDintPrimary key YesSurrogate key: initial value = 1 Increment = 1 Namechar(100)Yes char(50)No SpotIDintForeign key YesReference: PARKING USER table Column Name Data Type KeyRequire d Remarks SpotIDintPrimary key YesSurrogate 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 IST Transform this diagram into tables BUILDING(BuildingName, Address) APARTMENT(BuildingName, ApartmentID, NumberOfBedrooms, NumberofBaths, Rent)

IST BUILDING table Column Name Data Type KeyRequiredRemarks BuildingName ApartmentID NumberOfBed NumberOfBath Rent APARTMENT table Column Name Data Type KeyRequiredRemarks BuildingName Address BUILDING(BuildingName, Address) APARTMENT(BuildingName, ApartmentID, NumberOfBedrooms, NumberofBaths, Rent) In-class Exercise 2

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

IST BUILDING table Column Name Data Type KeyRequiredRemarks BuildingNameChar(20)Primary key, foreign key YesReference: BUILDING ApartmentIDintPrimary keyYes NumberOfBedfloatYes NumberOfBathfloatYes RentfloatYes APARTMENT table Column Name Data Type KeyRequiredRemarks BuildingNameChar(20)Primary key Yes 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 IST Transform this diagram into tables STUDENT(StudentID, StudentName, ) COURSE(CourseID, CourseName, Instructor) REGISTRATION(StudentID, CourseID)

IST STUDENT(StudentID, StudentName, ) COURSE(CourseID, CourseName, Instructor) REGISTRATION(StudentID, CourseID) STUDENT table Column Name Data TypeKeyRequiredRemarks CourseID CourseName Instructor COURSE table Column Name Data Type KeyRequiredRemarks StudentID StudentName Column Name Data Type KeyRequiredRemarks StudentID CourseID REGISTRATION table In-class Exercise 3

IST STUDENT(StudentID, StudentName, ) COURSE(CourseID, CourseName, Instructor) REGISTRATION(StudentID, CourseID) STUDENT table Column Name Data TypeKeyRequiredRemarks CourseIDChar(20)Primary key YesFormat: DepartmentName + CourseNumber CourseNameChar(50)Yes InstructorChar(100)No COURSE table Column Name Data TypeKeyRequiredRemarks StudentIDintPrimary key YesSurrogate key: initial value = 1 Increment = 1 StudentNameChar(100)Yes Char(50)No Column Name Data Type KeyRequiredRemarks StudentIDintPrimary key, foreign keyYesReference: STUDENT CourseIDChar(20)Primary key, foreign keyYesReference: COURSE REGISTRATION table

IST STUDENT table Column Name Data TypeKeyRequiredRemarks CourseIDChar(20)Primary key YesFormat: DepartmentName + CourseNumber CourseNameChar(50)Yes InstructorChar(100)No COURSE table Column Name Data Type KeyRequiredRemarks StudentIDintPrimary key YesSurrogate key: initial value = 1 Increment = 1 StudentNameChar(100)Yes Char(50)No Column Name Data 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”.

E-R Diagram  Tables IST Entity  Table Entity name  Table name Identifier  Primary key Attributes  Attributes 2.Relationship  Foreign key or a new table 3.Specify the attribute properties

Attendance check? IST210 54