Presentation is loading. Please wait.

Presentation is loading. Please wait.

STRUCTURED QUERY LANGUAGE SQL Fact of the Week: According to the 2010 outlook from the BLS 286,600 new Computer, Network, and Database administrator jobs.

Similar presentations


Presentation on theme: "STRUCTURED QUERY LANGUAGE SQL Fact of the Week: According to the 2010 outlook from the BLS 286,600 new Computer, Network, and Database administrator jobs."— Presentation transcript:

1 STRUCTURED QUERY LANGUAGE SQL Fact of the Week: According to the 2010 outlook from the BLS 286,600 new Computer, Network, and Database administrator jobs will be added in the next decade.

2 Learning Objectives  Describe and use basic SQL commands  Explain how and why SQL is used, and why its important  Compare and contrast DML and DDL  Use SQL commands to create metadata structures and perform CRUD operations.

3 Brief History of SQL  1970– E. Codd develops relational database concept  1974-1979–System R with Sequel (later SQL) created at IBM Research Lab  1979–Oracle markets first relational DB with SQL  1986–ANSI SQL standard released  1989, 1992, 1999, 2003, 2007–Major ANSI standard updates  Current–SQL is supported by most major database vendors at 1999, 2003 and 2007 http://www.jcc.com/sql.htm

4 The purpose of the SQL standard SQL Syntax and Semantics Intrinsic Data Structures Portability Levels: Minimal (L1) Complete (L2) Allow for Growth / Enhancement

5 Benefits of the SQL standard  Reduced training costs  Productivity  Application portability  Application longevity  Reduced dependence on a single vendor  Cross-system communication Yes. The standard helps, but each of these benefits is not as realized as other standards, such as HTML

6 The SQL Environment Server Instance Catalog (db) Schema Objects In this class we use: SQL Server ist-s-students,1533 With the default instance Each student has their own catalog (db) Default schema (dbo)

7 SQL Server 2005: ist-s-students  Other Information:  SQL Dialect: T-SQL / Transact-SQL  Case Sensitive Collation?: Yes  System tables used to represent meta data.  Client / Server over TCP/IP Connect to database using: host/IP, port number, logon, password Client software used to manage data/meta data on server  Everything can be expressed in SQL!  Naming Rules for Objects in SQL Server:  Up to 128 characters long  Must begin with a letter  Can contain digits, letters, _,.  Spaces can be used but should be avoided.

8 My Naming Conventions WhatMike’s ConventionRationale for use All object namesUse all lower case letters.Disambiguation: eg. Employee vs. employee for example All object namesUse underscore in place of SPACE Avoid the need to place brackets around identifiers. employee_phone_number vs. [employee phone number] TablesPluralizeShould be employees table, since it contains more than one employee TablesQualify with logical schemaDisambiguation of objects within the same database: eg. fudgemart_employees vs. fudgeflix_employees Column namesQuality with table nameHelps define scope of object. Eg. employee_zipcode.vs vendor_zipcode Constraintspk= primary key fk=foreign key u=unique ck=check i=index Disambiguation of constraints, for example: ck_vendor_zipcode.vs. fk_vendor_zipcode

9 SQL: Language Breakdown DomainSQL CommandsObjects Metadata (DDL) CREATE ALTER DROP Tables, functions, views, procedures, etc DATA (DML) C - INSERT R - SELECT U - UPDATE D - DELETE Tables (as a target) Security (DCL) GRANT REVOKE Tables, functions, views, procedures, etc. Transactions (DTL) BEGIN TRANS COMMIT ROLLBACK Controls DML statements

10 Workflow in SQL Mgmt Studio 1. Type in SQL 2. Highlight it 3. Check it (For syntax errors) 4. Wreck it (Execute on Server) 5. Once you execute “the program has run and the damage is done.” There is no undo, only redo, meaning if you delete something to get it back you must start over again.

11 Examples  Create students table  First name, Last name, netid, Year, GPA  Inserting data  Constraints unique, check  Updating Data  Foreign key lookup table  Using the select statement

12 STRUCTURED QUERY LANGUAGE SQL Basics On to the Demos…


Download ppt "STRUCTURED QUERY LANGUAGE SQL Fact of the Week: According to the 2010 outlook from the BLS 286,600 new Computer, Network, and Database administrator jobs."

Similar presentations


Ads by Google