Database Design Ack: Amanda Gerdes. Overview  Learning the Language What’s A Database? How Do We Talk About Databases?  Database Models “Flat file”

Slides:



Advertisements
Similar presentations
McGraw-Hill/Irwin Copyright © 2013 by The McGraw-Hill Companies, Inc. All rights reserved. Extended Learning Module C Designing Databases and Entity-Relationship.
Advertisements

Extended Learning Module C
© McGraw-Hill Companies, Inc., McGraw-Hill/Irwin Extended Learning Module C Designing Databases and Entity-Relationship Diagramming.
Copyright © 2015 Pearson Education, Inc. Database Design Chapters 17 and
Entity-Relationship Model and Diagrams (continued)
The Relational Database Model:
Extended Learning Module C Designing Databases and Entity-Relationship Diagramming McGraw-Hill/Irwin Copyright © 2010 by the McGraw-Hill Companies, Inc.
Designing a Database Unleashing the Power of Relational Database Design.
Database Design Chapter 2. Goal of all Information Systems  To add value –Reduce costs –Increase sales or revenue –Provide a competitive advantage.
Chapter 4 Relational Databases Copyright © 2012 Pearson Education, Inc. publishing as Prentice Hall 4-1.
Chapter 4 Relational Databases Copyright © 2012 Pearson Education 4-1.
Database Software Application
Michael F. Price College of Business Chapter 6: Logical database design and the relational model.
Page 1 ISMT E-120 Introduction to Microsoft Access & Relational Databases The Influence of Software and Hardware Technologies on Business Productivity.
IST Databases and DBMSs Todd S. Bacastow January 2005.
Page 1 ISMT E-120 Desktop Applications for Managers Introduction to Microsoft Access.
Database Design Concepts
1 DATABASE TECHNOLOGIES BUS Abdou Illia, Fall 2007 (Week 3, Tuesday 9/4/2007)
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall 9.1.
ASP.NET Programming with C# and SQL Server First Edition
PHP Programming with MySQL Slide 8-1 CHAPTER 8 Working with Databases and MySQL.
Chapter 1 Overview of Database Concepts Oracle 10g: SQL
1 Chapter 1 Overview of Database Concepts. 2 Chapter Objectives Identify the purpose of a database management system (DBMS) Distinguish a field from a.
Concepts and Terminology Introduction to Database.
2005 SPRING CSMUIntroduction to Information Management1 Organizing Data John Sum Institute of Technology Management National Chung Hsing University.
CHAPTER 8: MANAGING DATA RESOURCES. File Organization Terms Field: group of characters that represent something Record: group of related fields File:
© 2004 Ken Baldauf, All rights reserved. Database Systems Organizing Data in a Database Using Database Systems in Organizations Emerging Database Trends.
Lecture 2 An Overview of Relational Database IST 318 – DB Admin.
RELATIONSHIPS Generally there are two main database types: flat-file and relational.
Management Information Systems MS Access MS Access is an application software that facilitates us to create Database Management Systems (DBMS)
Normalization (Codd, 1972) Practical Information For Real World Database Design.
CORE 2: Information systems and Databases NORMALISING DATABASES.
Access 2013 Microsoft Access 2013 is a database application that is ideal for gathering and understanding data that’s been collected on just about anything.
Lecturer: Gareth Jones. How does a relational database organise data? What are the principles of a database management system? What are the principal.
Lecture2: Database Environment Prepared by L. Nouf Almujally & Aisha AlArfaj 1 Ref. Chapter2 College of Computer and Information Sciences - Information.
Chapter 17 Creating a Database.
MS Access 2007 Management Information Systems 1. Overview 2  What is MS Access?  Access Terminology  Access Window  Database Window  Create New Database.
1 Relational Databases and SQL. Learning Objectives Understand techniques to model complex accounting phenomena in an E-R diagram Develop E-R diagrams.
Chapter 1Introduction to Oracle9i: SQL1 Chapter 1 Overview of Database Concepts.
® Microsoft Access 2010 Tutorial 9 Using Action Queries and Advanced Table Relationships.
DataBase Management System What is DBMS Purpose of DBMS Data Abstraction Data Definition Language Data Manipulation Language Data Models Data Keys Relationships.
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.
6.1 © 2010 by Prentice Hall 6 Chapter Foundations of Business Intelligence: Databases and Information Management.
Prepared by Jennifer Kreie, New Mexico State UniversityHosted by the University of Arkansas Microsoft Enterprise Consortium Database Fundamentals Physical.
Access Review. Access Access is a database application A database is a collection of records and files organized for a particular purpose Access supports.
Database revision.
+ Information Systems and Databases 2.2 Organisation.
Database Fundamentals CSC105 Furman University Peggy Batchelor.
Programming Logic and Design Fourth Edition, Comprehensive Chapter 16 Using Relational Databases.
Lesson 2: Designing a Database and Creating Tables.
Lection №4 Development of the Relational Databases.
BSA206 Database Management Systems Lecture 2: Introduction to Oracle / Overview of Database Concepts.
A table is a set of data elements (values) that is organized using a model of vertical columns (which are identified by their name) and horizontal rows.
1 DATABASE TECHNOLOGIES (Part 2) BUS Abdou Illia, Fall 2015 (September 9, 2015)
Chapter 10 Designing Databases. Objectives:  Define key database design terms.  Explain the role of database design in the IS development process. 
Understand Relational Database Management Systems Software Development Fundamentals LESSON 6.1.
6.1 © 2007 by Prentice Hall Chapter 6 (Laudon & Laudon) Foundations of Business Intelligence: Databases and Information Management.
Howard Paul. Sequential Access Index Files and Data File Random Access.
CHAPTER 2 : RELATIONAL DATA MODEL Prepared by : nbs.
McGraw-Hill/Irwin Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. Chapter 6 Modeling the Data: Conceptual and Logical Data Modeling.
INFORMATION TECHNOLOGY DATABASE MANAGEMENT. A database is a collection of information organized to provide efficient retrieval. The collected information.
Rationale Databases are an integral part of an organization. Aspiring Database Developers should be able to efficiently design and implement databases.
IT 5433 LM3 Relational Data Model. Learning Objectives: List the 5 properties of relations List the properties of a candidate key, primary key and foreign.
XP Chapter 1 Succeeding in Business with Microsoft Office Access 2003: A Problem-Solving Approach 1 Level 2 Objectives: Understanding and Creating Table.
Revised: 2 April 2004 Fred Swartz
Databases Chapter 16.
Chapter 9 Designing Databases
Database Fundamentals
Presentation transcript:

