Presentation on theme: "Section 2MS SQL Overview1 HSQ - DATABASES & SQL And Franchise Colleges 2 MS SQL Server Overview By MANSHA NAWAZ."— Presentation transcript:
Section 2MS SQL Overview1 HSQ - DATABASES & SQL And Franchise Colleges 2 MS SQL Server Overview By MANSHA NAWAZ
Section 2MS SQL Overview2 OVERVIEW Client Server Architecture What is SQL? MS SQL Server V MS Access Creating an SQL Server Database Enterprise Manager Example SQL Enterprise Manager Resources Query Analyzer Example SQL in Query Analyzer SQL Query Analyser Resources Additional SQL Resources
Section 2MS SQL Overview3 Client/Server Architecture User Workstation Operator Workstation Department File-Servers Corporate Servers Server provides services for the Clients which are responsible for interacting with the users (Input/Output) Server is responsible for performing a service (e.g. transaction) and guaranteeing the integrity of the data Well suited for distributed systems handling large amounts of data
Section 2MS SQL Overview4 E-R Model NF Systems Analysis & Design DFD DataStores, DataFlows and Data Dictionary Database Management System (DBMS) PHYSICAL VIEW OF DATA TABLES (computer view)) LOGICAL VIEW OF DATA FORMS (user view) DATA MODEL TABLE SET WEB DEVELOPMENT Database connectivity via websites www.net technology Macromedia Dreamweaver MS Visual Studio CLIENT DB Development Database connectivity via desktop DBMS such as MS Access Program Development Database connectivity via programming languages such as MS Visual Basic Server Area of Interest Database Development Client Area of Interest
Section 2MS SQL Overview5 What is SQL? Structured Query Language It is the standard language for managing a database Creating, Accessing Searching Modifying Many different Systems depending on maker of software: Oracle Microsoft SQL Server MS Access Sybase etc. Initially we will examine SQL under MS Access –non-standard SQL In the main we use MS SQL Server 2000 –standard SQL Some Variations in symbols ACCESS SQL “ ‘ #%
Section 2MS SQL Overview6 MS SQL Server is a server based database. Multi User – Multi Platform Systems Large, high volume traffic database systems Server holds database. Workstation provides access. For web or database systems if the access traffic is likely to generate more than 20 concurrent database hits at a time, it's time to move to a database server Generally, database servers like MS SQL Server are the way to go for database or web/database systems Many and wide ranging user base for system Additional Security and Login features MySQL (free sql database used for connectivity to Websites via PHP). MS SQL Server V MS Access MS Access is Desktop based Small, low-traffic database systems Small, low-traffic web sites requiring database connectivity. Cannot handle heavy traffic from multiple users.
Section 2MS SQL Overview7 MS SQL SERVER 2005 MS SQL SERVER 2005 – STUDENT EDITION from MSDNAA MS SQL SERVER 2008 ** new MS SQL SERVER 2008 STUDENT EDITION from MSDNAA installation guide – similar to 2005 edition All lecture notes are in version 2005 The 2008 interface is similar if not the same. MS SQL SERVER 2005 – STUDENT EDITION from MSDNAA MS SQL SERVER 2008 STUDENT EDITION from MSDNAA
Section 2MS SQL Overview8 MSDN – MS SQL Server 2005 Online Videos http://msdn2.microsoft.com/en-us/express/aa718391.aspx http://msdn2.microsoft.com/en-us/express/aa718391.aspx Learning Resources - Video Series: SQL Server 2005 Express Edition for Beginners Getting Started with SQL Server Express This video series is designed specifically for SQL Server beginners—individuals who are interested in learning the basics of how to create, manage, and connect to SQL Server Express databases. Whether you’re just a beginner or somewhat familiar with databases, these video lessons will help you get better acquainted with SQL Server 2005 Express. The series includes almost 9 hours of video-based instruction that walks SQL Server beginners through the steps of learning about SQL Server databases to actually connecting a SQL Server database to a Web application. Select your starting point below based on your skill set. –Introduction Learning Video 1: What is a database? –Designing Tables Learning Video 2: Understanding Database Tables and Records Learning Video 3: More about Column Data Types and Other Properties Learning Video 4: Designing Relational Database Tables –Database Functions Learning Video 5: Manipulating Database Data Learning Video 6: More Structured Query Language Learning Video 12: Creating and Using Stored Procedures Learning Video 13: Enabling Full-Text Search in your Text Data –Creating and Using Reports Learning Video 10: Getting Started with Reporting Services Learning Video 11: Embedding, Packaging and Deploying SQL Server Express Reporting Services –Database Security Learning Video 7: Understanding Security and Network Connectivity –Database Management Learning Video 9: Using SQL Server Management Studio Express –Publishing to the Web Learning Video 8: Connecting your Web Application to SQL Server 2005 Express Edition
Section 2MS SQL Overview9 MS SQL Server 2005 Management Studio Express (MSE) MSE is the development environments for server based databases. Traditionally installed on servers only. Administrators and Developers access via MS SQL client tools installed on workstation. Users access via workstation either by MS SQL client tools or other software packages such as MS Access, MS VBasic, Macromedia Dreamweaver, etc Develop DB via Graphical UI Draw ER model in design view Create tables in design view Drag and drop relationships links Automatically creates tables from ER Model Easy to navigate existing DBs Develop DB via Scripting UI Write SQL code to reflect ER model SQL code held in a Script File Script Files of SQL code in notepad or word Use SQL code to create tables & relationships More powerful, less intuitive
Section 2MS SQL Overview10 Management Studio Graphical User Interface Click Databases Note additional server option
Section 2MS SQL Overview11 Note SUMMARY tag. Available from VIEW menu. Expand databases by clicking +
Section 2MS SQL Overview12 Management Studio Graphical User Interface (GUI) - develop and draw ER model to implement database Library ERD Use the GUI to develop your ER model. Add, Delete and Modify Tables, Fields and Relationships (links). SQL Script Code automatically generated. Also develop Views, Queries Reports etc
Section 2MS SQL Overview13 Management Studio Scripting User Interface SUI - develop and write SQL Code to implement database The most popular, and now standard, language for manipulating tables in a relational database is SQL. SQL, often known as a query language, is a combined DDL, DML and DCL used with relational databases. Data Definition Language (DDL) –is used to specify the data in a database. –The DDL statements define database objects, eg databases, tables, views, indexes, users, constraints, user-defined data types: CREATE, DROP, ALTER Data Manipulation Language (DML) –is used to access the data in a database. –The DML statements manipulate data: SELECT, INSERT, DELETE, UPDATE Data Control Language (DCL) –is used to control access to the data in a database. –The DCL statements control access to data: GRANT, DENY, REVOKE
Section 2MS SQL Overview14 SQL Query Code Example USE MASTER GO -- If the database already exists, drop it IF EXISTS(SELECT * FROM sysdatabases WHERE name='Restaurants') DROP DATABASE Restaurants GO -- Create the Restaurants database CREATE DATABASE Restaurants GO USE Restaurants GO -- Create the Widgets table in Restaurants CREATE TABLE RestaurantTable ( RestaurantId INT NOT NULL PRIMARY KEY IDENTITY(1,1), RestaurantName VARCHAR(50) NOT NULL, Rating SMALLINT DEFAULT 3, AvgMealPrice MONEY NOT NULL, ReservationReqd BIT NOT NULL DEFAULT 0 ) GO
Section 2MS SQL Overview15 SQL Server Object Names Standard Identifiers –Can contain from one to 128 characters, including letters, symbols (_ @ or #) and numbers. –No embedded spaces are allowed. –The first character must be alphabetic. –A name beginning with @ denotes a local variable or parameter. –A name beginning with # denotes a temporary table or procedure. –A name beginning with ## denotes a global temporary object. –NB: Names for temporary objects shouldn’t exceed 116 characters including # or ## as SQL Server gives them an internal numeric suffix. Delimited Identifiers –Do not comply with the rules for standard identifiers and must, therefore, always be delimited. –You can use delimited identifiers when: –Names contain embedded spaces. –Reserved words are used for object names or portions of object names. –You must enclose delimited identifiers in square brackets or quotation marks when you use them in Transact-SQL statements, eg: –SELECT * FROM [Blanks In Table Name] –SELECT * FROM “Blanks In Table Name” –NB:You can always use bracketed delimiters but can only use quotation marks if the SET QUOTED_IDENTIFIER option is on.
Section 2MS SQL Overview16 Additional SQL Resources on the SQL Website.
Section 2MS SQL Overview17 FURTHER READING Review the attached set of SQL notes over the next four weeks to reinforce your SQL skills. –Data Models are converted to schemas which are readable by the database management system. –Notation standardised through SQL and XML –Schemas describe data. –Described as tables (relations) for relational databases. –Definition of Columns of tables based on domains (sets of valid values). –Metadata describes data. Schemas form part of the metadata for a system. SQL_Data_DefinitionDomainsMetadataXML SQL Sub QueriesSQL GroupsSQL Data Definition Views Key Relational and SQL Concepts (part 1 of 3) Key Relational and SQL Concepts (part 2 of 3) Key Relational and SQL Concepts (part 3 of 3)