sql server 2005 _ lab 1
TRANSCRIPT
8/8/2019 SQL Server 2005 _ Lab 1
http://slidepdf.com/reader/full/sql-server-2005-lab-1 1/24
Adavnced Database Programming 1
MS SQL Server 2005MS SQL Server 2005
Lab #1 : Introduction
Installing Start Working With
8/8/2019 SQL Server 2005 _ Lab 1
http://slidepdf.com/reader/full/sql-server-2005-lab-1 2/24
Adavnced Database Programming 2
What is MS SQL Server?
MS SQL Server is a database managementsystem
SQL Server is one of the most popular andadvanced database systems currently
available. SQL Server is provided by Microsoft. Runs EXCLUSIVELY under Windows
operating system(2000,XP,Server 2003)
Uses specified type of SQL called ³Transact-
SQL´ : Specifies a sequence of Transact-SQL statements
that build a logical unit
used purposely for: Data Recovery & Concurrency
8/8/2019 SQL Server 2005 _ Lab 1
http://slidepdf.com/reader/full/sql-server-2005-lab-1 3/24
Adavnced Database Programming 3
Why MS SQL Server?
Because it works as an extension for Windows system which benefits it with . . .
1. Basically for Client/Server DBMS which
manages large number of different networkconnected computers
2. Using Windows OS Services that offers thedatabase with new or extended databasecapabilities such as:
Sending & Receiving messages, Task Scheduling
Managing login Security, Alerting,
Data Replication, . . . etc
8/8/2019 SQL Server 2005 _ Lab 1
http://slidepdf.com/reader/full/sql-server-2005-lab-1 4/24
Adavnced Database Programming 4
Why MS SQL Server?
3. Easy to use
4. Scales from mobile laptop to S-Multi Processor
5. Provides Business Intelligence Features
6. MS SQL Server is Bundled with Analyzing
Server to create a Comprehensive and as easier
approach to build Data Warehouse & DataMart
Solutions Using MS new OLAP technology
8/8/2019 SQL Server 2005 _ Lab 1
http://slidepdf.com/reader/full/sql-server-2005-lab-1 5/24
8/8/2019 SQL Server 2005 _ Lab 1
http://slidepdf.com/reader/full/sql-server-2005-lab-1 6/24
Adavnced Database Programming 6
SQL Server Editions
1.1. SQL Server ExpressSQL Server Express (used by: Application
Developers)
2.2.
Workgroup EditionWorkgroup Edition (For: SmallB
usinesses )3.3. Standard EditionStandard Edition ( Relational Database
without Business Intelligence)
4.4. Enterprise EditionEnterprise Edition (For: Time-Critical
Application With Large number of users,multiprocessor, data partitioning, Database
Snapshots, Online Database Maintenance )
8/8/2019 SQL Server 2005 _ Lab 1
http://slidepdf.com/reader/full/sql-server-2005-lab-1 7/24
Adavnced Database Programming 7
Planning the Installation . . .
What is the purpose of the SQL Server
System?
What are HW and SW requirements? How many users will be active at the same
time?
Where will the root directory be stored?
Which security type will be used?
8/8/2019 SQL Server 2005 _ Lab 1
http://slidepdf.com/reader/full/sql-server-2005-lab-1 8/24
Adavnced Database Programming 8
The Architecture of MS SQL Sever SQL Server (service) can be installed multiple times on the same
computer. Each installation is called an 'Instance'. When you
install SQL Server each time, a new windows service is installed.
Working with multiple instances:
to divide databases exist in your organization in different
groups
Each instance of SQL Server has its own set of :
Database Engine (System & User databases that aren¶t
shared with other server instances)
Analysis Server Integration Server
Report Server
SQL Server Mobile
8/8/2019 SQL Server 2005 _ Lab 1
http://slidepdf.com/reader/full/sql-server-2005-lab-1 9/24
Adavnced Database Programming 9
The Architecture of MS SQL Sever
Two types of Instances:
1.1. Default Instance:Default Instance:
Can create ONLY one default instance of it
Works as previous SQL Sever editions where no
support for instances
2.2. Named Instance:Named Instance:
Can create multi instances Give it a name (Instance Name\Computer Name)
Supports instances
8/8/2019 SQL Server 2005 _ Lab 1
http://slidepdf.com/reader/full/sql-server-2005-lab-1 10/24
The Architecture of MS SQL Sever
In most cases, you will need to install only
one instance (default instance). Multiple
instances are useful if you have multiple
departments or multiple clients sharing the
same computer and do need to manage their
SQL Server instance without affecting other
departments/clients.
Adavnced Database Programming 10
8/8/2019 SQL Server 2005 _ Lab 1
http://slidepdf.com/reader/full/sql-server-2005-lab-1 11/24
Adavnced Database Programming 11
Exploring SQL Server
Management Studio 2005
StartStart
ProgramsPrograms M
icrosoft SQL Server M
icrosoft SQL Server 20052005 SQL Server Management StudioSQL Server Management Studio Registered Servers
Object Explorer
Query Editor
Solution Explorer
8/8/2019 SQL Server 2005 _ Lab 1
http://slidepdf.com/reader/full/sql-server-2005-lab-1 12/24
Adavnced Database Programming 12
SQL Server Management Studio WindowsSQL Server Management Studio Windows
Registered Servers:
1. Lists servers that you manage.
2. Register Server: You can add, delete or edit a
server.
3. Addition of a Server Group.
8/8/2019 SQL Server 2005 _ Lab 1
http://slidepdf.com/reader/full/sql-server-2005-lab-1 13/24
Adavnced Database Programming 13
SQL Server Management Studio WindowsSQL Server Management Studio Windows
Object Explorer:
1. contain a tree of all the database objects and
other Services Servers (Analysis, Report,
Integration) in a Server Instance.
2. Management of several (local or Remote)
Servers on a computer
3. Starting, Pausing & Stopping Servers
4. Database Management: Create & modify DB
objects such as databases, tables,. . . etc
5. Generation & Execution of SQL Statements
8/8/2019 SQL Server 2005 _ Lab 1
http://slidepdf.com/reader/full/sql-server-2005-lab-1 14/24
Adavnced Database Programming 14
SQL Server Management Studio WindowsSQL Server Management Studio Windows
Query Editor:
Click New Query Button
Status bar at the bottom will show Connecting to
Server Status (Connected/Disconnected)
You can:
Generate & Execute Transact-SQL
Store Transact-SQL in a file Analyze execution plans for queries &
graphically illustrate it
8/8/2019 SQL Server 2005 _ Lab 1
http://slidepdf.com/reader/full/sql-server-2005-lab-1 15/24
Adavnced Database Programming 15
Starting with Servers
1. Register a Server:
Must be done before using it (it doesn't connect you to the
Server)
Registered ServersR.C. Database Engine
New
Server
Registration
OR Registered Servers R.C. Server New Server
Enter Server name & type
2. Connecting to the Server: (two ways)
Registered Servers R.C. Server ConnectNew Query
Object Explorer R.C. Server NameConnect
3. Work with the Server from Object Explorer
8/8/2019 SQL Server 2005 _ Lab 1
http://slidepdf.com/reader/full/sql-server-2005-lab-1 16/24
Adavnced Database Programming 16
Start Working With SQL Server 2005
First: Connect to Server Connect to Server Dialog Box
1. Select Server Type (Ex. Database Engine)
2. Select or type the Server name you want to use
3. Choose one of the two Authentication types:
1. Windows Authentication: Connecting using user
windows account
2. SQL Server Authentication: uses program
Authentication (needs user name + password)
8/8/2019 SQL Server 2005 _ Lab 1
http://slidepdf.com/reader/full/sql-server-2005-lab-1 17/24
Adavnced Database Programming 17
Creating New Server Group
To organize your Servers in groups
Two ways to , Choose one of them:
1. Registered Servers R.C. Database Engine
New Server Group type a Unique group
Name & choose group storing location
2. OR After Connecting your Server(s)
Registered Servers
R.C. Server
New
Server Group Enter group name
8/8/2019 SQL Server 2005 _ Lab 1
http://slidepdf.com/reader/full/sql-server-2005-lab-1 18/24
Adavnced Database Programming 18
Managing Servers
Configure Server Properties:
Object Explorer R.C on the chosen server
properities (Permissions, Security, « etc)
Rename a Server:
Object Explorer R.C. the Server Register
enter the new name
8/8/2019 SQL Server 2005 _ Lab 1
http://slidepdf.com/reader/full/sql-server-2005-lab-1 19/24
Adavnced Database Programming 19
Working With Servers
Starting, Pausing & Stopping :Starting, Pausing & Stopping :
1. SQL Computer Manager: Start Microsoft SQL
2005Configruation Tools SQL Computer
Manager
2. SQL Server Management Studio: Object
Explorer R.C on the chosen server Start, stop,
or pause
8/8/2019 SQL Server 2005 _ Lab 1
http://slidepdf.com/reader/full/sql-server-2005-lab-1 20/24
Adavnced Database Programming 20
Managing Databases (Properties)
Object Explorer R.C on the database folder
New Database type the DB name Set
the DB Properties (especially Basic ones
such as : owner, file type, initial size, Autogrowth, ..)
File Groups: where the database belongs &
stored in Delete Database: Object Explorer R.C.
Database name Delete
8/8/2019 SQL Server 2005 _ Lab 1
http://slidepdf.com/reader/full/sql-server-2005-lab-1 21/24
Adavnced Database Programming 21
Managing Databases (Properties)
Options Property:
Database Read-Only: Allows read-only access to
the database. Prohibits users from modifying any
data (Default False)
Database State: Describes the state of the
database (Default Normal)
Restrict Access: Restrict the use of the database
to one user at a time (DefaultMultiple)
Permissions
8/8/2019 SQL Server 2005 _ Lab 1
http://slidepdf.com/reader/full/sql-server-2005-lab-1 22/24
Adavnced Database Programming 22
New Database ´Dataµ Storing File
Object Explorer R.C on the database
Properties File Property Click Add type
file new name
Same way you can do:
Add New File group
Change File location or autogrowth, « etc
8/8/2019 SQL Server 2005 _ Lab 1
http://slidepdf.com/reader/full/sql-server-2005-lab-1 23/24
Adavnced Database Programming 23
Managing Tables
Can be created through Object Explorer or by
Transact-SQL
R.C. Database subfolder TablesNew Table enter
the Columns Names, Data type & Null Property,Default Value,..etc
Primary Key: R.C. Column Set Primary Key
Close Table enter table Name
Rename Table
Delete a Table
8/8/2019 SQL Server 2005 _ Lab 1
http://slidepdf.com/reader/full/sql-server-2005-lab-1 24/24
Adavnced Database Programming 24
ER Model of the Database
Database Folder Database Diagramssubfolder New Database Diagram addneeded Tables
Add Relationships:1. Drag relationship between tables
2. R.C. Graphical Table Relationships in theForeign Key Relationships Add Expand Tables
& Columns Specification Select Table with thecorresponding primary key choose keys