Database Design Ack: Amanda Gerdes

Overview  Learning the Language What’s A Database? How Do We Talk About Databases?  Database Models “Flat file” Database Relational Database  Relational Database Design Step One: Determine The Information You Need Step Two: Assign Your Attributes To Entities Step Three: Assign Primary Keys To Your Entities Step Four: Determine The Relationships Between Your Entities Step Five: Link Your Entities Together

Learning the Language What’s A Database?  Database: a collection of related records that is typically:... structured according to a schema … managed through a Database Management System (DBMS) Oooookay… that’s, uh… that’s just great. What the hell’s a schema? Or a DBMS?  Schema: the overall structure of the database which defines data represented in the database and the relationships between them  Database Management System (DBMS): a collection of software programs which aids in the storage, manipulation, reporting, management, and control of data that: … is a “front end” for the database, hiding potentially complex data relationships from the users … includes things like sales and order tracking systems and airline reservation systems … is often just called a “database” Hey, great. That’s not confusing at all.

Learning the Language How Do We Talk About Databases? idnameplanet 1LukeTatooine 2LeiaAlderaan 3HanCorellia 4ChewbaccaKashyyyk 5YodaCoruscant  Table: A set of data elements organized into horizontal rows (records) and vertical columns (fields). Each database can have multiple tables! A table has a specific number of columns but can have any number of rows.  Record: A row in the database representing a single set of related data. All records have the same structure (in this case id, name, and planet) and each element of a record is related.  Field: A column in the database representing a set of a type of data. In this case, the fields are id, name, and planet and each column provides a list of id numbers, names, and planets respectively. We will often see data types associated with fields. For example, our id field expects numbers.

Database Models The Flat Model  Flat Model: A two-dimensional array of data elements, consisting of only data and delimiters Delimiter: A sequence of one or more characters that specifies the boundary between fields and between records

Database Models The Flat Model (continued) idnameplanet 1LukeTatooine 2LeiaAlderaan 3HanCorellia 4ChewbaccaKashyyyk 5YodaCoruscant “1”,”Luke”,”Tatooine” “2”,”Leia”,”Alderaan” “3”,”Han”,”Corellia” “4”,”Chewbacca”,”Kashyyyk” “5”,”Yoda”,”Coruscant” 1-Luke-Tatooine/2-Leia- Alderaan/3-Han-Corellia/4- Chewbacca-Kashyyyk/5-Yoda- Coruscant/ Tab-Separated Record delimiter: Newline Field delimiter: Tab Comma-Separated Record delimiter: Newline Field delimiter: Comma Other Record delimiter: / Field delimiter: -

Database Models The Flat Model (continued)  Limitations The “flat file” database works when you’re collecting non- redundant data. Luke Skywalker only has one home planet; we’re not going to see him in our database twice. But what if we want to know what planets he’s visited? Suddenly, things are less simple… idnameplanet_fromplanet_to 1LukeTatooineYavin 4 2LeiaAlderaanHoth 3LukeTatooineHoth 4HanCorelliaHoth 5LukeTatooineDagobah 6LeiaAlderaanBespin 7HanCorelliaBespin 8LukeTatooineBespin 9LukeTatooine 10LukeTatooineEndor

