1-RDBMS - SQL
1-RDBMS - SQL
1-RDBMS - SQL
RDBMS Concepts
to Identify
to Explain
to Administer
to Plan
to Monitor
to Decide
to Analyze
to Implement
What is a DBMS??
Database
s
d
r
o Shane
A003 Allen
A007
c
e
R
d
A004 Brian
te A008 Ricky
a
l
Re
Retrieve Data
Update Data
Insert Data
Delete Data
DBMS
Benefits of DBMS
Database Models
RDBMS
Relational
Database
Applications for
interacting with
data in DB
RDBMS
A suite of S/W
programs to
create, maintain
DB
Users of RDBMS
Database
Administrators
End Users
Application Programmers
SQL
SQL
SQL
SQL
SQL
SQL
Server
Server
Server
Server
Server
Server
2000
2000
2000
2000
2000
2000
Enterprise Edition
Standard Edition
Personal Edition
Developer Edition
Desktop Engine
Windows CE Edition
Easy Installation
Enterprise
Edition
Standard
Edition
Personal
Edition
Developer
Edition
Desktop
Engine
SQL
Server
CE
Enterprise
Evaluation Edition
Microsoft Windows
98
Windows NT 4.0
Workstation
N/A
N/A
Supported
N/A
Supported
N/A
N/A
N/A
N/A
Supported
Supported
Supported
N/A
Supported
Windows NT 4.0
Server
Microsoft Windows
NT 4.0 Server,
Enterprise Edition
Supported
Supported
Supported
Supported
Supported
N/A
Supported
Supported
Supported
Supported
Supported
Supported
N/A
Supported
Windows 2000
Professional
N/A
N/A
Supported
Supported
Supported
N/A
Supported
Windows 2000
Server
Windows 2000
Advanced Server
Supported
Supported
Supported
Supported
Supported
N/A
Supported
Supported
Supported
Supported
Supported
Supported
N/A
Supported
Microsoft Windows
2000 DataCenter
Supported
Supported
Supported
Supported
Supported
N/A
Supported
Microsoft Windows
CE
N/A
N/A
N/A
N/A
N/A
SQL Server
Database Software
Client/Server mechanism
ODBC
ODS
Database
Designer
Tables
identified
End User
Attributes
A description
A Property
Relationship
Entity
Attribute
Relationship
Types of Relationships
1
Ha
s1
C_Code
One to One
1:1
One to Many 1: N
Many to Many N:M
Customer
Place
s
Item
N
Contain
s
Order
Identifies
Database
Designer
Attributes
Fields
Relations
Characteristics of a normalized
database
PUBS DATABASE
stor_id
ord_num
ord_date
qty
payterms
title_id
sales
c har(4)
varc har(20)
datetime
smallint
varc har(12)
varc har(6)
stor_id = stor_id
stores
stor_id
c har(4)
stor_name
varc har(40)
stor_address varc har(40)
city
varc har(20)
state
c har(2)
zip
c har(5)
stor_id = stor_id
title_id = title_id
titleauthor
au_id
varc har(11)
title_id
varc har(6)
au_ord
tinyint
royaltyper int
au_id = au_id
authors
au_id
varc har(11)
au_lname varc har(40)
au_fname varc har(20)
phone
c har(12)
address
varc har(40)
c ity
varc har(20)
state
c har(2)
zip
c har(5)
c ontrac t
bit
title_id = title_id
title_id
title
type
pub_id
pric e
advanc e
royalty
ytd_sales
notes
pubdate
titles
varc har(6)
varc har(80)
c har(12)
c har(4)
money
money
int
int
varc har(200)
datetime
title_id = title_id
roysched
title_id
varc har(6)
lorange int
hirange int
royalty
int
pub_id = pub_id
publishers
pub_id
char(4)
pub_name varc har(40)
c ity
varc har(20)
state
char(2)
c ountry
varc har(30)
discounts
disc ounttype varc har(40)
stor_id
c har(4)
lowqty
smallint
highqty
smallint
disc ount
decimal
pub_id = pub_id
employee
emp_id
c har(9)
fname
varc har(20)
minit
c har
lname
varc har(30)
job_id
smallint
job_lvl
tinyint
pub_id
c har(4)
hire_date datetime
job_id = job_id
job_id
job_desc
min_lvl
max_lvl
jobs
smallint
varc har(50)
tinyint
tinyint
pub_id = pub_id
pub_info
pub_id c har(4)
logo
image
pr_info text
authors_tmp
au_lname varc har(40)
au_fname varc har(20)
phone
char(12)
address
varc har(40)
c ity
varc har(20)
state
char(2)
zip
char(5)
DATABASE
At the most basic level a database is really just a file.
Databases come in all shapes and sizes. Some are large and
some are small. But each database generally serves a particular
purpose.
Features of tables
TABLES
A table is a storage structure made up of rows and columns.
(Sort of like a spreadsheet.)
Due to the differing terminologies, there are interchangeable
sets of terms:
Database
Table
Row
Column
File
Record
Field
TABLES
You will also hear a table referred to as an
entity. (Hence the name Entity
Relationship Diagram)
In the most basic sense, an entity is a
person, place, thing, or idea.
Entities usually become tables
Example: books, publishers, titles, authors
Keys
Default values
Indexes
Null values
Creating Tables
NAMING A TABLE
Up to 30 characters
No blanks
Underscore is permitted
Must be unique within the database
Keep abbreviations to a minimum
Names should reflect the contents of the table
NAMING A COLUMN
Up to 30 characters
No blanks
Underscore is permitted
Must be unique within the table
Keep abbreviations to a minimum
Names should reflect the contents of the column
Names should be readily recognizable
Data types
Data types
DATATYPES
Exact Numeric
Stores data with a specific accuracy
Approximate numeric
Stores data with accuracy dependent upon
calculations performed
Money
:
Monetary data
Date and time :
Storage of dates and times
Character
:
Alphanumeric data
Binary
:
Images, byte and bit values
NUMERIC DATATYPES
Tinyint
Whole numbers between 0 and 255
1 byte of storage
Smallint
Whole numbers between -32678 and
32677
2 bytes of storage
NUMERIC DATATYPES
numeric(p,s)
decimal(p,s)
Float(p)
double precision
real
Money
-922,337,203,685,477.5808 to
922,337,203,685,477.5807
8 bytes of storage
SmallMoney
-214,748.3648 to 214,748.3647
4 bytes of storage
Accurate up to 4 decimal places, but
are rounded to 2 places when
displaying
1/1/1753 to 1/31/9999
8 bytes of storage
Smalldatetime
1/1/1900 to 6/6/2079
4 bytes of storage
There is no separate datatype for just times
Time is stored along with a date with an accuracy of
1/300th of a second
Due to the limitation on the range of data, a
smalldatetime should no longer be used.
Dates and times can be entered into these columns
using a wide variety of date and time formats
The default display type is determined from the default
language for the server
Datetime
Text
Bit
Binary(n)
up to 255 bytes
n bytes of storage
Varbinary
0 or 1
1 byte of storage
up to 255 bytes
actual length of data
Image
up to 231-1 bytes
16 bytes address + multiples of 2K bytes of
storage
This data data type can be used whenever there is need for
storing pin numbers
Modifying Tables
Add Rows
INSERT [INTO] <Table_name> VALUES <values>
Modifying Tables
Update Rows
UPDATE <Table_name> SET <Column_name = Value>
WHERE <Search_Condition>
Modifying Tables
Delete Rows
DELETE FROM <Table_name> WHERE <Search_Condition>
Removing tables