Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 12

Database Design with SQL

My name: Mark Robbins


Ex Project Manager of large Public Service
Network implementations; now part-time
University teacher and consultant.

Who are you?

© Mark Robbins 2007


Course Structure

• Introduction to Relational Database Theory

• Database Design

• Implementing the Design

• Querying Data

• Introduction to programming SQL Server with T-SQL and the .NET Framework

Practical emphasis concentrating on basic Development -


A great deal of supporting theory and a lot of admin areas, which are
discussed in the set text “Database Systems” (Connolly & Begg)

Tonight’s Chapters – 1 & 2


Assessment

Class work, some of which will be assessed . Gives me a chance to evaluate your
understanding (50%)
A coursework (50%):

• Design a reasonably complex database


• Implement it in SQL Server
Basic Filing Systems

Customer Record:  
   
Customer Record:  
Name:
  J Bloggs
 
Customer Record:  
Address:
Name: 14 Acacia Avenue, Newtown, NT1 2BJ
J Bloggs
   
Customer Record:  
Balance:
Address: 14 Acacia Avenue, Newtown, NT1 2BJ £550
Name: J Bloggs
Sales Rep:
 
Giles Smooth
  File
Balance:
Address: 14 Acacia Avenue, Newtown, NT1 2BJ £550
Name: J Bloggs
Sales Rep:
Address: Giles Smooth
Balance: 14 Acacia Avenue, Newtown, NT1 2BJ £550
Sales Rep:
Balance: Giles Smooth £550
Sales Rep: Giles Smooth

Headings Record
(Fields)
The Origins of DP – File-based Systems

Pe rso nne l Ac a d e m ic Purc ha sing Ac c o unts


De pt. De p ts. De p t. De p t.

Custom Written Data Data Data Data


software for User Manipulation/ Manipulation/ Manipulation/ Manipulation/
User Interface User Interface User Interface User Interface
Interface and Data Application Application Application Application
Manipulation

Em p lo ye e
Raw data in separate Em p lo ye e Stu d e n t Su p p lie r
Pa yro ll
files Re c o rd s Re c o rd s Re c o rd s
Re c o rd s

© Mark Robbins 2007


File-based Systems – The Problems
 Data:

Duplication of Data (e.g Employee and Payroll)

Difficulty of integrating data (e.g. some applications need
Student & Lecturer info)
 Departments can only see their own narrow subset of data

 Applications:

 If the nature of the Data Changes, so do (data definitions


within) Programs
 Cumbersome; have to write all code for updating and querying
the files as well as the user functionality

A lot of duplication of effort (basic file handling routines the
same across systems).

© Mark Robbins 2007


The Database Approach

Ac a d e m ic Ac c o unts
De p ts. De p t.

User User
Interface Interface
Application Application
RDBMS
Em p lo ye e

Stud e nt
Pe rso nne l User
Interface
User
Interface
Purc ha sing
De p t. Application Sup p lie r Application De pt.

© Mark Robbins 2007


The Problems Solved
 Data:

No Duplication – all data in one place

All integrated; DBMS maintains links between all data so can
get from one piece to any related piece
 Can take whatever view of the data you want

 Applications:
 DBMS provides DML for updating the data and DDL for
defining it ( both often implemented as point-and-click GUIs
for even more ease – as in SQL Server)
 High level Query Language (SQL) and report generators reduce
the effort required to query the database. Forms generators
and other utilities reduce the work load further.

Data definitions stored separately (Data Dictionary), so when
data changes programs don’t have to.
© Mark Robbins 2007
The RDBMS
E.F. Codd’s 8 Services (+3):

1. Data storage, retrieval and update (DML & SQL)


2. A System Catalogue (The Data Dictionary – updated using DDL)
3. Transaction Support (All updates or none)
4. Concurrency Support (prevent clashing updates)
5. Recovery Services (recover to a consistent state)
6. Authorisation Services (data accessible only to those with permission)
7. Support for Data Communication (handling remote users)
8. Integrity Services (Data updated according to certain rules – stored in the
Data Dictionary

AND...
9. Data Independence (Changes to data structure do not change user views)
10. Utility services (importing, monitoring, analysis etc)
11. Programming language to integrate several DB processes into one (T-SQL.
.NET languages)
Basic database concepts
DATABASE Column (Field)

Name Address Balance Rep


J. Bloggs 14 Acacia Ave £550.00 G. Smooth Row (Record)
C. Vooderman 21 Keats Drive £350.00 C. Charmer
Table (File) 15 Hatton
J.Rumbelow Gardens £477.00 G.Smooth
D.Theabould 35 The Grove £1,990.00 G.Smooth
...      

               
               
               
               
Designing a Database
With the database approach, and the complex structure it allows us to give to
our data, design becomes very important:

• Which tables make up the database?


• Which columns belong in which table?
• How are the tables linked?
• What integrity rules belong to which columns?
• How do we retrieve data from each table?

1. Basic technique we will be learning is ERM (Entity Relationship Modelling) –


Establishes which entities (tables) we need and then determines relationship

between them.
2. Once done, we can further refine which columns belong to which tables
using a technique known as Normalisation
3. We then implement our design using a tool called SQL Server
Management Studio
SQL Server Management Studio

Object Work Area;


Explorer; display tables,
retrieve data
databases dictionary,
and tables write queries

Management Studio –
1. Graphical Front End to DDL and DML
2. SQL Editor and Processor
3. Various Admin and Programming Functions

You might also like