Database Overview
Database Overview
Database Overview
page=soCware_development
Database Systems
Not
too
long
ago,
this
was
the
only
data-storage
device
most
companies
needed.
Those
days
are
over.
Deployment
Maintenance
TesPng
ImplementaPon
The
SoCware
Development
Lifecycle
Design
Planning
Requirements
Analysis
Database
Systems
A
Database
is
a
structured
way
to
store
lots
of
informaPon.
The
informaPon
is
stored
in
dierent
tables.
-
Everything
today
is
stored
in
databases!
Examples:
Bank/Account
systems
InformaPon
in
Web
pages
such
as
Facebook,
Wikipedia,
YouTube,
etc.
Fronter,
TimeEdit,
etc.
lots
of
other
examples!
4
Example:
Database ER Diagram
Oracle
MySQL
(owned
by
Oracle,
but
previously
owned
by
Sun
Microsystems)
-
MySQL
can
be
used
free
of
charge
(open
source
license),
Web
sites
that
use
MySQL:
YouTube,
Wikipedia,
Facebook
MicrosoC
Access
IBM
DB2
Sybase
MariaDB
MongoDB
etc.
7
Database
Types
RelaPon
Database/SQL
Databases
MicrosC
SQL
Server
Oracle
MySQL
MariaDB
etc.
NoSQL
Databases
MongoDB
etc.
Database Types
h/p://home.hit.no/~hansha/?page=soCware_development
Database
Modelling
Hans-Pe/er
Halvorsen,
M.Sc.
10
Database
Modelling
The
logical
structure
of
the
database
ER
Diagram
(EnPty
RelaPonship)
11
Example:
Table
Name
Column
Names
Primary
Key
Primary
Key
Foreign
Key
RelaPonal
Database.
In
a
relaPonal
database
all
the
tables
have
one
or
more
relaPon
with
each
other
using
Primary
Keys
(PK)
and
Foreign
Keys
(FK).
Note!
You
can
only
have
one
PK
in
a
table,
but
you
may
have
several
FKs.
13
14
15
Table Name
17
ER
DTable
iagram
Example
using
built-in
Designer
in
MicrosoC
SQL
Server
Name
Table
Name
PK
FK
PK
PK-FK
Rela@onship
Table
Name
PK
FK
Table
Name
PK
FK
FK
Table
Name
PK
FK
PK-FK
Rela@onships
Table
Name
PK
FK
Table
Name
PK
FK
FK
Table
Name
PK
FK
FK
18
h/p://home.hit.no/~hansha/?page=soCware_development
20
SQL
Server
Main
parts:
SQL
Server
Engine
+
Management
Studio
Latest
version:
SQL
Server
2014
SQL
Server
Standard,
Developer,
Web,
Enterprise,
Datacenter,
...
Free
AlternaPve:
SQL
Server
Express
SQL
Azure
Database
Cloud-based
version
21
22
Your Database
Your
Tables
5
23
24
25
h/p://home.hit.no/~hansha/?page=soCware_development
SQL
27
We have 4 dierent Query Types (CRUD): INSERT, SELECT, UPDATE and DELETE
28
2
Next,
the
table
designer
pops
up
where
you
can
add
columns,
data
types,
etc.
29
30
if not exists (select * from dbo.sysobjects where id = object_id(N'[SCHOOL]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
N'IsUserTable') = 1)
31
select
SchoolName,
CourseName
from
You
link
Primary
Keys
and
Foreign
Keys
together
SCHOOL
inner
join
COURSE
on
SCHOOL.SchoolId
=
COURSE.SchoolId
32
2
4
Add
necessary
tables
Save
the
View
33
Create View:
GO
34
Stored Procedure
35
Trigger
A
Trigger
is
executed
when
you
insert,
update
or
delete
data
in
a
Table
specied
in
the
Trigger.
Inside
the
Trigger
you
can
use
ordinary
SQL
statements,
create
variables,
etc.
SQL
Code
(The
body
of
the
Trigger)
GO
Note!
INSERTED
is
a
temporarily
table
containing
the
latest
inserted
data,
and
it
is
very
handy
to
use
inside
a
trigger
36
Exercise
SQL
Use
SQL
queries
to
implemnt
data
into
your
LIBRARY
database
WeTest
the
dierent
Query
Types
(CRUD):
INSERT,
SELECT,
UPDATE
and
DELETE
Summary
DBMS
Database
Management
System
SQL
Structured
Query
Language.
A
Database
Computer
Language
designed
for
Managing
Data
in
RelaPonal
Database
Management
Systems
(RDBMS)
ER
Diagram
EnPty
RelaPonship.
Used
for
Design
and
Modeling
of
Databases.
Specify
Tables
and
relaPonship
between
them
(Primary
Keys
and
Foreign
Keys)
38
References
NTNU.
(2013).
TDT4140
Systemutvikling.
Available:
h/p://www.ntnu.no/studier/emner/TDT4140
UiO.
(2013).
INF1050
-
Systemutvikling.
Available:
h/p://www.uio.no/studier/emner/matnat/i/INF1050/
O.
Widder.
(2013).
geek&poke.
Available:
h/p://geek-and-poke.com
B.
Lund.
(2013).
Lunch.
Available:
h/p://www.lunchstriper.no,
h/p://www.dagbladet.no/tegneserie/lunch/
S.
Adams.
Dilbert.
Available:
h/p://dilbert.com
39
E-mail:
[email protected]
Blog:
hcp://home.hit.no/~hansha/
40