Database Models The Relational Model  Relational Model: A database consisting of multiple tables, each similar to a “flat file” table, which are linked together through common fields Pieces of the Relational Database Entity: A table in a relational database. Attribute: A field in a relational database. Key: An attribute used to identify, sort, or link records in a database. Primary Key: A key that is a unique identifier for a single, specific record contained in a specified field. Foreign Key: A key that acts as a “link” between different tables/entities.

Database Models The Relational Model (continued)  Relational Model: … continued … Database Normalization: The process of restructuring a database to eliminate redundancy and organize data efficiently. Third Normal Form (3NF): The most common method of structuring a database; method where any field that is not directly related to the key is moved to a separate table. Product Number (primary key) Product NameManufacturerManufacturer Address 1337Nimbus 2000Nimbus Racing Broom CompanyDiagon Alley 4242Clone ArmyThe Galactic EmpireKamino, Outer Rim 6666The One RingDark Lord SauronMordor, Middle Earth 6789Nimbus 2001Nimbus Racing Broom CompanyDiagon Alley Product # (primary key) Product NameManufacturer 1337Nimbus 2000Nimbus Racing Broom Company 4242Clone ArmyThe Galactic Empire 6666The One RingDark Lord Sauron 6789Nimbus 2001Nimbus Racing Broom Company ManufacturerManufacturer Address Nimbus Racing Broom CompanyDiagon Alley The Galactic EmpireKamino, Outer Rim Dark Lord SauronMordor, Middle Earth Product InformationManufacturer Information

Relational Database Design Our Example  We’re part of a college advising team. Our job is to meet with students prior to the start of the semester, review their academic performance with them, go over pending degree requirements, and then counsel them about their best options for the coming semester.

Relational Database Design Step One: Determine The Information You Need  Make a list of the information we need. ▪ Student’s name ▪ Student’s address ▪ Names of classes ▪ Professors who are teaching the classes ▪ Contact info for professors ▪ Class start and end times ▪ Class locations ▪ Class descriptions ▪ Student’s major/emphasis ▪ Course number ▪ Student ID number

Relational Database Design Step Two: Assign Your Attributes To Your Entities  Now that we know what information we need, our next job is to organize the data pieces (fields/attributes) into categories (tables/entities). ▪ Student’s name ▪ Student’s address ▪ Names of classes ▪ Professors who are teaching the classes ▪ Contact info for professors ▪ Class start and end times ▪ Class locations ▪ Class descriptions ▪ Student’s major/emphasis ▪ Course number ▪ Student’s grades Info About StudentsInfo About ClassesInfo About Professors Tables/Entities Fields/Attributes

Relational Database Design Step Three: Assign Primary Keys To Your Entities  We now have three separate tables (entities) for our database. We now need a way to uniquely identify each row in each of the tables.  To determine a primary key, let’s do the following: Determine if we already have a field that uniquely identifies each row. Each value in this field must be completely unique within the entire table. If we do: This is called a natural key and we can use it as our primary key. If we don’t: We will have to add a field to our database to hold a unique identifier we can use as a primary key. We can either add a data field (e.g., a SSN acting as an ID number) or create what we call a surrogate key; this is just a “fake” value that has no real-world meaning to our row but will uniquely identify it (e.g., having the DBMS generate a random number or auto- increment number for every record)

Relational Database Design Step Three (Continued) STUDENT TABLE Student IDStudent Last Name Student First Name Address PotterHarryCupboard Under the Stairs 4 Privet Drive Little Whinging, Surrey GreyJeanXavier Institute for Higher Learning 1407 Greymalkin Lane Salem Center, New York BagginsFrodoBag End Hobbiton, Westfarthing of the Shire CLASSES TABLE Course #Course NameStart TimeEnd TimeDescriptionLocation ABC-109-1Lightsaber Combat10:00am3:00pmPrereq: Light Side100 Building A ABC-109-2Lightsaber Combat7:00pm10:00pmPrereq: Light Side104 Building A ABC-111-1Divination4:00pm7:00pmTea leaves, palmistry102 Building A ABC-112-1Tengwar 1017:00pm10:00pmIntro to Tengwar language100 Building A PROFESSORS TABLE Professor Last Name Professor First Name Phone Number Address Professor ID

Relational Database Design Step Four: Determine The Relationships Between Your Entities  Now that we have our entities more or less in order, our next job is to figure out how they are related to each other. One-to-One (1:1). One instance of Entity A relates to one instance of Entity B. Example: Every employee gets his/her own office; each employee gets only one office, each office houses only one employee One-to-Many (1:N). One instance of Entity A relates to many instances of Entity B. Example: Employees are assigned to different regional centers; each employee works at only one regional center, each regional center houses multiple employees Many-to-Many (M:N). Many instances of Entity A relate to many instances of Entity B. Example: Employees are assigned to projects; one employee has many projects and each project has many employees assigned to it

