ISM 4212 Lab Creating DB Tables 02 copyright Lars Paul Linden 2007.

Slides:



Advertisements
Similar presentations
Microsoft® Access® 2010 Training
Advertisements

Database Basics. What is Access? Database management system Computer-based equivalent of a manual database Makes it easy to organize and update information.
Introduction to Microsoft Access
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.
Prepared by Jennifer Kreie, New Mexico State UniversityHosted by the University of Arkansas Microsoft Enterprise Consortium SQL Fundamentals Create Student-Team.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 11-1 David M. Kroenke’s Chapter Eleven: Managing Databases with SQL Server.
Access - Project 1 l What Is a Database? –A Collection of Data –Organized in a manner to allow: »Access »Retrieval »Use of That Data.
XP New Perspectives on Microsoft Office Access 2003, Second Edition- Tutorial 2 1 Microsoft Office Access 2003 Tutorial 2 – Creating And Maintaining A.
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.
Database Design Concepts INFO1408 Term 2 week 1 Data validation and Referential integrity.
Figure 1. Hit analysis in 2002 of database-driven web applications Hits by Category in 2002 N = 73,873 Results Reporting 27% GME 26% Research 20% Bed Availability.
Microsoft Access 2007 Microsoft Access 2007 Introduction to Database Programs.
® IBM Software Group © 2006 IBM Corporation The Eclipse Data Perspective and Database Explorer This section describes how to use the Eclipse Data Perspective,
Access Tutorial 8 Sharing, Integrating, and Analyzing Data
Using ER/Studio.
Access Tutorial 10 Automating Tasks with Macros
Overview What is SQL Server? Creating databases Administration Security Backup.
ACCESS CHAPTER 1. OBJECTIVES Tables Queries Forms Reports Primary and Foreign Keys Relationship.
Database Applications – Microsoft Access Lesson 2 Modifying a Table and Creating a Form 45 slides in presentation Accessibility check 9/14.
ASP.NET Programming with C# and SQL Server First Edition
Working with Queries in Microsoft Access The Access Workbench: Section Three DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 3 rd Edition.
Creating Databases with MySQL Workbench Build the Forums database in Ullman’s Chapter 6.
Lecture Note 9: Introduction to the MS Access
CITY UNIVERSITY / Vysoká Škola Manažmentu.:IS Information Systems :. © Martina Cesalova, 2005 MS ACCESS 1 Start Microsoft Access – New - Blank Database.
Chapter 6 Advanced Report Techniques
Creating a Web Site to Gather Data and Conduct Research.
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.
McGraw-Hill/Irwin ©2009 The McGraw-Hill Companies, All Rights Reserved Business Driven Information Systems 2e Plug-In T6: Basic Skills and Tools Using.
Office 2003 Advanced Concepts and Techniques M i c r o s o f t Access Project 6 Switchboards, PivotTables, and PivotCharts.
Microsoft Access 2000 Presentation 2 Creating Databases Part I (Creating Tables)
XP New Perspectives on Microsoft Access 2002 Tutorial 21 Microsoft Access Tutorial 2 – Creating And Maintaining A Database.
Microsoft Office 2007 Access Chapter 6 Using Macros, Switchboards, PivotTables, and PivotCharts.
XP New Perspectives on Microsoft Office Access 2003, Second Edition- Tutorial 2 1 Microsoft Office Access 2003 Tutorial 2 – Creating And Maintaining A.
WEEK 11 Database Design. TABLE INSTANCE CHARTS Create Tables.
Dreamweaver MX. 2 Overview of Templates n Templates represent a web page design or _______ that will be common to multiple pages. n There are two situations.
McGraw-Hill/Irwin © 2008 The McGraw-Hill Companies, All Rights Reserved Plug-In T6: Basic Skills and Tools Using Access 2010 Business Driven Technology.
Personal Oracle8i Create a new user Create a new table Enter data into a new table Export & import data Start and exit SQL Plus SQL Plus Syntax.
5 Copyright © 2004, Oracle. All rights reserved. Creating a Master-Detail Form.
Office 2003 Post-Advanced Concepts and Techniques M i c r o s o f t Access Project 7 Advanced Report and Form Techniques.
Microsoft Access 2010 Chapter 10 Administering a Database System.
© 2002 by Prentice Hall 1 Database Processing with Microsoft Access David M. Kroenke Database Concepts 1e Appendix A.
® Microsoft Office 2013 Access Creating a Database.
IST 220 Introduction to Databases Course Wrap-up.
Copyright 2007, Paradigm Publishing Inc. ACCESS 2007 Chapter 2 BACKNEXTEND 2-1 LINKS TO OBJECTIVES Creating Related Tables Creating Related Tables Determining.
Unit 5 Microsoft SQL Server and MySQL. Key Concepts DBMS variations SQL Server features SQL Server Management Studio MySQL features Scripts Queries Database.
McGraw-Hill/Irwin © The McGraw-Hill Companies, All Rights Reserved TECHNOLOGY PLUG-IN T6 Basic Skills Using Access.
Course ILT Forms and queries Unit objectives Create forms by using AutoForm and the Form Wizard, and add or modify form headers and footers Open and enter.
Database Processing with Microsoft Access Appendix DAVID M. KROENKE’S DATABASE CONCEPTS, 2 nd Edition.
3 Copyright © 2004, Oracle. All rights reserved. Working in the Forms Developer Environment.
Ch. 101 Database Management An Introduction to Databases.
Fall 2003Sylnovie Merchant, Ph.D. ACCESS Tutorial Note: The purpose of this tutorial is to provide an introduction to some of the functions of ACCESS in.
INTRODUCTION TO ACCESS. OBJECTIVES  Define the terms field, record, table, relational database, primary key, and foreign key  Create a blank database.
Personal Oracle8i Create a new user Create a new table Enter data into a new table Export & import data Start and exit SQL Plus SQL Plus Syntax.
Enterprise manager Using the Enterprise manager. Purpose of the Enterprise Manager To design tables To populate / update tables To draw diagrams of tables.
IMS 4212 Lab: Lab Introduction 1 Dr. Lawrence West, MIS Dept., University of Central Florida Subject—Topics Installing.
Modify Tables and FieldsModify Tables and Fields Lesson 4 © 2014, John Wiley & Sons, Inc.Microsoft Official Academic Course, Microsoft Word Microsoft.
Class11 Introduction to relational databases and MySQL MIS 3501, Fall 2015 Brad Greenwood, PhD MBA Department of MIS Fox School of Business Temple University.
MSOffice Access Microsoft® Office 2010: Illustrated Introductory 1 Part 1 ® Database & Table.
Microsoft Office 2013 Try It! Chapter 4 Storing Data in Access.
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.
Access Module Implementing a Database with Microsoft Access A Great Module on Your CD.
MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Sravanthi Lakkimsety Mar 14,2016.
1 Access Lesson 1 Understanding Access Fundamentals Microsoft Office 2010 Fundamentals Story / Walls.
Copyright © 2014 Pearson Canada Inc. Ext. 5b-1 Copyright © 2014 Pearson Canada Inc. Application Extension 5b Using Microsoft Access Part 2: Using Information.
2 Copyright © 2008, Oracle. All rights reserved. Building the Physical Layer of a Repository.
SQL MODELER - OPEN There are Three Ways to open the SQL Modeler
ORACLE SQL Developer & SQLPLUS Statements
Presentation transcript:

