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)

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

1 SQL Server Management Studio SQL DDL CREATE TABLE Constraints ALTER TABLE DROP TABLE The GUI way Steen Jensen, autumn 2013.
Virtual training week 4 structured query language (SQL)
Introduction to Structured Query Language (SQL)
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)
 Review HW #4  Answer questions about Microsoft Visio  Introduce SQL  Introduce SQL Server 2008 environment for programming SQL  Will meet in AB208.
Introduction to Structured Query Language (SQL)
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.
Introduction to Structured Query Language (SQL)
Chapter 7 Managing Data Sources. ASP.NET 2.0, Third Edition2.
Working with SQL and PL/SQL/ Session 1 / 1 of 27 SQL Server Architecture.
DAT702.  Standard Query Language  Ability to access and manipulate databases ◦ Retrieve data ◦ Insert, delete, update records ◦ Create and set permissions.
Prepared by Jennifer Kreie, New Mexico State UniversityHosted by the University of Arkansas Microsoft Enterprise Consortium SQL Fundamentals Introduction.
Your Oracle Account UserName is the same as your UWP username Followed Not case sensitive Initial Password: UWPstudent Password is case sensitive.
Ceng 356-Lab1. Objectives After completing this lesson, you should be able to do the following: Get Familiar with the development environment List the.
DAY 21: MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Akhila Kondai October 30, 2013.
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.
Chapter 4 SQL. SQL server Microsoft SQL Server is a client/server database management system. Microsoft SQL Server is a client/server database management.
Session 5: Working with MySQL iNET Academy Open Source Web Development.
Chapter 9 SQL and RDBMS Part C. SQL Copyright 2005 Radian Publishing Co.
ASP.NET Programming with C# and SQL Server First Edition
 SQL stands for Structured Query Language.  SQL lets you access and manipulate databases.  SQL is an ANSI (American National Standards Institute) standard.
Web Server Administration Chapter 7 Installing and Testing a Programming Environment.
CS 3630 Database Design and Implementation. Your Oracle Account UserName is the same as your UWP username Followed Not case sensitive Initial.
Introduction to SEQUEL. What is SEQUEL? Acronym for Structural English Query Language Acronym for Structural English Query Language Standard language.
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.
NMED 3850 A Advanced Online Design January 12, 2010 V. Mahadevan.
SQL Data Definition Language (DDL) Using Microsoft SQL Server 1SDL Data Definition Language (DDL)
Chapter 5: Part 1: DDL STRUCTURED QUERY LANGUAGE (SQL)
7 1 Chapter 7 Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
Structured Query Language (SQL) IST2101. Structured Query Language – Acronym: SQL – Pronounced as “S-Q-L” [“Ess-Que-El”] – Originally developed by IBM.
Chapter 5 MYSQL Database. Introduction to MYSQL MySQL is the world's most popular open-source database. Open source means that the source code, the programming.
Oracle 11g DATABASE DEVELOPMENT LAB1. Introduction  Oracle 11g Database:-  Oracle 11g database is designed for some features, which helps to the organizations.
Most information comes from Chapter 3, MySQL Tutorial: 1 MySQL: Part.
SQL: DDL. SQL Statements DDL - data definition language –Defining and modifying data structures (metadata): database, tables, views, etc. DML - data manipulation.
6 1 Lecture 8: Introduction to Structured Query Language (SQL) J. S. Chou, P.E., Ph.D.
CN2180 MS SQL Server Kemtis Kunanuraksapong MSIS with Distinction, A+ MCTS, MCDST, MCP.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
Features of SQL SQL is an English-like language . It uses words such as select , insert , delete as part of its commend set. SQL is an a non-procedural.
Oracle 11g: SQL Chapter 4 Constraints.
Database Lab Lecture 1. Database Languages Data definition language ( DDL ) Data definition language –defines data types and the relationships among them.
Copyright  Oracle Corporation, All rights reserved. Introduction.
Chapter 4 Constraints Oracle 10g: SQL. Oracle 10g: SQL 2 Objectives Explain the purpose of constraints in a table Distinguish among PRIMARY KEY, FOREIGN.
Database Fundamental & Design by A.Surasit Samaisut Copyrights : All Rights Reserved.
Agenda for Class 2/02/2006 Finish discussing constraints generated with the CREATE TABLE statement. Discuss DROP statement. Discuss INSERT, COMMIT, DELETE,
SQL.. AN OVERVIEW lecture3 1. Overview of SQL 2  Query: allow questions to be asked of the data and display only the information required. It can include.
ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah.
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)
Relational Database Management System(RDBMS) Structured Query Language(SQL)
Distribution of Marks For Second Semester Internal Sessional Evaluation External Evaluation Assignment /Project QuizzesClass Attendance Mid-Term Test Total.
Introduction to Teradata Client Tools. 2 Introduction to Teradata SQL  OBJECTIVES :  Teradata Product Components.  Accessing Teradata – Database /
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.
SQL Introduction to database and SQL. Chapter 1: Databases and Database Users 6 Introduction to Databases Databases touch all aspects of our lives. Examples:
1 Working with MS SQL Server Beginning ASP.NET in C# and VB Chapter 12.
Installation Oracle 11g Express 2 double click the "setup" button to install the Oracle.
LM 5 Introduction to SQL MISM 4135 Instructor: Dr. Lei Li.
MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Sravanthi Lakkimsety Mar 14,2016.
SQL Basics Review Reviewing what we’ve learned so far…….
1 Section 1 - Introduction to SQL u SQL is an abbreviation for Structured Query Language. u It is generally pronounced “Sequel” u SQL is a unified language.
CS 3630 Database Design and Implementation
ATS Application Programming: Java Programming
ORACLE SQL Developer & SQLPLUS Statements
STRUCTURED QUERY LANGUAGE
The Basics of Data Manipulation
SQL .. An overview lecture3.
Chapter # 7 Introduction to Structured Query Language (SQL) Part I.
Presentation transcript:

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) tables. Introduce SELECT statement. Discuss connection between MS Access and SQL Server.

