Agenda for Class 2/16/2012 Introduce Microsoft’s SQL Server database management system. Use the lab to discuss how to CREATE, DROP and populate (INSERT)

Slides:



Advertisements
Similar presentations
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.
Advertisements

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.
Brian Alderman | MCT, CEO / Founder of MicroTechPoint Pete Harris | Microsoft Senior Content Publisher.
Let’s try Oracle. Accessing Oracle The Oracle system, like the SQL Server system, is client / server. For SQL Server, –the client is the Query Analyser.
NMED 3850 A Advanced Online Design February 25, 2010 V. Mahadevan.
 Review HW #4  Answer questions about Microsoft Visio  Introduce SQL  Introduce SQL Server 2008 environment for programming SQL  Will meet in AB208.
Chapter 12: ADO.NET and ASP.NET Programming with Microsoft Visual Basic.NET, Second Edition.
Access Tutorial 1 Creating a Database
DT211 Stage 2 Databases Lab 1. Get to know SQL Server SQL server has 2 parts: –A client, running on your machine, in the lab. You access the database.
Chapter 7 Managing Data Sources. ASP.NET 2.0, Third Edition2.
PHP and SQL Server: Queries IST2101. Three-Tier Architecture Three-tier architecture means that the Web server and the DBMS are on separate servers IST2102.
DAT702.  Standard Query Language  Ability to access and manipulate databases ◦ Retrieve data ◦ Insert, delete, update records ◦ Create and set permissions.
Your Oracle Account UserName is the same as your UWP username Followed Not case sensitive Initial Password: UWPstudent Password is case sensitive.
Stored Procedures Dr. Ralph D. Westfall May, 2009.
Tutorial 1 Creating a Database. Objectives Learn basic database concepts and terms Learn basic database concepts and terms Explore the Microsoft Access.
1 Working with MS SQL Server II. 2 The sqlcmd Utility Command line utility for MS SQL Server databases. Previous version called osql Available on classroom.
Overview What is SQL Server? Creating databases Administration Security Backup.
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.
A Guide to SQL, Eighth Edition Chapter Three Creating Tables.
Microsoft Azure Introduction ISYS 512. Microsoft Azure Microsoft Azure is a cloud.
ASP.NET Programming with C# and SQL Server First Edition
1 MySQL and phpMyAdmin. 2 Navigate to and log on (username: pmadmin)
® Microsoft Access 2010 Tutorial 1 Creating a Database.
CS 3630 Database Design and Implementation. Your Oracle Account UserName is the same as your UWP username Followed Not case sensitive Initial.
1 Working with MS SQL Server Textbook Chapter 14.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 Working with MSSQL Server Code:G0-C# Version: 1.0 Author: Pham Trung Hai CTD.
Introduction to MySQL Lab no. 10 Advance Database Management System.
NMED 3850 A Advanced Online Design January 12, 2010 V. Mahadevan.
ISM 4212 Lab Creating DB Tables 02 copyright Lars Paul Linden 2007.
SQL Data Definition Language (DDL) Using Microsoft SQL Server 1SDL Data Definition Language (DDL)
CSCI 6962: Server-side Design and Programming Database Manipulation in ASP.
Structured Query Language (SQL) IST2101. Structured Query Language – Acronym: SQL – Pronounced as “S-Q-L” [“Ess-Que-El”] – Originally developed by IBM.
1 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 8 DATABASE DESIGN AND DEVELOPMENT: A VISUAL APPROACH Chapter 8 Creating.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting MySQL – Inserting Data.
® Microsoft Office 2013 Access Creating a Database.
Agenda for Class 9/25/2012 Introduce Microsoft’s SQL Server database management system. Use the lab to discuss how to CREATE, DROP and populate (INSERT)
CN2180 MS SQL Server Kemtis Kunanuraksapong MSIS with Distinction, A+ MCTS, MCDST, MCP.
Creating Tables and Inserting Records -- Not easy to edit! -- check constraints! Create table test1 ( C1 char(5) primary key, C2 Varchar2(15) not null.
1 Database Systems Introduction to Microsoft Access Part 2.
Chapter Thirteen Working with Access Databases and LINQ Programming with Microsoft Visual Basic th Edition.
Constraints cis 407 Types of Constraints & Naming Key Constraints Unique Constraints Check Constraints Default Constraints Misc Rules and Defaults Triggers.
Chapter 9 Constraints. Chapter Objectives  Explain the purpose of constraints in a table  Distinguish among PRIMARY KEY, FOREIGN KEY, UNIQUE, CHECK,
Oracle 11g: SQL Chapter 4 Constraints.
Chapter 4 Constraints Oracle 10g: SQL. Oracle 10g: SQL 2 Objectives Explain the purpose of constraints in a table Distinguish among PRIMARY KEY, FOREIGN.
Visual Programing SQL Overview Section 1.
Agenda for Class 2/02/2006 Finish discussing constraints generated with the CREATE TABLE statement. Discuss DROP statement. Discuss INSERT, COMMIT, DELETE,
INTRODUCTION TO ACCESS. OBJECTIVES  Define the terms field, record, table, relational database, primary key, and foreign key  Create a blank database.
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.
Agenda for Class 2/20/2014 Introduce Microsoft’s SQL Server database management system. Use the lab to discuss how to CREATE, DROP and populate (INSERT)
Learningcomputer.com SQL Server 2008 –Views, Functions and Stored Procedures.
Managing Database With Oracle Replacement for Ch10 COP 4708.
Starting with Oracle SQL Plus. Today in the lab… Connect to SQL Plus – your schema. Set up two tables. Find the tables in the catalog. Insert four rows.
Ch 7. Working with relational data. Transactions Group of statements executed as a group. If all statements execute successfully, changes are committed.
Integrating Crystal Reports with SIGNZ (V3.59, July 2008) Integrating Crystal Reports with SIGNZ (V3.59, July 2008)
1 Working with MS SQL Server Beginning ASP.NET in C# and VB Chapter 12.
Creating E/R Diagrams with SQL Server Management Studio, Writing SQL Queries D0ncho Minkov Telerik School Academy schoolacademy.telerik.com Technical Trainer.
CS320 Web and Internet Programming SQL and MySQL Chengyu Sun California State University, Los Angeles.
Education And Training CTC IT DIVISION PivotLink User Training April 2010.
Copyright © 2014 Pearson Canada Inc. Ext. 5b-1 Copyright © 2014 Pearson Canada Inc. Application Extension 5b Using Microsoft Access Part 2: Using Information.
Agenda for Today  DATABASE Definition What is DBMS? Types Of Database Most Popular Primary Database  SQL Definition What is SQL Server? Versions Of SQL.
Tutorial 1 Creating a Database
CS 3630 Database Design and Implementation
Presented by: Teererai Marange
CS320 Web and Internet Programming SQL and MySQL
Database application MySQL Database and PhpMyAdmin
Using SQL Server through Command Prompt
Module 5: Implementing Data Integrity by Using Constraints
CS3220 Web and Internet Programming SQL and MySQL
Grauer and Barber Series Microsoft Access Chapter One
CS3220 Web and Internet Programming SQL and MySQL
Presentation transcript:

Agenda for Class 2/16/2012 Introduce Microsoft’s SQL Server database management system. Use the lab to discuss how to CREATE, DROP and populate (INSERT) tables. Introduce SELECT statement. Discuss connection between MS Access and SQL Server.

Accessing SQL Server Login to COBA server (use your netID). Accessing from COB labs: –Execute Microsoft SQL Server Management Studio. Accessing from home: –Execute Remote Desktop Connection. –Login to server called sts.coba.unr.edu Use your netID as the User name and password. Log on to: BSQL\Students –Execute Microsoft SQL Server Management Studio.

SQL Server Management Studio Object Explorer New Query File Tabs Difference between database object and SQL code Accessing files from the classdata area Saving SQL code to/from a separate file

Class Exercise Database Referential integrity: Table constraint. When inserting data in the child table, checks to see whether a related row exists in the parent table.

Let’s create a small table Click on the “new query” button. Type the following: CREATE TABLE tblemployee (employeeIDchar(5)primary key, LastNamevarchar(30), BillingRatemoney); Click on the “Execute” button.

Deleting a table Cannot have more than one data object with the same name. Must delete data objects before re-creating them. SQL Statement is: DROP TABLE tblemployee; Let’s try and drop the table named tblemployee. Must delete objects in the order of referential integrity constraints.

Create a named constraint Constraints can be “named” in SQL for easier future reference. CREATE TABLE tblemployee (employeeIDchar(4), LastNamevarchar(30), BillingRatemoney, Constraint pkemployee Primary key (employeeID));

SQL INSERT Statement Used to “populate” a table with data. Used to enter one row of data. Character/string data must be entered surrounded by single quotes. Dates can be entered using a variety of formats: –16-feb-2012 –02/16/2012 –

Let’s put data into that table Click on the “new query” button. Type the following SQL Commands (or copy from the PowerPoint). Each command will produce one row in the table called “tblemployee”. INSERT INTO tblemployee VALUES (‘7819', ‘Martinson’, 125); INSERT INTO tblemployee VALUES (‘2745', ‘Johnson’, 85.50); INSERT INTO tblemployee VALUES (‘0062', Belwin, 54.75); INSERT INTO tblemployee VALUES (0062, ‘Smith’, 200);

Let’s look at the data Click on the “new query” button. Type the following SQL command: SELECT * FROMtblemployee;

CREATE TABLE tblContract (ContractIDchar(6), DateSigneddatetime, DateDuedatetime, CONSTRAINT pkcontract PRIMARY KEY (ContractID)); CREATE TABLE tblTime (EmployeeIDchar(4), DateTimeStarteddatetime, ContractIDchar(6), Amountint, CONSTRAINT pkTime PRIMARY KEY (employeeID, datetimestarted), CONSTRAINT fktoContract FOREIGN KEY(contractid) REFERENCEStblContract(contractID), CONSTRAINT fktoemployee FOREIGN KEY(employeeID) REFERENCEStblemployee(employeeID));

Enter data Populate the two tables with INSERT statements. This means completing task #3 on the exercise

Sample Tables with Concatenated Foreign Key

CREATE TABLE tblOrd (order_id CHAR(5) PRIMARY KEY, cust_id CHAR(3), ord_date DATETIME); CREATE TABLE tblProduct (prod_idINT, manufacturer_id CHAR(6), location_idINT, costMONEY, PRIMARY KEY (prod_id, manufacturer_id, location_id));

CREATE TABLE tblOrderLine (order_idCHAR(5), prod_idINT, ship_dateDATETIME, manufacturer_idCHAR(6), location_idINT, qtyDECIMAL(8,2), priceMONEY, PRIMARY KEY (order_id,prod_id,ship_date), CONSTRAINT product_fk FOREIGN KEY (prod_id,manufacturer_id,location_id) REFERENCES tblProduct(prod_id,manufacturer_id,location_id), CONSTRAINT order_fk FOREIGN KEY (order_id) REFERENCES tblOrd(order_id));

Creating tables with other constraints CREATE TABLE tblExample (field1 INT PRIMARY KEY, field2 CHAR(2) CHECK (code_field in(‘02’,’A1’,’B3’,’04’)), field3 MONEY CHECK (cost >.02), field4char(5) NOT NULL, field5decimal(6,4) default 1 );

SQL Server Connections Not a “front end” package; not designed for end- users. Can be connected as a backend database to a variety of different packages. Access is the most convenient for our environment. Pull out printed handout on connection to MS Access.

Examples of Retrieving Data from a Table SELECT* FROM tblemployee; SELECT * FROM tblcontract SELECT contractID, datedue FROM tblcontract; SELECT employeeID, lastname FROM tblemployee WHERE employeeID = ‘0062’; The * means retrieve all columns. The FROM statement, without a WHERE statement, means retrieve all rows.

Copy the results into Word Select all the columns and rows from tblemployee. Copy and paste the results from SQL Server into Word See how ugly? Could do a screen capture to improve the look.

Using MS Access as our “front end” Open a file on the “k” drive called: IS475\s12\StoredProcedureTemplate. CREATE PROCEDURE --Stored Proc Name Here AS --Put your code here GO

Using an MS Access Project for Output Refer to the “Connecting SQL Server 2008 to MS Access 2010” link on the course web site. Follow the instructions to create a query that can be retrieved from MS Access. Look at the output in MS Access. Copy and paste output from MS Access to Word.

Sharing tables with your team Discuss database owners. Discuss database name in object browser. Discuss permissions. Best practice: Create and populate the tables in each group member’s database. The data for HW#5-7 is relatively static, so it will lessen the complexity of the assignments if everyone has direct access to the tables.