Relational Database Design Step Four: (continued)  Determine the relationship for our entities: Professors to Classes One professor can have ________ class(es). One class can have ________ professor(s). Students to Classes One student can have ________ class(es). One class can have ________ student(s). MANY ONE Many-To-Many One-To-Many

Relational Database Design Step Five: Link Your Entities Together  Now that we have our tables and we know how they are related to each other… we must link them together.  Linking Tables Related tables are linked via a common field The primary key in Entity A will appear as a foreign key in Entity B; we can then match Entity A’s primary key to Entity B’s foreign key for a match. Product # (primary key) Product NameManufacturer 1337Nimbus 2000Nimbus Racing Broom Company 4242Clone ArmyThe Galactic Empire 6666The One RingDark Lord Sauron 6789Nimbus 2001Nimbus Racing Broom Company ManufacturerManufacturer Address Nimbus Racing Broom CompanyDiagon Alley The Galactic EmpireKamino, Outer Rim Dark Lord SauronMordor, Middle Earth Foreign KeyPrimary Key=

Relational Database Design Step Five: (continued)  Guidelines for Linking Tables One-to-One: Either table can hold the foreign key. One-to-Many: The “Many” table should hold the foreign key. Many-to-Many: We will create a joint table that contains the primary keys for both tables.

Relational Database Design Step Five: (continued)  Linking Professors and Classes Relationship: ONE Professor to MANY Classes Keep in Mind: Foreign key belongs in the MANY table Foreign key in one table = Primary Key of the other table CLASSES TABLE Course # (primary key) Course NameStart TimeEnd TimeDescriptionLocation ABC-109-1Lightsaber Combat10:00am3:00pm{..}100 Building A ABC-109-2Lightsaber Combat7:00pm10:00pm{..}104 Building A ABC-111-1Divination4:00pm7:00pm{..}102 Building A ABC-112-1Tengwar 1017:00pm10:00pm{..}100 Building A PROFESSORS TABLE Professor ID (primary key) Professor Last Name Professor First Name Phone Number Address Professor ID (foreign key)

Relational Database Design Step Five: (continued)  Linking Students and Classes Relationship: MANY Students to MANY Classes With a Many-to-Many relationship, we have to create a joint table! A Joint Table should include: A primary key Foreign keys to each of the tables we’re linking Any data fields that are specific to the joint relationship (e.g., a student’s grade depends on both the student and the class)

Relational Database Design Step Five: (continued) CLASSES TABLE Course # (primary key) Course NameStart TimeEnd TimeDescriptionLocationProfessor ID (foreign key) ABC-109-1Lightsaber Combat10:00am3:00pm{..}100 Building A ABC-109-2Lightsaber Combat7:00pm10:00pm{..}104 Building A ABC-111-1Divination4:00pm7:00pm{..}102 Building A ABC-112-1Tengwar 1017:00pm10:00pm{..}100 Building A STUDENT TABLE Student ID (primary key) Student Last Name Student First Name Address PotterHarryCupboard Under the Stairs 4 Privet Drive Little Whinging, Surrey GreyJeanXavier Institute for Higher Learning 1407 Greymalkin Lane Salem Center, New York BagginsFrodoBag End Hobbiton, Westfarthing of the Shire STUDENTS-CLASSES TABLE ID Number (primary key) Student ID (foreign key) Course # (foreign key) Grade ABC-109-1B ABC-111-1B ABC-109-2C ABC-112-1A ABC-109-1A ABC-111-1B-

Relational Database Design Summary View CLASSES TABLE Course # (primary key) Course NameStart TimeEnd TimeDescriptionLocationProfessor ID (foreign key) ABC-109-1Lightsaber Combat10:00am3:00pm{..}100 Building A ABC-109-2Lightsaber Combat7:00pm10:00pm{..}104 Building A ABC-111-1Divination4:00pm7:00pm{..}102 Building A ABC-112-1Tengwar 1017:00pm10:00pm{..}100 Building A STUDENT TABLE Student ID (primary key) Student Last Name Student First Name Address PotterHarry{…} GreyJean{…} BagginsFrodo{…} STUDENTS-CLASSES TABLE ID Number (primary key) Student ID (foreign key) Course # (foreign key) Grade ABC-109-1B ABC-111-1B ABC-109-2C ABC-112-1A ABC-109-1A ABC-111-1B- PROFESSORS TABLE Professor ID (primary key) Professor Last Name Professor First Name Phone Number Address JonesIndiana {…} MiyagiKesuke {…} YodaMaster {…} KrabappleEdna {…}