Top Banner
Information Technologies and Microsoft SQL Server Day 1 by Alper Özpınar [email protected]
53

Information Technologies and Microsoft SQL Server Day 1 by Alper Özpınar [email protected].

Dec 27, 2015

Download

Documents

Marian Haynes
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Information Technologies and Microsoft SQL Server Day 1 by Alper Özpınar ozpinar@zetabt.com.

Information Technologies and Microsoft SQL Server

Day 1

by Alper Özpı[email protected]

Page 2: Information Technologies and Microsoft SQL Server Day 1 by Alper Özpınar ozpinar@zetabt.com.

Course Overview Introduction to Information Technologies

Historical background Data and information Data collecting and storing Data processing

SQL Server SQL Server Technical Details Creating a database Security and users Table’s and data types SQL Language SQL Functions Stored Procedures

Applications

Page 3: Information Technologies and Microsoft SQL Server Day 1 by Alper Özpınar ozpinar@zetabt.com.

Structure of World Economy

High Imperialism 1880 - 1914

World War I 1914 - 1918/23

The World between the Wars

1918/23 - 1939

World War II 1939 - 1945

Post World War II 1945 - 1949

Industrialization War Economy Political Issues War Economy Political Issues

     Demand >>>

SupplyDemand >> Supply

The Early Cold War 1949 - 1969

The Late Cold War 1969 - 1990

New World 1990 -2000

Now

Technology RaceNew Business

StructureGlobalization  

Demand >> Supply Demand = Supply Demand < SupplyDemand <<<

Supply

Page 4: Information Technologies and Microsoft SQL Server Day 1 by Alper Özpınar ozpinar@zetabt.com.

Computers and Humanbeings

"I think there is a world market for maybe five computers."

Thomas Watson (1874-1956), Chairman of IBM, 1943

Page 5: Information Technologies and Microsoft SQL Server Day 1 by Alper Özpınar ozpinar@zetabt.com.

Computers and Humanbeings

"There is no reason anyone would want a computer in their home." Ken Olson, president, chairman and

founder of Digital Equipment Corp., 1977

Page 6: Information Technologies and Microsoft SQL Server Day 1 by Alper Özpınar ozpinar@zetabt.com.

Structure of old economy

The capital rise and grow Most of the producers have a local or national market

competition, not more than a competition with neighboring countries

Competition based on costing and quality Product improvements still continues while the

product on the market Products have a long market life Product development includes continues actions

Page 7: Information Technologies and Microsoft SQL Server Day 1 by Alper Özpınar ozpinar@zetabt.com.

Structure of new economy

The information rise and grow Competition

Competition in world markets Management and control in a global marketplace Global work groups & delivery systems

Products & Services Complex and variable Short market life Product & Service development processes are

mostly parallel and multidisciplinary

Page 8: Information Technologies and Microsoft SQL Server Day 1 by Alper Özpınar ozpinar@zetabt.com.

Structure of new economy

Weapons of the competitive market Perfection in product & service design Creativity and Innovation Flexible to the customer demands High quality New product development and entering the market

timing Limited employee knowledge base Leadership

Page 9: Information Technologies and Microsoft SQL Server Day 1 by Alper Özpınar ozpinar@zetabt.com.

Structure of new economy

Production & Services Ready to work with uncertainty and fuzzy situations Flexible network production Distributed & Outsourced All disciplines and departments works parallel in

production Low capacity high flexibility Cheaper Faster Durable Reliable

Page 10: Information Technologies and Microsoft SQL Server Day 1 by Alper Özpınar ozpinar@zetabt.com.

Structure of new economy

Transformation of the Enterprise Flattening Decentralization Flexibility Location Independence Low transaction and coordination costs Empowerment Collaborativework and teamwork

Page 11: Information Technologies and Microsoft SQL Server Day 1 by Alper Özpınar ozpinar@zetabt.com.

Structure of new economy

