SQL Server
2008
Lecture 1
Prepared by:
Roy B. Callope
A Brief History and
Background of RDBMS
Dr.
Edgar F. Codd pioneered the concept
of relational database model in 1970.
From his seminal paper A Relational
Model of Data for Large Shared Data
Banks
SQL his groundbreaking invention at the
IBM Research Labs (1971)
RDBMS Defined
A
relational database is simply a
collection of interrelated information
that is organized into tables.
Microsoft SQL Server 2008
Is
aimed to be database platform for the
next generation of connected, scalable
and reliable enterprise level
applications.
Default System Databases
Master default system database,
composed of system tables that keep track
of server installation as a whole and all
other databases that we subsequently
created.
Model is a template database. Every time
we create a new database, the SQL Server
makes a copy of the model database to
form the basis of the new database.
Default System Databases
Msdb
contains the metadata and database
objects used by the SQL Server agent that
performs scheduled activities.
Tempdb is a temporary database or workspace.
This default system database is always recreated
every time the SQL Server is restarted. The
tempdb database is used purposely for
temporary tables created by the database users
and hold intermediate results created internally
by the SQL Server during query processing and
sorting activities.
Common Data Types of SQL
Server
Numeric
Character
Date
and Time
Miscellaneous Data Types
Integer Data Types
INT
uses 4 bytes of storage, from -231 to 231 - 1
SMALLINT uses 2 bytes of storage, from 2 15 to
215 - 1
TINYINT 1 byte of storage, stores from 0 to
255
BIGINT uses 8 bytes of storage, from -2 63 to
263 - 1
MONEY uses 8 bytes of storage
SMALLMONEY
Decimal Data Types
Refers
to a number with decimal point
Precision refers to the total number of
digits stored
Scale is the maximum number of
digits to the right of the decimal point
Decimal Data Types
DECIMAL
uses 217 bytes for storage,
however the storage sizes varies
depending on the specified precision
FLOAT uses 8 bytes for storage and
has the precision of 15 digits
REAL uses 4 bytes for storage and has
a precision of 7 digits
Character Data Types
Refers
to any combination of letters,
numbers and symbols.
Enclosed with single quote.
Character Data Types
VARCHAR
(n) variable length singlebyte character strings that can also be
used to store up to 8000 bytes of data,
the storage size will be the actual length
of the data entered
CHAR(n) is a fixed-length single-byte
character strings that can be used to
store up to 8000 bytes of data
Character Data Types
TEXT
is also a variable-length singlebyte character strings, but may be used
to store more than 8000 bytes of data,
this is for storing large strings of data
Date and Time Data Types
DATETIME
Uses 8 bytes for storage
SMALLDATETIME
Uses 4 bytes of storage
Miscellaneous Data Types
IMAGE
is used to store pictures or
images which is in binary format
BIT is an integer data type which can
store only 1 or 0 and can consume only
a single bit of storage space
XML is used to store and handle XML
data
Simple Rules in Selecting Data
Types
Use the smallest possible sizes. The
smaller the column size, the lesser the
amount of data that SQL Server has to store
and process.
If we are going to use a column for frequent
sorts, let us use an integer-based column
rather than a character-based column.
We should not use REAL and FLOAT data
types in defining our primary keys.
Your database: