Download presentation
Presentation is loading. Please wait.
Published byChastity June Phelps Modified over 9 years ago
1
Assignment 1 Uploaded to course website Due next Tuesday, Sep 1, at 11:59pm
2
Chapter 1. Introduction to Database IST2102
3
Previous Lecture Potential problems with Lists – Deletion – Update – Insertion
4
A Long List to Several Small Lists IST2104 Two themes: Student, Course INFORMATION LOSS! Registration information is not in Student and Course tables
5
A Long List to Several Small Lists IST2105 PROBLEMS! One cell does NOT allow multiple values. (IMPORTANT! This rule is strictly enforced in database.) Two themes: Student, Course
6
A Long List to Several Small Lists IST2106 Student Entity Course Entity Student-Course Relationship Three themes: two entities and one relationship
7
A Long List to Several Small Lists IST2107 Student Course Registration Key points in splitting: 1. A table must be connected with other table(s) through shared column(s) Student (StudentID) Registration Course (CourseID) Registration 2. One cell can only have one value Revisit previous issues: Insert: A new student not taking any class Update: IST210 location changed Delete: Kate drops 230 Use above criteria to check whether you split the tables correctly!
8
Exercise IST2108 What are the modification problems (delete/insert/update) with this table? Split it into multiple tables. (Hint: do not lose information!)
9
Relational Databases A relational database stores information in tables. Each informational topic is stored in its own table In essence, a relational database will break-up a list into several parts. One part for each theme in the list IST2109
10
Answering Query: Putting the Pieces Back Together In our relational database, we broke apart our list into several tables. Somehow the tables must be joined back together In a relational database, tables are joined together using the value of the data IST21010
11
Query Relational Database: Using One Table IST21011 Student Table Course Table Registration Table Query 1: How many students take class 210? Answer: Check Registration Table to see many rows with CourseID as 210. count = 4
12
Query Relational Database: Using Two Tables IST21012 Query 2: How many students take class taught by Marc? Student Table Course Table Registration Table Answer: Step 1. Check the CourseID taught by Marc in Course Table. CourseID = 220 Step 2. See how many students taking class with CourseID 220 in Registration Table. count = 2
13
Query Relational Database: Using Three Tables IST21013 Query 3: Who are the students taking class taught by Zihan? Student Table Course Table Registration Table Answer: Step 1. Check the CourseID taught by Zihan in Course Table. CourseID = 210 Step 2. Get the StudentID taking class with CourseID 210 in Registration Table. StudentID 101, 102, 103, 104 Step 3. Get the student names in Student Table with StudentID 101, 102, 103, 104. Bob, Lisa, Sarah, Jim
14
Query Relational Database IST21014 Student Table Course Table Registration Table In a relational database, to answer a query, tables are joined together using the value of the data in the shared columns
15
Query Relational Database: Structured Query Language (SQL) Structured Query Language (SQL) is an international standard for creating, processing and querying databases and their tables IST21015 SELECTCount(StudentID) FROMCourse, Registration WHERECourse.CourseID = Registration.CourseID AND Course.Instructor = ‘Marc’ Query 2: How many students take class taught by Marc? Answer: Step 1. Check the CourseID taught by Marc in Course Table. CourseID = 220 Step 2. See how many students taking class with CourseID 220 in Registration Table. count = 2
16
Exercise (cont.) IST21016 After you split this table into multiple tables, answer following questions: Question 1: How many items purchased by Anderson? Question 2: What items purchased by customers in State College?
17
Sounds like More Work, Not Less A relational database is more complicated than a list However, a relational database minimizes data redundancy, preserves complex relationships among topics, and allows for partial data Furthermore, a relational database provides a solid foundation for user forms and reports IST21017
18
Chapter 1 Summary What is the problem with using a simple list to store the information? – Redundancy, Multiple themes Modification issues What is the solution to replace a simple list? – Relational database – Break a simple long list to several tables; each table has its own theme How to query a relational database? – Join back the tables by the value of data through shared columns IST21018
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.