Search for notes by fellow students, in your own course and all over the country.
Browse our notes for titles which look like what you need, you can preview any of the notes via a sample of the contents. After you're happy these are the notes you're after simply pop them into your shopping cart.
Document Preview
Extracts from the notes are below, to see the PDF you'll receive please use the links above
Databases for beginners
02-DBBA
Marek Kręglewski
1
About the course
• Steven Roman, Access Database Design &
Programming (3rd Edition), O’Reilly 2002
• Curtis D
...
microsoft
...
microsoft
...
aspx#BMpartsofadatabase
2
Basics about a database?
• A database is a structured collection of records
...
• Databases versus spreadsheets
– easy manipulation of data
3
Single table database
ISBN
Title
AuID
AuName
AuTel
PubID
PubName
PubTel
Price
0-99-999999-9
Emma
1
Austen
111-111-1111
1
Big House
123-456-7890
20
...
00 zł
0-91-045678-5
Hamlet
5
Shakespeare
555-555-5555
2
Alpha Press
999-999-9999
20
...
00 zł
0-555-55555-9
Macbeth
5
Shakespeare
555-555-5555
2
Alpha Press
999-999-9999
12
...
00 zł
0-55-123456-9
Main Street
9
Smith
123-222-2222
3
Small House
714-000-0000
23
...
00 zł
0-321-32132-1
Balloon
2
Sleepy
222-222-2222
3
Small House
714-000-0000
34
...
00 zł
0-321-32132-1
Balloon
11
Grumpy
321-321-0000
3
Small House
714-000-0000
34
...
g
...
00 zł
0-11-345678-9
Moby Dick
3
49
...
00 zł
0-123-45678-0
Ulysses
2
34
...
00 zł
0-321-32132-1
Balloon
3
34
...
00 zł
0-555-55555-9
Macbeth
2
12
...
00 zł
0-91-335678-7
Faerie Queen
1
15
...
00 zł
0-99-999999-9
Emma
1
20
...
00 zł
1-22-233700-0
Visual Basic
1
25
...
16
Building relations
Relation many-to-many
Table S
A1
Table S/T
A2
A3
A4
A5
A1
Table T
B1
B1
B2
B3
B4
17
Enforcing referential integrity
• Cascade Update Related Fields – the
values of foreign keys change following
changes of the values of the primary key
• Cascade Delete Related Records –
deleting a record from the primary field in
a relationship causes a deletion of all
related records in the second table
18
Indexing field values
•
•
•
•
Purpose: speed up access to specific data
Used in large tables
Updating of all indexes every time a table record is updated
or added
Example
Index of towns
Table of shops
Gdańsk
•
1
Plus
Toruń
Kraków
•
2
Piotr
Poznań
Poznań
•
3
Tesco
Kraków
Poznań
•
4
Tesco
Poznań
Toruń
•
5
Plus
Gdańsk
19
Principles for building a database
• Types of attributes:
– Identification
– Information
– Identification+information
• Example 1: {PubID,PubName,PubTel,FoundYear}
Ident
Ident+inform
Inform
ISBN
Title
PubID
PubName
1-1111-1111-1
Macbeth
1
Big House
• Example 2:
2-2222-2222-2 Hamlet
1
5-5555-5555-5
2
ABC Press
20
Queries
• Database – data located in tables + relations
• Query – primary mechanism for retrieving information
from a database, consists of questions presented to the
database in a predefined format – an expression stored
in a database having a unique name
• Answer to the query – a computed table = Dynaset
• SQL – Structured Query Language
• Types of queries:
– Select query
– Action queries (Make-Table, Append, Update, Delete)
– Crosstab query
21
Creating a query in MS Access
22
Design View of a query
Drug and drop principle
23
Selection criteria
• Specifying criteria:
–
–
–
–
A value of an expression
Use of criteria operators: <, >, <=, >=, <>
BETWEEN, e
...
BETWEEN 2 AND 5,
LIKE, e
...
LIKE „*[b-d]k[0-5]?#”
• Logical operators: OR, AND
– e
...
„Smith” OR „Jones”
• Mathematical operators: +, - ,*, /, \, MOD, ^
• Text operator:
&
• Date/Time fields
– Format #2009-06-19#
#16:00#
#4:00PM#
– Date/time functions: Date()
Day(date), Month(date), Year(date), Weekday(date)
24
Calculation on groups of records
25
Parameter query
When you run the query, you will be prompted to supply the maximum price
26
Crosstab query
27
Database Normalization Basics
• Purpose: - eliminating redundant data
- ensuring logical relations of dependent data
• The normal forms
- 1NF, 2NF, 3NF, BCNF
- guidelines only
- hierarchical structure of NF
• First Normal Form (1NF)
- eliminate duplicative columns
- create separate tables for each group of related data
and define primary keys
e
...
Authors = Jones, H
...
(incorrect)
28
Database Normalization Basics
• Second Normal Form (2NF)
- meet all requirements of the 1NF
- remove subsets of data that apply to multiple rows and
place them in separate tables
- create relationships between new tables using foreign
keys
• Example - table of addresses:
{Town, Street, HouseNumber, HouseColor, SizeOfTown}
attribute of Town
29
Database Normalization Basics
• Third Normal Form (3NF)
- meet all requirements of the 2NF
- remove columns that are not dependent upon primary key
• Example
{ISBN, Title, NumberOfBooks, UnitPrice, TotalValue}
where: TotalValue = NumberOfBooks*UnitPrice
Correct form:
{ISBN, Title, NumberOfBooks, UnitPrice}
30
Database Normalization Basics
• Fourth Normal Form (Boyce-Codd NF = BCNF)
- meet all requirements of the 3NF
- remove all multi-valued dependencies
• Example
{Town, Street, HouseNumber, ZIPcode}
where: combination of {Town, Street}
determines
{Zipcode}
Correct form:
{Street, HouseNumber, ZIPcode}
and {ZIPcode, Town}
31
Decomposition of tables
• Relations between data must be conserved
AuID
AuName
PubID
A1
Smith, John
P1
A2
Smith, John
P2
• Decomposition
AuID
AuName
AuName
PubID
A1
Smith, John
Smith, John
P1
A2
Smith, John
Smith, John
P2
• Display all John Smiths
AuID
AuName
PubID
A1
Smith, John
P1
A1
Smith, John
P2
A2
Smith, John
P1
A2
Smith, John
P2
32
Example: Relation ORDERS not normalized
No_order
IDsupplier
Name_
Supplier
Address_
Supplier
IDpart
Name_
part
Qty
Warehouse
Address_
Warehouse
001
300
VW
Wolfsburg,
Rotestrasse 10
53
Carburetor
100
5
Warszawa,
Chopina 3
57
Crankshaft
50
5
Warszawa,
Chopina 3
59
Mudguard
500
6
Warszawa,
Mozarta 25
54
Carburetor
500
5
Warszawa,
Chopina 3
32
Wheel
100
6
Warszawa,
Mozarta 25
002
400
WSK
Świdnik,
Kraszewskiego 5
003
500
VW
Polska
Antoninek,
Słowackiego 2
88
Engine
15
7
Warszawa,
Bacha 3
004
600
FIAT
Bielsko-Biała,
Mickiewicza 25
58
Mudguard
400
6
Warszawa,
Mozarta 25
21
Alternator
50
7
Warszawa,
Bacha 3
53
Carburetor
200
5
Warszawa,
Chopina 3
57
Crankshaft
30
5
Warszawa,
Chopina 3
59
Mudguard
20
6
Warszawa,
Mozarta 25
005
006
300
300
VW
VW
Wolfsburg,
Rotestrasse 10
Wolfsburg,
Rotestrasse 10
33
Relation ORDERS in the first normal form (1NF)
eliminates duplicative columns
No_order
IDsupplier
Name_
Supplier
Address_
Supplier
IDpart
Name_
part
Qty
Warehouse
Address_
Warehouse
001
300
VW
Wolfsburg,
Rotestrasse 10
53
Carburetor
100
5
Warszawa,
Chopina 3
001
300
VW
Wolfsburg,
Rotestrasse 10
57
Crankshaft
50
5
Warszawa,
Chopina 3
001
300
VW
Wolfsburg,
Rotestrasse 10
59
Mudguard
500
6
Warszawa,
Mozarta 25
002
400
WSK
Świdnik,
Kraszewskiego 5
54
Carburetor
500
5
Warszawa,
Chopina 3
002
400
WSK
Świdnik,
Kraszewskiego 5
32
Wheel
100
6
Warszawa,
Mozarta 25
003
500
VW
Antoninek,
Słowackiego 2
88
Engine
15
7
Warszawa,
Bacha 3
004
600
FIAT
Bielsko-Biała,
Mickiewicza 25
58
Mudguard
400
6
Warszawa,
Mozarta 25
004
600
FIAT
Bielsko-Biała,
Mickiewicza 25
21
Alternator
50
7
Warszawa,
Bacha 3
005
300
VW
Wolfsburg,
Rotestrasse 10
53
Carburetor
200
5
Warszawa,
Chopina 3
005
300
VW
Wolfsburg,
Rotestrasse 10
57
Crankshaft
30
5
Warszawa,
Chopina 3
006
300
VW
Wolfsburg,
Rotestrasse 10
59
Mudguard
20
6
Warszawa,
Mozarta
3425
Relation ORDERS in the second normal form (2NF)
all attributes fully dependent on primary keys
No_order
IDsupplier
Name_supplier
Address_supplier
IDpart
Name_part
Qty
Warehouse
Diagram of functional
dependencies in the
relation ORDERS
Address_warehouse
35
No_order
IDsupplier
Name_
supplier
Address_Supplier
001
300
VW
Wolfsburg,
Rotestrasse 10
002
400
WSK
Świdnik,
Kraszewskiego 5
003
500
VW
Antoninek,
Słowackiego 2
004
600
FIAT
Bielsko-Biała,
Mickiewicza 25
005
300
VW
Wolfsburg,
Rotestrasse 10
006
300
VW
Wolfsburg,
Rotestrasse 10
SUPPLIER_ON_ORDER
2NF
PARTS_ON_ORDER
No_order
IDpart
Qty
001
53
100
001
57
50
001
59
500
002
54
500
002
32
100
IDpart
Name_part
Warehouse
Address_Warehouse
003
88
15
53
Carburetor
5
Warszawa, Chopina 3
004
58
400
57
Crankshaft
5
Warszawa, Chopina 3
004
21
50
58
Mudguard
6
Warszawa, Mozarta 25
005
53
200
59
Mudguard
6
Warszawa, Mozarta 25
005
57
30
54
Carburetor
5
Warszawa, Chopina 3
006
59
20
32
Wheel
6
Warszawa, Mozarta 25
88
Engine
7
Warszawa, Bacha 3
21
Alternator
7
Warszawa, Bacha 3
PARTS_IN_WAREHOUSE
36
Relation ORDERS in the third normal form (3NF)
remove column not dependent upon primary key
No_order
IDsupplier
Diagram of functional
dependencies in the relation
SUPPLIER_ON_ORDER
Name_supplier
Address_supplier
IDpart
Diagram of functional
dependencies in the relation
PARTS_IN_WAREHOUSE
Name_part
Warehouse
Address_warehouse
No_order
IDpart
Qty
Diagram of functional
dependencies in the relation
PARTS_ON_ORDER
37
ORDER_TO_SUPPLIER
No_order
IDsupplier
001
300
002
400
003
500
004
600
005
300
006
300
3NF
No_order
IDsupplier
SUPPLIERS
IDsupplier
Name_ Supplier
Address_Supplier
300
VW
Wolfsburg, Rotestrasse 10
400
WSK
Świdnik, Kraszewskiego 5
500
VW
Antoninek, Słowackiego 2
600
FIAT
Bielsko-Biała, Mickiewicza 25
IDupplier
Name_supplier
Address_Supplier
WAREHOUSES
Warehouse
Address_Warehouse
5
Warszawa, Chopina 3
6
Warszawa, Mozarta 25
7
Warszawa, Bacha 3
Warehouse
Address_Warehouse
38
PARTS
PARTS_IN_WAREHOUSE
PARTS_ON_ORDER
as above
IDpart
Name_ part
21
Alternator
32
Wheel
53
Carburetor
54
Carburetor
57
Crankshaft
58
Mudguard
59
Mudguard
88
Engine
IDpart
Warehouse
53
5
57
5
58
6
59
6
54
5
32
6
88
7
21
7
3NF
IDpart
Name_part
IDpart
Warehouse
39
Example: ORDERS
40
Structured Query Language - SQL
Why to use SQL in addition to the Design View?
- not all SQL functions can be used from the Design View level
- SQL can be used in other applications (Excel, Word, Visual Basic)
- SQL is a standard query language which can be used outside the
Access program
One can easily switch between Design View and SQL View
SQL is a procedure language which tells what to do, and not
how to do
...
42
Sorting
SELECT PUBLISHERS
...
PubTel
FROM PUBLISHERS
ORDER BY PUBLISHERS
...
PubName AS [Publisher’s Name],
PUBLISHERS
...
PubName;
Publisher’s Name
Publisher’s Phone
Alpha Press
999-999-9999
Big House
123-456-7890
Small House
714-000-0000
44
Filtering
SELECT COUNT (ISBN) AS [How many books from Alpha Press?]
FROM BOOKS
WHERE (PubID=1);
How many books from Alpha Press?
6
SELECT COUNT(ISBN) AS [Number of books],
MIN(Price) AS Min_Price,
MAX(Price) AS Max_Price,
AVG(Price) AS Avg_Price
FROM BOOKS;
Number of books
Min_Price
Max_Price
Avg_Price
15
12
...
00 zł
29
...
Price
FROM BOOKS1
WHERE ((BOOKS1
...
Price= [BOOKS1]![Price]+1;
UPDATE BOOKS1
SET BOOKS1
...
Price)<20);
50
Queries based on multiple tables
SELECT Title, PubName, Price
FROM PUBLISHERS, BOOKS
WHERE PUBLISHERS
...
PubID
ORDER BY BOOKS
...
Title, PUBLISHERS
...
Price
FROM PUBLISHERS, BOOKS
WHERE PUBLISHERS
...
PubID
ORDER BY BOOKS
...
Title, PUBLISHERS
...
Price
FROM PUBLISHERS INNER JOIN BOOKS
ON PUBLISHERS
...
PubID
ORDER BY BOOKS
...
primarykey = TABLE2
...
Title) AS [Number of books],
PUBLISHERS
...
Price) AS [Average price]
FROM PUBLISHERS INNER JOIN BOOKS
ON PUBLISHERS
...
PubID
GROUP BY PUBLISHERS
...
Name;
53
What happens if WHERE is missing?
SELECT BOOKS
...
PubName, BOOKS
...
00 zł
Iliad
Alpha Press
25
...
00 zł
Iliad
Edition 2000
25
...
00 zł
Moby Dick
Alpha Press
49
...
00 zł
Moby Dick
Edition 2000
49
...
00 zł
On Liberty
Alpha Press
25
...
00 zł
On Liberty
Edition 2000
25
...
00 zł
Ulysses
Alpha Press
34
...
00 zł
Ulysses
Edition 2000
34
...
Result:
A direct product
of two tables
54
Inner join 3 many-to-many
SELECT BOOKS
...
ISBN, BOOKS
...
Year,
PUBLISHERS
...
AuName
FROM PUBLISHERS
INNER JOIN (BOOKS
INNER JOIN (AUTHORS
INNER JOIN [BOOKS/AUTHORS]
ON AUTHORS
...
AuID)
ON BOOKS
...
ISBN)
ON PUBLISHERS
...
PubID;
Title
ISBN
Price
Year
PubName
AuName
Iliad
0-103-45678-9
25
...
00 zł
1998
Small House
Melville
On Liberty
0-12-333433-3
25
...
00 zł
1999
Alpha Press
Joyce
Jane Eyre
0-12-345678-9
49
...
00 zł
1995
Small House
Snoopy
Balloon
0-321-32132-1
34
...
00 zł
1995
Small House
Sleepy
Main Street
0-55-123456-9
23
...
00 zł
1996
Small House
Jones
Macbeth
0-555-55555-9
12
...
00 zł
2000
Alpha Press
Shakespeare
55
Query Customers1
SELECT [First_name] & " " & [Surname] AS Person,
BOOKS
...
DateOut, [CUST/BOOKS]
...
ISBN = [CUST/BOOKS]
...
CustID = [CUST/BOOKS]
...
Title, WhoBorrowsID
...
DateBack
FROM CUSTOMER LEFT {outer} JOIN WhoBorrowsID
ON CUSTOMER
...
CustID;
WhoBorrows is a query
57
Query WhoBorrows
SELECT [CUST/BOOKS]
...
Title, [CUST/BOOKS]
...
DateBack
FROM BOOKS INNER JOIN [CUST/BOOKS]
ON BOOKS
...
ISBN;
58
NULL in a query
SELECT BOOKS
...
Title, [CUST/BOOKS]
...
DateBack
FROM BOOKS
LEFT JOIN [CUST/BOOKS] ON BOOKS
...
ISBN
WHERE
((([CUST/BOOKS]
...
DateBack) Is Null)) OR
((([CUST/BOOKS]
...
DateBack) Is Not Null))
ORDER BY BOOKS
...
ISBN) AS [Number of books],
Year([CUST/BOOKS]!DateOut) AS YearOut
INTO Table_NotReturned
FROM CUSTOMER INNER JOIN [CUST/BOOKS]
ON CUSTOMER
...
CustID
GROUP BY CUSTOMER!Surname & " " & CUSTOMER!First_name,
Year([CUST/BOOKS]!DateOut), [CUST/BOOKS]
...
DateBack) Is Null) AND
((Year([CUST/BOOKS]!DateOut))=[Give the year]))
ORDER BY CUSTOMER!Surname & " " & CUSTOMER!First_name;
Only SELECT
Creating a new table
60
Functional queries
Creating o copy of a table
SELECT *
INTO NotReturned2008
FROM Table_NotReturned;
Merging two tables
INSERT INTO Table_NotReturned
SELECT *
FROM NotReturned2008;
61
Creating reports
Characteristic features of a report:
•attractive form
•basic information in headers and footers
•information grouped and sorted
•graphical elements improving the form
Methods of creating reports:
•design view
•Wizard
•AutoReport: Columnar or Tabelar
Source of data: tables or queries
62
AutoReport
63
Report – design view
64
Toolbox
Combo box
Text box
List box
Label
Subreport
Image
Button
65
Database form
A form is an Access object
...
Data can be inserted, updated,
or deleted from a table using a Form object
...
For example, you may want to ask a user
for parameters before running a report
...
For
example, you may create a form where a user can select a form to
load, a report to run, etc
...
An unbound form does not have a RecordSource,
that doesn't mean it can't contain data, but the programmer will have
to bring that data in manually
...
The Form options quickly
create a form based upon a
table or query
...
71
Creating forms - adjustments
72
Using a form
Access to the existing records in
the table CUSTOMER
Input of a new record
73
Editing properties of a form
Properties icon:
Our original goal is to create a form for data purposes
...
Setting the „Data Entry” property to
„Yes” will only allow users to insert new records and modify
records created during that session
...
A new record is introduced
into the table CUSTOMER:
75
Security differences between Access
2007 and earlier versions of Access
Earlier versions:
-security levels (Low, Medium, or High),
-to run potentially unsafe code or not
...
Message Bar:
You can choose to trust or not trust the disabled
content in the database
...
•Trust the database permanently Place the database in a trusted
location — a folder on a drive or network that you mark as trusted
...
When you ignore the Message Bar, you
can still view the data in the database and use any components
in the database that Access has not disabled
...
Start Office Access 2007, and on the Getting Started with
Microsoft Office Access page, under Featured Online
Templates, click Assets to open the Assets template
...
In the File Name box, type a name for the new database, and
then click Download
...
3
...
The Microsoft Office
Security Options dialog box appears
...
Click Enable this content, and then click OK
...
Click the Microsoft Office Button
, and then click Access
Options
...
80
Click Trusted Locations
...
The Microsoft Office Trusted Location dialog box appears
...
In the Path box, type the file path and folder name of the location that
you want to set as a trusted source, or click Browse to locate a folder
...
Note If you want to allow trusted network locations, in the Trust
Center dialog box, click Allow Trusted Locations on my network
(not recommended)
...
Point to Save As, and under Save the database in another
format, click one of the available options
...
If you do not have a database open
Locate and copy your database
83
Use a database password to encrypt an
Office Access 2007 database
The encryption tool in Office Access 2007 combines and improves
on two older tools — database passwords and encoding
...
On the Database Tools tab, in the Database Tools group, click
Encrypt with Password
...
85
Decrypt and open a database
1
...
2
...
3
...
86
Remove a password
Open the database in Exclusive mode
...
87
Package, sign, and distribute
an Access 2007 database
Access 2007 makes it easier and faster to sign and distribute a
database
...
accdb file or
...
•ways to convey trust
•add only one database to a package
•signs all of the objects in your databases
•the process also compresses the package file
•a security certificate
88
Create a self-signed certificate
In Microsoft Windows, click the Start button, point to All
Programs, point to Microsoft Office, point to Microsoft Office
Tools, and then click Digital Certificate for VBA Projects
89
Create a self-signed certificate
90
Create a self-signed certificate
91
Create a signed package
Open the database
Microsoft Office Button ,
point to Publish, and then
click Package and Sign
Select a digital certificate and
then click OK
The Create Microsoft Office
Access Signed Package
dialog box appears
92
Create a signed package
Select a location for your signed
database package
...
Access creates the
...
Click the Microsoft Office Button , and then click Open
...
Select Microsoft Office Access Signed Packages (*
...
3
...
accdc file, select the file, and
then click Open
...
Do one of the following:
•If you have earlier chosen to trust the digital certificate that
was applied to the deployment package, the Extract
Database To dialog box appears
...
•If you have not yet chosen to trust the digital certificate, an
advisory message appears
...
If you trust any certificate
from that provider, click Trust all
from publisher and then click
OK
...
) code, you can hide that code by saving your
Microsoft Office Access database (database: A collection of data related to
a particular subject or purpose
...
) in the
...
Saving a database as an
...
Your VBA code retains its
functionality, but the code cannot be viewed or edited
...
97
Microsoft Access Security
The Security Wizard in MS Access is a very useful tool
...
The 12 steps will describe how to secure a database
from start to finish
...
You may secure any database that has been created while joined to the
System
...
2
...
MDW)
3
...
4
...
Modify the Admins group by adding the new administrator and removing the
original Admin account
...
Re-log into Access as the new workgroup administrator that you created
previously
...
Set up a password for the new workgroup administrator
...
Run the Security wizard under Tools | Security | User - Level Security
...
Create any additional group accounts
...
Create any additional user accounts
...
Set up the database object's permissions
...
Any new databases that you create will already be secure
...
MDW file
A Workgroup Information File (*
...
It stores the user
names, group names, and passwords
...
Its
main purpose is to verify that a user is really who
they say they are
...
, are stored in
each MDB file
...
mdw is the default
workgroup filename created when you install MS
Access
...
If the log in is successful, MS Access continues
loading and the user never realizes that they were logged
in as Admin
...
A PID can be any text or numbers
up to 20 characters long
...
101
The database
...
After the user has been
verified, the workgroup information file’s job is done
...
The MDB will have a list of user id’s and the privileges that
each user may have