New way of operating the business SCM (Supply Chain Management ) MRP ( Management Resources Planning) MIS ( Management Information Systems ) ERP (Enterprise Resource Planning ) CRM (Customer Relationship Management ) ...

Page 12: Information Technologies and Microsoft SQL Server Day 1 by Alper Özpınar ozpinar@zetabt.com.

Functions of Information Systems

Environment

Organization

Input OutputProcessing

Feedback

Customers Suppliers

CompetitorsRegulatory Agencies

Stockholders

Page 13: Information Technologies and Microsoft SQL Server Day 1 by Alper Özpınar ozpinar@zetabt.com.

Information Systems

Management

Technology

Organizations

InformationSystems

Page 14: Information Technologies and Microsoft SQL Server Day 1 by Alper Özpınar ozpinar@zetabt.com.

Key Systems in Organization

Because there are different interests, specialities, and levels in an organization, there are different types of systems in an organization these are;

1. Operational-level Systems

2. Knowledge-level Systems

3. Management-level Systems

4. Strategic-level Systems

Page 15: Information Technologies and Microsoft SQL Server Day 1 by Alper Özpınar ozpinar@zetabt.com.

Time Sequence

mid-1950s Transaction Processing Systems (TPS) 1960s MIS 1970s Office Automation Systems

DSS 1980s DSS Expanded

Commercial applications of expert systems Executive Information Systems

1990s Group Support Systems Neural Computing Integrated, hybrid computer systems

Page 16: Information Technologies and Microsoft SQL Server Day 1 by Alper Özpınar ozpinar@zetabt.com.

TYPES OF INFORMATION SYSTEMSTYPES OF INFORMATION SYSTEMS

DATA WORKERSDATA WORKERS

KIND OF SYSTEM GROUPS SERVEDKIND OF SYSTEM GROUPS SERVED

STRATEGIC LEVEL SENIOR STRATEGIC LEVEL SENIOR MANAGERSMANAGERS

MANAGEMENT LEVEL MIDDLE MANAGEMENT LEVEL MIDDLE MANAGERSMANAGERS

OPERATIONAL OPERATIONAL

OPERATIONAL LEVEL OPERATIONAL LEVEL MANAGERS MANAGERS

KNOWLEDGE LEVEL KNOWLEDGE & KNOWLEDGE LEVEL KNOWLEDGE &

SALES & MANUFACTURING FINANCE ACCOUNTING HUMAN RESOURCESMARKETING

Page 17: Information Technologies and Microsoft SQL Server Day 1 by Alper Özpınar ozpinar@zetabt.com.

Operational-level Systems

Support operational managers by keeping track of the elementary activities and transactions of the organisation. The principle purpose of systems at this level is to answer routine questions and track the flow of transactions through the organisation. Covers things such as sales, receipts, cash deposits, payroll, credit decisions, flow of materials.

Page 18: Information Technologies and Microsoft SQL Server Day 1 by Alper Özpınar ozpinar@zetabt.com.

Knowledge-level Systems

Support knowledge and data workers in an organisation. The purpose of these systems is to help the organisation discover, organise and integrate new and existing knowledge in to the business, and to help control the flow of paperwork. These systems, specially in the form of collaboration tools, workstations, and office systems, are the fastest growing applications in business today.

Page 19: Information Technologies and Microsoft SQL Server Day 1 by Alper Özpınar ozpinar@zetabt.com.

Management-level Systems

Designed to serve the the monitoring, controlling, decision-making, and administrative activities of middle managers. These typically provide periodic reports rather than instant information on operations. Some of these systems support non-routine decision-making, focusing on less-structured decisions for which information requirements are not always clear. This will often require information from outwith the organisation, as well as from normal operational-level data.

Page 20: Information Technologies and Microsoft SQL Server Day 1 by Alper Özpınar ozpinar@zetabt.com.

Strategic-level Systems

