All Powder Board and Ski Oracle 9i Workbook Chapter 3: Database Tables Jerry Post Copyright © 2003.

Slides:



Advertisements
Similar presentations
All Powder Board and Ski
Advertisements

1 All Powder Board and Ski Microsoft Access Workbook Chapter 5: Advanced Queries Jerry Post Copyright © 2007.
All Powder Board and Ski Microsoft Access Workbook Chapter 3: Database Tables Jerry Post Copyright © 2007.
ER Modeling Case Studies
Computer Science & Engineering 2111 Introduction to Database Systems 1CSE 2111-Introduction to Database Systems.
THE RELATIONAL DATABASE MODEL & THE DATABASE DEVELOPMENT PROCESS Fact of the Week: According to a Gartner study in ‘06, Microsoft SQL server had the highest.
Fundamentals, Design, and Implementation, 9/e COS 346 Day 11.
A Guide to SQL, Seventh Edition. Objectives Understand the concepts and terminology associated with relational databases Create and run SQL commands in.
Database Design Chapter 2. Goal of all Information Systems  To add value –Reduce costs –Increase sales or revenue –Provide a competitive advantage.
Database Design Concepts INFO1408 Term 2 week 1 Data validation and Referential integrity.
SQL DDL constraints Restrictions on the columns and tables 1SQL DDL Constraints.
5 Copyright © 2004, Oracle. All rights reserved. Creating a Master-Detail Form.
Access Lecture 1 Database Overview and Creating Tables Create an Employee Table.
Database Constraints. Database constraints are restrictions on the contents of the database or on database operations Database constraints provide a way.
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.
DAY 21: MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Akhila Kondai October 30, 2013.
Working with Queries in Microsoft Access The Access Workbench: Section Three DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 3 rd Edition.
DAY 15: ACCESS CHAPTER 2 Larry Reaves October 7,
Copyright  Oracle Corporation, All rights reserved. 4 CMIS Powell Oracle Designer: Creating the Database Design CMIS Powell.
Microsoft Access Introduction. What Is a Database Suppose you are a school administrator. You need to have information about –Students –Faculty –Staff.
All Powder Board and Ski SQL Server 2000 Workbook Chapter 1 Jerry Post Copyright © 2003.
MIS 301 Information Systems in Organizations Dave Salisbury ( )
IT354 Database Design Seminar 5: May 19, 2011 Physical Database Design Entity-Relationship Diagrams.
1 All Powder Board and Ski Oracle 9i Workbook Chapter 7: Integrity and Transactions Jerry Post Copyright © 2003.
1 All Powder Board and Ski SQL Server Workbook Chapter 2: Database Design Jerry Post Copyright © 2004.
1.NET Web Forms Business Forms © 2002 by Jerry Post.
Chapter 6 Database Administration
1 All Powder Board and Ski Oracle 9i Workbook Chapter 9: Database Administration Jerry Post Copyright © 2003.
M1G Introduction to Database Development 2. Creating a Database.
All Powder Board and Ski Oracle 9i Workbook Chapter 1 Jerry Post Copyright © 2003.
Intro to SQL| MIS 2502  Spacing not relevant › BUT… no spaces in an attribute name or table name  Oracle commands keywords, table names, and attribute.
5 Copyright © 2004, Oracle. All rights reserved. Creating a Master-Detail Form.
INFO1408 Database Design Concepts Week 15: Introduction to Database Management Systems.
MS Access. Access is a DBMS/RDMS DBMS = Database Management System RDMS = Relational Database Management System.
1 All Powder Board and Ski Oracle 9i Workbook Chapter 10: Distributed Databases Jerry Post Copyright © 2003.
1 Chapter 6 Database Administration. 2 Introduction Database administration The process of managing a database Database administrator A person or an entire.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
All Powder Board and Ski Microsoft Access Workbook Chapter 3: Database Tables Jerry Post Copyright © 2003.
All Powder Board and Ski Microsoft Access Workbook Chapter 2: Database Design Jerry Post Copyright © 2003.
Constraints cis 407 Types of Constraints & Naming Key Constraints Unique Constraints Check Constraints Default Constraints Misc Rules and Defaults Triggers.
1 All Powder Board and Ski Microsoft Access Workbook Chapter 8: Data Warehouses and Data Mining Jerry Post Copyright © 2003.
MIS 385/MBA 664 Systems Implementation with DBMS/ Database Management
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.
IS 380 Introduction to SQL This lectures covers material from: database textbook chapter 3 Oracle chapter: 3,14,17.
1 All Powder Board and Ski Microsoft Access Workbook Chapter 9: Database Administration Jerry Post Copyright © 2003.
CSC 240 (Blum)1 Introduction to Access CSC 240 (Blum)2 Click on the Access desktop icon or go to Start/All Programs/Microsoft Office/Microsoft Office.
MIS 301 Information Systems in Organizations Dave Salisbury ( )
1 All Powder Board and Ski Microsoft Access Workbook Chapter 5: Advanced Queries Jerry Post Copyright © 2003.
Concepts of Database Management Seventh Edition Chapter 4 Keys and Relationship.
IMS 4212: Constraints & Triggers 1 Dr. Lawrence West, Management Dept., University of Central Florida Stored Procedures in SQL Server.
Data Resource Management Application Layer TPS A RCHITECTURE Data Layer Sales/MarketingHR Finance/Accounting Operations Spreadsheet Data MS Access Accounts.
1 All Powder Board and Ski SQL Server Workbook Chapter 5: Advanced Queries Jerry Post Copyright © 2003.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 4 Basic SQL تنبيه : شرائح العرض (Slides) هي وسيلة لتوضيح الدرس واداة.
1 Data Normalization Text book Chapter 3: Jerry Post Copyright © 2003.
McGraw-Hill/Irwin Copyright © 2005 by The McGraw-Hill Companies, Inc. All rights reserved. Chapter 9: Database Administration All Powder Board and Ski.
CompSci 280 S Introduction to Software Development
Fundamentals of DBMS Notes-1.
Order Database – ER Diagram
Chapter 1: Introduction All Powder Board and Ski
Chapter 1 Introduction.
CSIS 115 Database Design and Applications for Business
Order Database – ER Diagram
Chapter 2: Database Design All Powder Board and Ski
All Powder Board and Ski
All Powder Board and Ski
Order Database – ER Diagram
Order Database – ER Diagram
Supplement: Using the DBDesign System
Constraints.
Creating a Master-Detail Form
Presentation transcript:

All Powder Board and Ski Oracle 9i Workbook Chapter 3: Database Tables Jerry Post Copyright © 2003

DBDesign: An Expert System Benefits Makes it easy to create database diagrams Saves data in central location, so changes can be made from almost any computer Provides immediate detailed feedback on the design Requirements Instructors must ask for a free account Instructors and students need a Java-enabled Web browser

Identifying Key Columns If you are uncertain about which columns to key. Write them down and evaluate the business rules. OrderIDCustomerID For a given order, can there ever be more than one customer? If yes, then key CustomerID. In most businesses, only one customer per order, so do not key it. For a given customer, can there ever be more than one order? If yes, then key OrderID, otherwise, do not key it. All businesses hope to get more than one order from a customer, so OrderID must be key. Underline it. Since OrderID is the only key, these columns belong in the Order table. CustomerOrder(OrderID CustomerID, … )

Sequences: Introduction Sometimes it is best to let the DBMS generate a guaranteed unique key value The table must contain a single column primary key that is assigned a numeric data type, such as NUMBER(38) Later, you will create a SEQUENCE to generate the numbers Later, you will create a trigger to automatically obtain and use the generated key value

Customer Skill Level CustomerID, LastName, … Style, SkillLevel Business rule: Each customer can have one skill in many styles. Business rule: Each style can apply to more than one customer. Need a table with both attributes as keys. CustomerID, LastName, … Style, SkillLevel But you cannot include LastName, FirstName and so on, because then you would have to re-enter that data for each customer skill. Consider what happens if you (incorrectly) try to place Style and SkillLevel in the Customer table:

Customer Style Skills Customer CustomerID LastName FirstName Phone Address City State ZIP CustomerSkill CustomerID Style SkillLevel Style StyleDescription SkillLevel SkillDescription

Creating Tables with the Editor Table name Data type Data size Column name Primary key

Primary Key Constraint Create unique name Select Primary constraint type Select the columns that make up the primary key

Constraints Unique name Acceptable values CHECK constraint type

Create Tables with SQL CREATE TABLE Customer ( CustomerIDNUMBER(38), LastNameNVARCHAR2(25), FirstNameNVARCHAR2(25), PhoneNVARCHAR2(25), NVARCHAR2(120), AddressNVARCHAR2(50), CityNVARCHAR2(50), StateNVARCHAR2(25), ZIPNVARCHAR2(15), GenderNVARCHAR2(15), DateOfBirthDATE, CONSTRAINT pk_Customer PRIMARY KEY (CustomerID), CONSTRAINT ck_CustGender CHECK (Upper(Gender) IN ('FEMALE', 'MALE', 'UNIDENTIFIED')) );

Table in SQL: ProductCategory CREATE TABLE ProductCategory ( CategoryNVARCHAR2(50), CategoryDescriptionNVARCHAR2(250), CONSTRAINT pk_ProductCategory PRIMARY KEY (Category) );

ANALYZE TABLE ANALYZE TABLE PaymentMethod COMPUTE STATISTICS; One command for each table Substantial performance improvement

Relationships: Department and Employee Employee EmployeeID TaxpayerID LastName FirstName Address Phone City State ZIP Department Description 1…1 1…* Foreign Key Reference Table

Relationship: Foreign Key Constraint Employee table Department table must be created first Foreign key constraint Column in the Employee table Column in the Department table Reference tableCascade is important

Relationships in SQL CREATE TABLE Department ( DepartmentNVARCHAR2(50), DescriptionNVARCHAR2(150), CONSTRAINT pk_Department PRIMARY KEY (Department) ); CREATE TABLE Employee ( EmployeeIDINTEGER, TaxpayerIDNVARCHAR2(50), LastNameNVARCHAR2(25), FirstNameNVARCHAR2(25), AddressNVARCHAR2(50), PhoneNVARCHAR2(25), CityNVARCHAR2(50), StateNVARCHAR2(15), ZIPNVARCHAR2(15), DepartmentNVARCHAR2(50) DEFAULT ‘Sales’, CONSTRAINT pk_Employee PRIMARY KEY (EmployeeID), CONSTRAINT fk_DepartmentEmployee FOREIGN KEY (Department) REFERENCES Department(Department) ON DELETE CASCADE );

Estimating Database Size CustomerIDLong4 LastNameText(50)30 FirstNameText(50)20 PhoneText(50)24 Text(150)50 AddressText(50)50 StateText(50)2 ZIPText(15)14 GenderText(15)10 DateOfBirthDate8 Average bytes per customer212 Customers per week (winter)*200 Weeks (winter)*25 Bytes added per year1,060,000

Data Assumptions 200 customers per week for 25 weeks 2 skills per customer 2 rentals per customer per year 3 items per rental 20 percent of customers buy items 4 items per sale 100 manufacturers 20 models per manufacturer 5 items (sizes) per model

Database Table Sizes