Normalizing Database Files Professor Ralph Westfall May, 2011.

Slides:



Advertisements
Similar presentations
WaveMaker Visual AJAX Studio 4.0 Training
Advertisements

Stored procedures and views You can see definitions for stored procedures and views in the demo databases but you can’t change them. For views, expand.
Microsoft SQL Server 2008 From the Program menu choose: Microsoft SQL Server 2008 R2  SQL Server Management Studio. You may see a window indicating the.
Using Macros and Visual Basic for Applications (VBA) with Excel
Visual Basic.NET Data Entry Professor Ralph Westfall April 2011.
BIM211 – Visual Programming Database Operations 1.
Concepts of Database Management Seventh Edition
Concepts of Database Management Sixth Edition
Concepts of Database Management Seventh Edition
Microsoft Office 2010 Access Chapter 1 Creating and Using a Database.
Microsoft Excel 2010 Chapter 7
Office 2003 Introductory Concepts and Techniques M i c r o s o f t Access Project 2 Querying a Database Using the Select Query Window.
XP Chapter 3 Succeeding in Business with Microsoft Office Access 2003: A Problem-Solving Approach 1 Analyzing Data For Effective Decision Making.
A Guide to SQL, Seventh Edition. Objectives Understand the concepts and terminology associated with relational databases Create and run SQL commands in.
Creating And Maintaining A Database. 2 Learn the guidelines for designing databases When designing a database, first try to think of all the fields of.
Stored Procedures Dr. Ralph D. Westfall May, 2009.
Chapter 2 Querying a Database
Advanced Tables Lesson 9. Objectives Creating a Custom Table When a table template doesn’t suit your needs, you can create a custom table in Design view.
Page 1 ISMT E-120 Desktop Applications for Managers Introduction to Microsoft Access.
Copyright 2007, Paradigm Publishing Inc. BACKNEXTEND 3-1 LINKS TO OBJECTIVES Save a Filter as a Query Save a Filter as a Query Parameter Query Inner, Left,
1 Working with MS SQL Server. 2 Objectives You will be able to Use Visual Studio for GUI based interactive access to a Microsoft SQL Server database.
1 Insert, Update and Delete Queries. 2 Return to you Address Book database. Insert a record.
Concepts of Database Management, Fifth Edition
MBAC 611.  Click on the My Computer Icon  Open your private network directory  Create a new folder named lab7  Copy your lab6 Access file to the lab7.
Databases and LINQ Visual Basic 2010 How to Program 1.
Chapter 2 Querying a Database MICROSOFT ACCESS 2010.
Databases in Visual Studio. Database in VisualStudio An MS SQL database are built in Visual studio The Name can be something like ”(localdb)\Projects”
Introduction to Microsoft Access Danielle Zammit B.Pharm. (Hons.), M.S.(Pharm.)
Mr. Justin “JET” Turner CSCI 3000 – Fall 2015 CRN Section A – TR 9:30-10:45 CRN – Section B – TR 5:30-6:45.
Creating a Web Site to Gather Data and Conduct Research.
Microsoft Access Lesson 1 Lexington Technology Center February 11, 2003 Bob Herring On the Web at
Analyzing Data For Effective Decision Making Chapter 3.
1 Data Bound Controls II Chapter Objectives You will be able to Use a Data Source control to get data from a SQL database and make it available.
Microsoft Access – Tutorial 2 Designing Databases In this tutorial, we will create a new database create a new table import tables from an existing database.
1 Working with MS SQL Server Textbook Chapter 14.
Office 2003 Advanced Concepts and Techniques M i c r o s o f t Access Project 6 Switchboards, PivotTables, and PivotCharts.
Microsoft Office 2007 Access Chapter 2 Querying a Database.
WEEK 11 Database Design. TABLE INSTANCE CHARTS Create Tables.
Microsoft Access You will need a pen/pencil.. What is Microsoft Access? Access is a database management system.  Create a database, add/change delete.
ISM 4212 Lab Creating DB Tables 02 copyright Lars Paul Linden 2007.
Concepts of Database Management Seventh Edition
CIS 338: Using Queries in Access as a RecordSource Dr. Ralph D. Westfall May, 2011.
U:/msu/course/cse/103 Day 06, Slide 1 CSE students: Do not log in yet. Review Day 6 in your textbook. Think about.
Tutorial 9 Using Action Queries and Advanced Table Relationships.
Copyright 2007, Paradigm Publishing Inc. ACCESS 2007 Chapter 2 BACKNEXTEND 2-1 LINKS TO OBJECTIVES Creating Related Tables Creating Related Tables Determining.
Introduction to Database using Microsoft Access 2013 Part 7 November 19, 2014.
® Microsoft Access 2010 Tutorial 12 Managing and Securing a Database.
XP Chapter 2 Succeeding in Business with Microsoft Office Access 2003: A Problem-Solving Approach 1 Building The Database Chapter 2 “It is only the farmer.
INFORMATION TECHNOLOGY DATABASE MANAGEMENT. Adding a new field 1Right click the table name and select design view 2Type the field information at the end.
CIS 338: VB.NET & Databases Dr. Ralph D. Westfall May, 2011.
Gold – Crystal Reports Introductory Course Cortex User Group Meeting New Orleans – 2011.
Task #1 Create a relational database on computers in computer classroom 308, using MySQL server and any client. Create the same database, using MS Access.
1 Chapter 10 – Database Management 10.1 An Introduction to Databases 10.2 Editing and Designing Databases.
MSOffice Access Microsoft® Office 2010: Illustrated Introductory 1 Part 1 ® Database & Table.
Change Display of a Key Figure While in the Change Query (Local Definition) Hiding 1.Right click.
Change Display of a Key Figure While in the Change Query (Local Definition) Hiding 1.Right click.
Office 2003 Introductory Concepts and Techniques M i c r o s o f t Access Project 2 Querying a Database Using the Select Query Window.
SQL server Section 2&3. What are Data Types Character Data Types Number Data Types Date and Time Data Types CAST and CONVERT functions TRY_PARSE and TRY_CONVERT.
CSCI 3327 Visual Basic Chapter 13: Databases and LINQ UTPA – Fall 2011.
CIS 338: VB.NET Printing Dr. Ralph D. Westfall May, 2011.
Visual Database Creation with MySQL Workbench 도시정보시스템 설계
Physical Layer of a Repository. March 6, 2009 Agenda – What is a Repository? –What is meant by Physical Layer? –Data Source, Connection Pool, Tables and.
Chapter 7 Creating Templates, Importing Data, and Working with SmartArt, Images, and Screen Shots Microsoft Excel 2013.
Visual Basic 2010 How to Program
Stored Procedures Dr. Ralph D. Westfall May, 2011.
Database application MySQL Database and PhpMyAdmin
Normalizing an Existing Table
CIS16 Application Programming with Visual Basic
CIS16 Application Programming with Visual Basic
Presentation transcript:

Normalizing Database Files Professor Ralph Westfall May, 2011

Concepts Covered Using SQL Server Management Studio to take unnormalized data in a file and splitting it into two normalized files  For example, repeated data in a field that has a one to many or many to many relationship with the other fields in the table Doing the same thing with Excel

Create Non-Redundant Table CREATE TABLE currenciesCKey ( Currency VARCHAR(15)) INSERT INTO currencies (Currency) SELECT DISTINCT Currency from nations Word DISTINCT gets rid of duplicated entries in the normalized new table

Finish Creating New Table Click Execute button  Click in Object Explorer window, then click Refresh icon and expand Tables node for this database to see the new table  May need to right-click Tables>Refresh for the database used to see table that was just created

Add Normalized New Table Key Right-click this new table name>Design  Right-click top field>Insert Column  Change Data Type to int (or something else appropriate)‏  Right-click this new column>Set Primary Key  Set (Is Identity) to Yes in Column Properties  Set Identity Seed to a value large enough so all current and expected rows will have same number of digits in their key Click diskette icon to save this new table

Create Table with Foreign Key Define a new table that has a foreign key to reference the data in the second table Do a join that includes all fields from both tables EXCEPT for the field that went into the separate normalized table  the key field from the second table gets added to the new table but the data the key field references doesn't go into it Results of this join fill the new table with data

Create Table with Foreign Key CREATE TABLE [table] ([field [datatype], [field] [datatype], etc.)‏ INSERT INTO [table] ([field], [field], [field],[table].[field], etc.)‏ WHERE [table].[field]=[other_table].[field] Will have all fields (excluding duplicates) in the new table  Will need to qualify fields with same names in both tables by name of the table they come from Execute, then Refresh to see the new table See sample code in Notes

Verify Data Use SQL Server Management Studio to Select Top 1000 Rows to see data in new table  visually check foreign keys against values in other table Or run a SQL query to join and view the data

Backup Backup data from the original table  Right-click database name>Tasks>Export Data>Next  Data source is SQL Server Native Client 10.0>Use Windows Authentication>Database is the one that was being used>Next  Create a new.txt file on desktop>Destination is Flat File Destination>Browse for that file>Format: Delimited>Next  Copy data from one or more etc.>Next  Source table or view: [original table]>Next>Next> Finish

Finish Backup and Delete Verify that the new table has the same number of rows as the original table  SELECT COUNT([key_field]) FROM [original_table] and then repeat with new table Delete the original table Detach the database

Excel Could easily normalize small and middle sized data sets in Excel See Filter for unique values or remove duplicate values for how to get unique values for second tableFilter for unique values or remove duplicate values Copy the column to be normalized into a new table  add sequence of numbers in column to the left  put captions over each of these two columns  follow instructions in the link above

Excel - 2 Add an extra column to the main table  create a VLOOKUP column on the second table you just created that converts the data in the un- normalized column in the main table to the key value  use Paste Special to replace the actual with key values  save both tables as.csv files to load into a database