Help senior management tackle and address strategic issues and long-term trends, both within the organisation and in the external environment. Principal concern is matching organisational capability to changes, and opportunities, occurring in the medium to long term (i.e. 5 - 10 years) in the external environment.

Page 21: Information Technologies and Microsoft SQL Server Day 1 by Alper Özpınar ozpinar@zetabt.com.

Systems

Typically, an organisation might have operational, knowledge, management and strategic level systems for each functional area within the organisation.

This would be based on the management model adopted by the organisation, so, while the most commonly-adopted systems structure would simply follow the standard functional model, structures reflecting bureaucratic, product and matrix models are also possible.

Page 22: Information Technologies and Microsoft SQL Server Day 1 by Alper Özpınar ozpinar@zetabt.com.
Page 23: Information Technologies and Microsoft SQL Server Day 1 by Alper Özpınar ozpinar@zetabt.com.
Page 24: Information Technologies and Microsoft SQL Server Day 1 by Alper Özpınar ozpinar@zetabt.com.

MISMIS

MIS FILESMIS FILES

SALES DATA

UNIT PRODUCT COST

PRODUCT CHANGE DATA

EXPENSE DATA

MISREPORTS

MANAGERSMANAGERS

TPS

Order Processing

System

Materials Resource

Planning System

General Ledger

System

ORDER FILE

PRODUCTION MASTER FILE

ACCOUNTING FILES

TPS DATA FOR MIS APPLICATIONS

Page 25: Information Technologies and Microsoft SQL Server Day 1 by Alper Özpınar ozpinar@zetabt.com.

Decision Support Systems

Repetitive Linear Logic Regular Reports No support of decisions

TPS ESS/EIS

DSS ES

Specialised heuristics System makes decision itself No regular reports

MISOAS KWS

Page 26: Information Technologies and Microsoft SQL Server Day 1 by Alper Özpınar ozpinar@zetabt.com.

Decision-Support Systems (DSS)

Decision Maker

DSS User

Interface

MMS

Management Support Systems

MBMS

Model Base Management

Services

DBMS

Database Management

Systems

Mail, News,

Discussion

Groups

Models and Aids

Corporate

Databases

Components of a DSS

Page 27: Information Technologies and Microsoft SQL Server Day 1 by Alper Özpınar ozpinar@zetabt.com.

ESS

TPSKWS

OAS

DSSMIS

Relations

Page 28: Information Technologies and Microsoft SQL Server Day 1 by Alper Özpınar ozpinar@zetabt.com.

"There are two ways of constructing a software design; one way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult." - C. A. R. Hoare

Page 29: Information Technologies and Microsoft SQL Server Day 1 by Alper Özpınar ozpinar@zetabt.com.
Page 30: Information Technologies and Microsoft SQL Server Day 1 by Alper Özpınar ozpinar@zetabt.com.

What is a Database?

The term database has fallen into loose use lately, losing much of its original meaning. To some people, a database is any collection of data items (phone books, laundry lists, parchment scrolls . . . whatever).

A record is a representation of some physical or conceptual object. Say, for example, that you want to keep track of a business’s customers. You assign a record for each customer. Each record has multiple attributes, such as name,address, and telephone number. Individual names, addresses, and so on are the data.

Page 31: Information Technologies and Microsoft SQL Server Day 1 by Alper Özpınar ozpinar@zetabt.com.

What Is a Database ManagementSystem? A database management system (DBMS) is a set of

programs used to define, administer, and process databases and their associated applications.The database being “managed” is, in essence, a structure that you build to hold valuable data.

A DBMS is the tool you use to build that structure and operate on the data contained within the database.

Many DBMS programs are on the market today. Some run only on mainframe computers, some only on minicomputers, and some only on personal computers.

Page 32: Information Technologies and Microsoft SQL Server Day 1 by Alper Özpınar ozpinar@zetabt.com.

What is SQL Server 2000?

SQL Server is a client/server based relational database management system

