Sql Overview

620 views
593 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
620
On SlideShare
0
From Embeds
0
Number of Embeds
122
Actions
Shares
0
Downloads
23
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • 04/08/10 CIS-182 SQL
  • Sql Overview

    1. 1. SQL Overview CIS-182
    2. 2. Structured Query Language <ul><li>Language used to work with databases </li></ul><ul><li>Used in ‘back end’ </li></ul><ul><ul><li>Typically not part of user interface (don’t expect users to type in a query…) </li></ul></ul>
    3. 3. SEQEL to SQL <ul><li>Structured English Query Language developed by IBM </li></ul><ul><li>Other companies developed similar products </li></ul><ul><li>ANSI set standards in 1986 </li></ul><ul><ul><li>Standards are ‘open’ </li></ul></ul><ul><ul><li>Different vendors have different levels of conformance </li></ul></ul>
    4. 4. SQL <ul><li>Most languages are procedural </li></ul><ul><ul><li>Describe how to perform a task </li></ul></ul><ul><li>SQL is non-procedural (declarative) </li></ul><ul><ul><li>Code describes results </li></ul></ul><ul><ul><li>Includes some procedural components </li></ul></ul><ul><ul><ul><li>If … Then, Loops </li></ul></ul></ul><ul><li>Database apps typically use both types of languages </li></ul><ul><ul><li>Procedural languages manage interface, data requests </li></ul></ul><ul><ul><li>SQL manages data storage and retrieval </li></ul></ul>
    5. 5. Types of SQL Statements <ul><li>Data Definition Language (DDL): Create/edit objects </li></ul><ul><ul><li>CREATE, ALTER </li></ul></ul><ul><li>Data Control Language (DCL): Specify access and permissions </li></ul><ul><ul><li>GRANT, REVOKE </li></ul></ul><ul><li>Data Manipulation Language (DML): Work with data </li></ul><ul><ul><li>SELECT * FROM Employees </li></ul></ul><ul><ul><li>INSERT INTO Students </li></ul></ul>
    6. 6. Logical Organization <ul><li>Catalogs: group of schemas </li></ul><ul><li>Schema: group of related tables, views </li></ul><ul><li>Implementation is up to vendor </li></ul><ul><ul><li>Some vendors use catalogs, some don’t </li></ul></ul><ul><ul><li>Vendors have different levels of support for schemas </li></ul></ul>
    7. 7. Databases <ul><li>‘ Database’ is not an ANSI specification </li></ul><ul><li>Most vendors have a database object </li></ul><ul><li>In practice, schema and database tend to be viewed interchangeably </li></ul><ul><ul><li>Schema defines the contents of a database </li></ul></ul><ul><ul><li>May have sub-schemas to reflect application needs (include only a portion of the database) </li></ul></ul>
    8. 8. Coding <ul><li>One command may extend across several lines </li></ul><ul><ul><li>[Enter] doesn’t represent the end of a statement </li></ul></ul><ul><ul><li>SQL uses ; (semi-colon) to identify statement end </li></ul></ul><ul><ul><ul><li>; is optional in SQL Server </li></ul></ul></ul><ul><li>Keywords are capitalized </li></ul><ul><ul><li>CREATE DATABASE MyNewDatabase </li></ul></ul><ul><li>No standard conventions for naming </li></ul><ul><ul><li>Typically use Pascal case naming with each new word capitalized </li></ul></ul>
    9. 9. Naming Requirements <ul><li>Object names are not typically case sensitive </li></ul><ul><ul><li>Delimited identifiers wrap names in double quotes and ARE case sensitive </li></ul></ul><ul><ul><li>“ MyNewTable” uses double quotes to identify the object name </li></ul></ul><ul><ul><li>Single quotes identify strings (text) </li></ul></ul><ul><li>Can use letters, numbers, underscore </li></ul><ul><ul><li>Can’t use spaces, punctuation </li></ul></ul>
    10. 10. Qualified Names <ul><li>A qualified name defines explicitly how to find an object </li></ul><ul><ul><li>‘ .’ is used as separator </li></ul></ul><ul><li>SQL Server uses ServerName.DatabaseName.OwnerName.ObjectName </li></ul><ul><li>OR </li></ul><ul><li>ServerName.DatabaseName.SchemaName.ObjectName </li></ul>
    11. 11. Coding Reference <ul><li>SQL Server uses special characters to identify different parts of commands </li></ul><ul><li>End of statement: ; </li></ul><ul><ul><li>Optional in SQL Server </li></ul></ul><ul><li>Placeholder: <> </li></ul><ul><li>Placeholder Definition: ::= </li></ul><ul><li>Optional Parameter(s): [ ] </li></ul><ul><li>Specific Parameter Values: { } </li></ul><ul><li>Value Separator: | </li></ul><ul><li>List Separator: , </li></ul>
    12. 12. Placeholder Example <ul><li>Basic command definition: </li></ul><ul><ul><li>ON UPDATE <referential action> </li></ul></ul><ul><ul><li><referential action> ::= CASCADE|SET NULL </li></ul></ul><ul><li><referential action> is placeholder </li></ul><ul><li>CASCADE|SET NULL is placeholder definition (placeholder value must be one of these choices) </li></ul>
    13. 13. Management Studio <ul><li>Microsoft GUI for most SQL Server operations </li></ul><ul><ul><li>Additional applications manage overall server security, business intelligence </li></ul></ul><ul><li>Separate application from SQL Server </li></ul><ul><ul><li>Uses a connection to send commands and capture results </li></ul></ul><ul><ul><li>SQL Server is not something we’ll work with directly </li></ul></ul>

    ×