ISM 4212 Lab Creating DB Tables 02 copyright Lars Paul Linden 2007

UCF 2ISM 4212 Lab Lab Overview Last Week: Introduction to the SQL Server DBMS Creating Databases Moving Databases This Week: Creating DB Tables Next Week: Introduction to SQL SELECT Statements

UCF 3ISM 4212 Lab Today’s Agenda CREATE tables and DROP tables (GUI and SQL) Fields (the columns), including setting field data types More about creating tables NULL / NOT NULL IDENTITY keyword PRIMARY KEY DEFAULT values Setting table properties Create a diagram Multi-page diagrams Using the diagram as an editing tool for DB objects Relationships between tables

UCF 4ISM 4212 Lab Create Tables and Drop Tables

UCF 5ISM 4212 Lab Two Ways of Creating Tables Graphical User Interface’s (GUI) “New Table” form Execute SQL in a Query Pane

UCF 6ISM 4212 Lab The GUI’s “New Table” form Using SQL Server Manager Studio, open the your database in the Object Explorer Expand the database to see the “Tables” folder Right click on “Tables” and select “New Table…” In the pane that opens, enter a “Column Name”, hit tab, use the drop down to specify a “Data Type”, and check “Allow Nulls” depending on your design Complete cells with column metadata Repeat until all of your columns are specified When done, “X” out the pane, respond “Yes” Finally, in the “Choose Name” pop-up, type in the name of your table, and click “OK”

UCF 7ISM 4212 Lab Having Created It, Display Your Table Using SQL Server Manager Studio In the Object Explorer, open the your database Expand the database to see the “Tables” folder Expand the “Tables” folder to see the name of your table Right click on the name of your table and select “Modify” Note: select “Open Table” to see the table’s data