Runs on Windows 2000 Professional, Server, Advanced Server, NT 4, Windows 9x/ME or Windows CE

Included in BackOffice product family Include in .Net Servers family

Page 33: Information Technologies and Microsoft SQL Server Day 1 by Alper Özpınar ozpinar@zetabt.com.

Client/Server

Server Side Database Engine Security Fault-tolerance Performance Concurrency Reliable backup

Client Side User Interface Forms Reports Queries

Page 34: Information Technologies and Microsoft SQL Server Day 1 by Alper Özpınar ozpinar@zetabt.com.

Desktop Databases

ServerWorkstation

1

2

3

4

5

User Runsthe Query

Requestsdatabase

from Server

Entire Databaseis copied to the

workstation

Results arepresented to the

user

Query isrun

Database

Page 35: Information Technologies and Microsoft SQL Server Day 1 by Alper Özpınar ozpinar@zetabt.com.

Client/Server Database

ServerWorkstation

1

2

43

5

User Runsthe Query

Query issent to the

server

Results are sentback to theWorkstation

Results arepresented to the

user

Query isrun on the

server

Database

Page 36: Information Technologies and Microsoft SQL Server Day 1 by Alper Özpınar ozpinar@zetabt.com.

Types of Databases

Relational Flat-File Hierarchical Relational Vs. Flat-file

Page 37: Information Technologies and Microsoft SQL Server Day 1 by Alper Özpınar ozpinar@zetabt.com.

Database Objects

• Table• Row• Column• Data Type• Stored

Procedure• Trigger• Rule• Default• View• Index

ROW

COLUMN

TABLE

CA

COLUMN

DEFAULT

ALL CAPS

RULE

VIEW

CalculateSalary

STOREDPROCEDURE

Page 38: Information Technologies and Microsoft SQL Server Day 1 by Alper Özpınar ozpinar@zetabt.com.

Data-Warehousing Vs. Transaction ProcessingData-Warehousing Decision Support

Systems (DSS) Online Analytical

Processing (OLAP) Relatively fixed data Long running queries

Online Transaction Processing (OLTP)

Continuously changing data

Updates relatively small transactions

SQL Server works well with either applications

Page 39: Information Technologies and Microsoft SQL Server Day 1 by Alper Özpınar ozpinar@zetabt.com.

Background on SQL Server & SQL

History Position in the Market History of SQL – IBM 1970 SQL and SEQUEL ANSI-SQL, T-SQL / PL-SQL SQL Language DDL Data Definition Language DML Data Manipulation LanguageBrief History of Windows and Versions of Windows 2000

Page 40: Information Technologies and Microsoft SQL Server Day 1 by Alper Özpınar ozpinar@zetabt.com.

SQL Server Product Roadmap

SQL Server 7.0

SQL Server “Yukon”

SQL Server 2000

• Lowest TCOLowest TCO• Ease-of-UseEase-of-Use

• Performance and ScalabilityPerformance and Scalability• Integrated Business IntelligenceIntegrated Business Intelligence

• Enterprise-class scalability

• Programmability advancements

• End-to-end business intelligence

• Manageability• Support for multiple types

of data

• Reliability and scalability advancements

• Deep XML support• Data warehousing• SQL Server CE• 64 bit support

• Re-architecture of relational server

• First to include OLAP in database

• Auto tuning• Ease-of-use

Foundations of Foundations of each release:each release:

SQL Server 6.5

• Data warehousing• Internet support• Differentiation from

Sybase SQL Server

Page 41: Information Technologies and Microsoft SQL Server Day 1 by Alper Özpınar ozpinar@zetabt.com.

Versions of SQL Server 2000

SQL Server CE Runs on Windows CE Replicate data from Standard and Enterprise Edition

Personal Runs on Windows 9x/ME/2000 Pro No license required if you have Standard or Enterprise Edition