Accessing SQL Server Login to COB 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. When not in the COB labs, your netID for Windows authentication is UNR\netID. –Execute Microsoft SQL Server Management Studio.

Logging into the class server for SQL Server After executing SQL Server Management Studio, either directly when in the COB labs, or through remote desktop when not in the COB labs, you must login to our class server. –Server name is ISSQL\Students Use Windows authentication for all work on SQL Server.

SQL Server Management Studio Object Explorer New Query editor Options File Tabs Difference between database object and SQL code Accessing files from the k: or u: drives Saving SQL code to/from a separate file

SQL (structured query language) is a non- procedural language designed to process data. Data processing operations include: –Creating tables –Create and enforcing constraints –Adding, changing, deleting data –Accessing data (either through single rows or aggregation) SQL is an ANSI (American National Standards Institute) standard language 5 SQL Background

A front-end programming tool Does not: –Make pretty output (forms/reports) –Make pretty websites –Make anything pretty for users to look at!! –Do extensive calculations –Do statistical calculations 6 SQL is not...

All commands are considered to be “queries” Any command acts upon the database: –creating or altering (changing) database objects, –adding/deleting/changing data inside a database object, –looking at data inside a database object. Operates with an implied loop; no explicit loops. The programmer has no control over the execution of the loop. 7 How does SQL operate?

8 SQL Commands Data Definition Commands (DDL) Data Manipulation Commands (DML) Data Control Commands (DCL) CREATEINSERTGRANT ALTERUPDATEREVOKE DROPDELETECOMMIT TRUNCATEROLLBACK SELECTSET TRANSACTION

SQL statements start with a command, and then include few or many modifiers/extensions for the command. SQL statements are not case sensitive. Can span more than one physical line; it is a free form language. SQL keywords cannot be abbreviated or split across lines. 9 Guidelines for writing SQL

Keywords and/or main clauses are typically placed on separate lines. Tabs and indentation are used to enhance readability. Keywords are typically aligned in the first column. Keywords are usually capitalized. Data are usually in lowercase or a combination of uppercase and lowercase. Comments are included sparingly, but usefully. 10 Much tradition in SQL code

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 (employeeID char(5) primary key, LastName varchar(30), BillingRate money); 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. Keep the current query tab open, and open another “new query” tab. Drop the table. General information: 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 data and dates must be entered surrounded by single quotes. Dates can be entered using a variety of formats: –‘25-sep-2012’ –‘09/25/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”. This is task #3 on the exercise sheet. 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. The SQL statement below is task #4 on the exercise sheet. SELECT * FROMtblemployee;

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

Now create the other two tables in the sample ERD Do tasks #5 and #6 on the exercise sheet.

Sample Tables with Concatenated Foreign Key This is NOT a task on the exercise sheet. This shows how to handle a concatenated foreign key. Will be discussed in class.

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.

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\f12\StoredProcedureTemplate. CREATE PROCEDURE --Stored Proc Name Here AS --Put your code here GO

Using an MS Access Project for Output Refer to the “MSAccess FrontEnd” link on the “handouts” column for 9/25 on the course web site. Follow the instructions to create an empty project shell in MS Access that links to SQL Server. Then 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-8 is relatively static, so it will lessen the complexity of the assignments if everyone has direct access to the tables.