UCF 8ISM 4212 Lab basic CREATE TABLE syntax CREATE TABLE Products ( ProductID INT, ProductName CHAR(20), Price MONEY ) Commas between column specifications Parenthesis around Column specifications Notice how each line has a field name and that field’s data type

UCF 9ISM 4212 Lab Another way to create a table with SQL Open a Query Pane Open the “Template Explorer” Under “Table”, select “Create Table” Replace the as needed an example of the syntax is on the next slide And, of course, execute

UCF 10ISM 4212 Lab Drop a Table (GUI) Using SQL Server Manager Studio, open the your database in the Object Explorer Expand the database to see the “Tables” folder Expand the “Tables” folder to see the name of your table Right click on the name of your table and select “Delete” Click on “Yes” to confirm

UCF 11ISM 4212 Lab Drop a Table (SQL) # Make sure you are using the correct database DROP TABLE YourTableName

UCF 12ISM 4212 Lab Setting table properties

UCF 13ISM 4212 Lab table properties In Object Explorer right-click on the table name Select “Properties”

UCF 14ISM 4212 Lab More about creating DB tables

UCF 15ISM 4212 Lab Look at an existing table In “Northwind” Open the “Shippers” table Using Rgt-Click “Modify” Note the following: A. Allow Nulls B. Identify Specification C. Primary Key icon D. Default values (not shown) Now we covers these four topics… C A B

UCF 16ISM 4212 Lab CREATE TABLE with NULL or NOT NULL CREATE TABLE Products2 ( ProductID INTNOT NULL, Name CHAR(20) NOT NULL, Price MONEYNOT NULL, Description CHAR(100)NULL ) After executed, you can view the table and check what you created for the Description field: A.

UCF 17ISM 4212 Lab What is the impact of the NOT NULL? In a few weeks, in the lab when we INSERT data into a table, we’ll see that if a field is marked as NOT NULL then data must be inserted into that field or an error message will result. That is, there is a constraint on that field in the table Any row of data in that table, must have data in any NOT NULL field. A.

UCF 18ISM 4212 Lab CREATE TABLE with an IDENTITY What does the IDENTITY do? Automatically increments on insert Only one per table By itself, not guaranteed unique You can turn it on and off Now, see the syntax… B.

UCF 19ISM 4212 Lab CREATE TABLE with an IDENTITY CREATE TABLE Products3 ( ProductID INTIDENTITYNOT NULL, Name CHAR(20) NOT NULL, Price MONEYNOT NULL, Description CHAR(100)NULL ) After executed, you can view the table and check the result at the bottom under “Column Properties”: B.

UCF 20ISM 4212 Lab What is the impact of the IDENTITY? In a few weeks, in the lab when we INSERT data into a table, we’ll see that if a field has an IDENTITY then the “seed” automatically increments and is inserted into that field of the row when the row is inserted into the table. This is perfect for some Primary Keys B.

UCF 21ISM 4212 Lab One little trick to know about the IDENTITY You can specify how the identity is going to behave: IDENTITY (, ) CREATE TABLE Products4 ( ProductID INTIDENTITY(10,5)NOT NULL, Name CHAR(20) NOT NULL, Price MONEYNOT NULL, Description CHAR(100)NULL ) B.

UCF 22ISM 4212 Lab One little trick to know about the IDENTITY When viewing the table, in the “Column Properties” section, expand the “Identity Specification” The details of the Identity B. (con’t)

UCF 23ISM 4212 Lab CREATE TABLE with a PRIMARY KEY CREATE TABLE Categories ( CategoryIDint NOT NULL, CategoryNamenvarchar(15)NOT NULL, DescriptionntextNULL, CONSTRAINT PK_Categories PRIMARY KEY (CategoryID) ) C. the name of this constraint the type of constraint the field that is the PK

UCF 24ISM 4212 Lab CREATE TABLE with a PRIMARY KEY After executed, you can view the table and see a check for the PK icon: C.

UCF 25ISM 4212 Lab What is the impact of a PRIMARY KEY ? For starters, it is a constraint “Enforces uniqueness for the purpose of identifying a row.” - Turley, page 331 C.

UCF 26ISM 4212 Lab Default values When a new row is inserted into this table, if the “State” field is not specified in the insert statement, then the system automatically add the default field of ‘FL’. CREATE TABLE Locations ( LocationID INT IDENTITY NOT NULL, LocationName CHAR(20) NOT NULL, State CHAR(2) NOT NULL DEFAULT 'FL' ) D.

UCF 27ISM 4212 Lab Evidence of the Default values D. Select the field then look below

UCF 28ISM 4212 Lab Diagram