Developer Designed for Developers to be used on Single Machine Runs on Windows NT/2000

Standard Comes with most of the features for workgroups and departments Lacks dome enterprise level features Runs on Windows NT/2000 Server

Enterprise: All features including clustering support, log shipping, parallel computing support,

enhanced read-aheads, partitioning support, HTTP support, Very Large Database (VLDB) Support

Runs on Windows NT/2000 Server

Page 42: Information Technologies and Microsoft SQL Server Day 1 by Alper Özpınar ozpinar@zetabt.com.

Feature Personal Standard Enterprise

Runs on Microsoft Windows NT 4 Server or Windows 2000 Server

Yes Yes Yes

Runs on Windows NT 4 Server, Enterprise Edition or Windows 2000 Advanced Server

Yes Yes Yes

AWE Support (Windows 2000 only)

No No Yes

SQL Server failover support No No Yes

Supports Microsoft Search Service, full-text catalogs, and full-text indexes

Yes, except on Windows 98

Yes Yes

Maximum database size 2 GB 1,048,516 TB 1,048,516 TB

Number of symmetric multiprocessing (SMP) CPUs

2 on all platforms except Windows 98, which supports only 1

4 on all platforms except Windows NT 4 Server, Enterprise Edition, which supports 8

32 on Windows 2000 Datacenter Server 8 on Windows NT 4 Server Enterprise Edition and Windows 2000 Advanced Server 4 on Windows NT 4 Server and Windows 2000 Server

Physical memory supported 2 GB 2 GB

64 GB on Windows 2000 Datacenter Server 8 GB on Windows 2000 Advanced Server 4 GB on Windows 2000 Server 3 GB on Windows NT 4 Server, Enterprise Edition 2 GB on Windows NT 4 Server

Page 43: Information Technologies and Microsoft SQL Server Day 1 by Alper Özpınar ozpinar@zetabt.com.

SQL Server 2000 Clients

Directly Supported: Windows 9x/ME Windows 2000 Windows NT

Does not ship with 16-bit drivers, however you can use drivers from old version of SQL Server

When correctly configured with Web Server, any client can access it

Page 44: Information Technologies and Microsoft SQL Server Day 1 by Alper Özpınar ozpinar@zetabt.com.

Differences on Windows 9x

Windows 9x Windows 2000 AS

SQL Engine Runs as an application Runs as a Service

Integrated Security No Yes

Automated Alerts No Yes

Maximum Users (Recommended)

Five Unlimited (Limited by Hardware resources)

Performance Monitor No Yes

Page 45: Information Technologies and Microsoft SQL Server Day 1 by Alper Özpınar ozpinar@zetabt.com.

Special System Databases

A new SQL Server 2000 installation automatically includes six databases: master, model, tempdb, pubs, Northwind, and msdb.

Page 46: Information Technologies and Microsoft SQL Server Day 1 by Alper Özpınar ozpinar@zetabt.com.

master

The master database is composed of system tables that keep track of the server installation as a whole and all other databases that are subsequently created. Although every database has a set of system catalogs that maintain information about objects it contains, the master database has system catalogs that keep information about disk space, file allocations, usage, systemwide configuration settings, login accounts, the existence of other databases, and the existence of other SQL servers (for distributed operations). The master database is absolutely critical to your system, so be sure to always keep a current backup copy of it. Operations such as creating another database, changing configuration values, and modifying login accounts all make modifications to master, so after performing such activities, you should back up master.

Page 47: Information Technologies and Microsoft SQL Server Day 1 by Alper Özpınar ozpinar@zetabt.com.

model

The model database is simply a template database. Every time you create a new database, SQL Server makes a copy of model to form the basis of the new database. If you'd like every new database to start out with certain objects or permissions, you can put them in model, and all new databases will inherit them.

Page 48: Information Technologies and Microsoft SQL Server Day 1 by Alper Özpınar ozpinar@zetabt.com.

Pubs & Northwind