UCF 29ISM 4212 Lab Create a diagram Using SQL Server Manager Studio, Open the your database in the Object Explorer Expand the database to see the “Database Diagrams” folder Right click on “Database Diagrams and select “New Database Diagram” Add Tables To save, right click on the tab of the pane and enter a name in the “Choose Name” pop-up

UCF 30ISM 4212 Lab Miscellaneous Diagram Operations On menu, select “Database Diagram” and then “Arrange Tables” To zoom, right click on the background and select “Zoom” To change the appearance of a table, right click on a table and select “Table View” and then a new selection

UCF 31ISM 4212 Lab From a diagram, you can alter your tables In the diagram, right click on the table Choose a selection, for example, “Insert Column” When you are all done, make sure you save the diagram by right-clicking on the tab and selecting “Save…”

UCF 32ISM 4212 Lab Help with Multi-page diagrams With the diagram open… Right click on the background and select “View Page Breaks”

UCF 33ISM 4212 Lab Save Your Diagram Right-click on the tab, and select save Give your diagram a name The diagram is then available in the Object Explorer under “Database Diagrams”

UCF 34ISM 4212 Lab Create a Relationship Between Two Tables

UCF 35ISM 4212 Lab Inspect a One-to-Many Relationship First, lets look at an example In Northwind… Focus on just the Categories table and the Products table Notice that the Categories table has a CategoryID and that the Products table has a CategoryID There exists a relationship between these two tables Specifically, Products.CategoryID is a Foreign Key that references the Categories.CategoryID which is a Primary Key (con’t on next slide)

UCF 36ISM 4212 Lab Inspect a One-to-Many Relationship (con’t from previous slide) To find evidence of this relationship… Open Northwind’s “Products” table Right-click on the background and select “Relationships” In the “Foreign Key Relationships” pop-up window, find the “Selected Relationships” area that lists the existing relationships Highlight the “FK_Products_Categories” and then expand the part of the window where it says “Tables and Columns Specification” … this will show the tables and attributes. (con’t on next slide) (con’t)

UCF 37ISM 4212 Lab Inspect a One-to-Many Relationship (con’t) Lists the details of the relationship

UCF 38ISM 4212 Lab Creating a One-to-Many Relationship (GUI) First, create two tables that can be used in the example CREATE TABLE MyCategories ( CategoryIDintIDENTITY(1,1)NOT NULL, CategoryNamenvarchar(15)NOT NULL, DescriptionntextNULL, CONSTRAINT PK_MyCategories PRIMARY KEY (CategoryID) ) CREATE TABLE MyProducts ( ProductID INT, ProductName CHAR(20), Price MONEY, CategoryID INT NOT NULL ) (con’t)

UCF 39ISM 4212 Lab Creating a One-to-Many Relationship (GUI) Now create the relationship, where the MyProducts.CategoryID is the FK and the MyCategories.CategoryID is the PK From the Object Explorer, right click and “modify” the MyProducts table Right click on background and select “Relationships” Click “Add” Under “Identity” where it says (name), enter the name of the relationships (e.g. FK_MyProducts_MyCategories) Under “Tables and Columns Specification” click the button that has the ellipsis (“…”) Select a table and field for the Primary Key and the Foreign Key “OK” to save and “Close” to exit “Foreign Key Relationship” pop-up (con’t)

UCF 40ISM 4212 Lab Creating a One-to-Many Relationship (SQL) First, create two tables that can be used in the example CREATE TABLE MyCategories2 ( CategoryIDintIDENTITY(1,1)NOT NULL, CategoryNamenvarchar(15)NOT NULL, DescriptionntextNULL, CONSTRAINT PK_MyCategories2 PRIMARY KEY (CategoryID) ) CREATE TABLE MyProducts2 ( ProductID INT, ProductName CHAR(20), Price MONEY, CategoryID INT NOT NULL FOREIGN KEY REFERENCES MyCategories2 (CategoryID) )

UCF 41ISM 4212 Lab Bonus

UCF 42ISM 4212 Lab Ctrl+K, Ctrl+C to Comment SQL Ctrl+K, Ctrl+U to Uncomment SQL

UCF 43ISM 4212 Lab Another way to see your table’s metadata EXEC sp_help YourTableName Note: the “sp_help” is a stored procedure that comes with the installation. We’ll learn more about stored procedures in a few weeks.

UCF 44ISM 4212 Lab Next Week

UCF 45ISM 4212 Lab Next Topic 1. Introduction to SQL SELECT Statements including the following important SQL keywords: WHERE ORDER BY AS

UCF 46ISM 4212 Lab To Do List 1. Practice 2. Read Ch. 3 (pp ): Statements 3. Read Ch. 4 (pp ): JOINs