The pubs database is a sample database used extensively by much of the SQL Server documentation

The Northwind database is a sample database that was originally developed for use with Microsoft Access. Much of the documentation dealing with APIs uses Northwind, as do some of the newer examples in the SQL Server documentation. It's a bit more complex than pubs, and at almost 4 MB, slightly larger.

The Northwind database can be rebuilt just like the pubs database, by running a script located in the \Install subdirectory. The file is called Instnwnd.sql.

Page 49: Information Technologies and Microsoft SQL Server Day 1 by Alper Özpınar ozpinar@zetabt.com.

msdb

The msdb database is used by the SQL Server Agent service, which performs scheduled activities such as backups and replication tasks. In general, other than performing backups and maintenance on this database, you should ignore msdb.

Page 50: Information Technologies and Microsoft SQL Server Day 1 by Alper Özpınar ozpinar@zetabt.com.

Database Files

A database file is nothing more than an operating system file. (In addition to database files, SQL Server also has backup devices, which are logical devices that map to operating system files, to physical devices such as tape drives, or even to named pipes. :

Primary data files Every database has one primary data file that keeps track of all the rest of the files in the database, in addition to storing data. By convention, the name of a primary data file has the extension MDF.

Secondary data files A database can have zero or more secondary data files. By convention, the name of a secondary data file has the extension NDF.

Log files Every database has at least one log file that contains the information necessary to recover all transactions in a database. By convention, a log file has the extension LDF.

Page 51: Information Technologies and Microsoft SQL Server Day 1 by Alper Özpınar ozpinar@zetabt.com.

Creating a Database

The easiest way to create a database is to use SQL Server Enterprise Manager, which provides a graphical front end to Transact-SQL commands and stored procedures that actually create the database and set its properties

by Command CREATE DATABASE newdb

Page 52: Information Technologies and Microsoft SQL Server Day 1 by Alper Özpınar ozpinar@zetabt.com.

Creating a Table

Data Types Description bigint Integer data from -2^63 through 2^63-1 int Integer data from -2^31 through 2^31 - 1 smallint Integer data from -2^15 through 2^15 - 1 tinyint Integer data from 0 through 255 bit Integer data with either a 1 or 0 value decimal Fixed precision and scale numeric data from -10^38 +1 through 10^38 -1 numeric Fixed precision and scale numeric data from -10^38 +1 through 10^38 -1 money Monetary data values from -2^63 through 2^63 - 1 smallmoney Monetary data values from -214,748.3648 through +214,748.3647 float Floating precision number data from -1.79E + 308 through 1.79E + 308 real Floating precision number data from -3.40E + 38 through 3.40E + 38

datetime Date and time data from January 1, 1753, through December 31, 9999, with an accuracy of 3.33 milliseconds

smalldatetime Date and time data from January 1, 1900, through June 6, 2079, with an accuracy of one minute

Page 53: Information Technologies and Microsoft SQL Server Day 1 by Alper Özpınar ozpinar@zetabt.com.

Creating a Table

Data Types Description char Fixed-length character data with a maximum length of 8,000 characters varchar Variable-length data with a maximum of 8,000 characters text Variable-length data with a maximum length of 2^31 - 1 characters nchar Fixed-length Unicode data with a maximum length of 4,000 characters nvarchar Variable-length Unicode data with a maximum length of 4,000 characters ntext Variable-length Unicode data with a maximum length of 2^30 - 1 characters binary Fixed-length binary data with a maximum length of 8,000 bytes varbinary Variable-length binary data with a maximum length of 8,000 bytes image Variable-length binary data with a maximum length of 2^31 - 1 bytes cursor A reference to a cursor

sql_variant A data type that stores values of various data types, except text, ntext, timestamp, and sql_variant

table A special data type used to store a result set for later processing

timestamp A database-wide unique number that gets updated every time a row gets updated

uniqueidentifier A globally unique identifier