mark dixon 1 21 – databases: multiple tables and writing data

47
Mark Dixon 1 21 – Databases: Multiple Tables and Writing Data

Upload: reynold-murphy

Post on 05-Jan-2016

218 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Mark Dixon 1 21 – Databases: Multiple Tables and Writing Data

Mark Dixon 1

21 – Databases: Multiple Tablesand Writing Data

Page 2: Mark Dixon 1 21 – Databases: Multiple Tables and Writing Data

Mark Dixon 2

Questions: Databases• How many records are in the following table?• How many fields does the following table have?

64

CountryName Population Land Mass Continent

UK 60776238 241590 EuropeSpain 40448191 499542 EuropeGermany 82400996 349223 EuropeEgypt 80335036 995450 AfricaKenya 36913721 569250 AfricaChina 1321851888 9326410 Asia

Page 3: Mark Dixon 1 21 – Databases: Multiple Tables and Writing Data

Mark Dixon 3

Questions: SQL• Write an SQL statement to display the name and

land mass of all countries in Africa.

SELECT Name, Land MassFROM Country WHERE Continent = 'Africa';

CountryName Population Land Mass Continent

UK 60776238 241590 EuropeSpain 40448191 499542 EuropeGermany 82400996 349223 EuropeEgypt 80335036 995450 AfricaKenya 36913721 569250 AfricaChina 1321851888 9326410 Asia

Page 4: Mark Dixon 1 21 – Databases: Multiple Tables and Writing Data

Mark Dixon 4

Questions: HTML in VB• Are these correct (assume variables and

fields exist)?

f = f + r("Description")

h = h + r("<br />Name")

a = "<p>" + a "</p>"

html = html + <img src=face.gif />

h = "<table>" + h + "</table>"

Page 5: Mark Dixon 1 21 – Databases: Multiple Tables and Writing Data

Mark Dixon 5

Advice• Don’t

– put anything on desktop– Especially database

Page 6: Mark Dixon 1 21 – Databases: Multiple Tables and Writing Data

Mark Dixon 6

Session Aims & Objectives• Aims

– To deal with multiple tables– To write data to databases

• Objectives,by end of this week’s sessions, you should be able to:

– identify a suitable primary key for a table– identify duplicated data in a single table– split that table to reduce data redundancy,

using a suitable foreign key– generate SQL statements to (temporarily)

join tables, and use these in your code– use SQL to write data into database

Page 7: Mark Dixon 1 21 – Databases: Multiple Tables and Writing Data

Mark Dixon 7

Data Duplication• Look for repeating data:

Track Title Artist Name Country

Paranoid Black Sabbath UK

Falling in Love Aerosmith US

Pink Aerosmith US

Love in an Elevator Aerosmith US

Smooth Criminal Alien Ant Farm US

Meaning of Life Disturbed US

The Game Disturbed US

Voices Disturbed US

Down with the Sickness Disturbed US

Track

Page 8: Mark Dixon 1 21 – Databases: Multiple Tables and Writing Data

Mark Dixon 8

Problem: Data Duplication• takes up lots of space

• can become inconsistent (misspellings)

• difficult to change (need to change each instance)

• difficult to search (misspellings)

Page 9: Mark Dixon 1 21 – Databases: Multiple Tables and Writing Data

Mark Dixon 9

Solution: Normalisation• Part of database design

• Process of breaking data down (splitting)

• Codd– 7 stages of normalisation

• Mathematical• Difficult to apply stages• Most professionals do it instinctively

Page 10: Mark Dixon 1 21 – Databases: Multiple Tables and Writing Data

Mark Dixon 10

Relations (tables)

Track Title

Paranoid

Falling in Love Aerosmith US

Pink Aerosmith US

Love in an Elevator Aerosmith US

Smooth Criminal Alien Ant Farm US

Meaning of Life Disturbed US

The Game Disturbed US

Voices Disturbed US

Down with the Sickness Disturbed US

Track

Artist Name Country

Black Sabbath UK

Page 11: Mark Dixon 1 21 – Databases: Multiple Tables and Writing Data

Mark Dixon 11

Relations (tables)

Track Title

Paranoid

Falling in Love Aerosmith US

Pink Aerosmith US

Love in an Elevator Aerosmith US

Smooth Criminal Alien Ant Farm US

Meaning of Life Disturbed US

The Game Disturbed US

Voices Disturbed US

Down with the Sickness Disturbed US

Track

Artist ID

1

Artist

Artist Name Country

Black Sabbath UK

ID Artist Name Country

1 Black Sabbath UK

Page 12: Mark Dixon 1 21 – Databases: Multiple Tables and Writing Data

Mark Dixon 12

Relations (tables)

Track Title

Paranoid

Falling in Love

Pink Aerosmith US

Love in an Elevator Aerosmith US

Smooth Criminal Alien Ant Farm US

Meaning of Life Disturbed US

The Game Disturbed US

Voices Disturbed US

Down with the Sickness Disturbed US

Track

Artist ID

1

Artist

ID Artist Name Country

1 Black Sabbath UKAerosmith US

ID Artist Name Country

1 Black Sabbath UK

2 Aerosmith US2

Page 13: Mark Dixon 1 21 – Databases: Multiple Tables and Writing Data

Mark Dixon 13

Relations (tables)

Track Title

Paranoid

Falling in Love

Pink

Love in an Elevator Aerosmith US

Smooth Criminal Alien Ant Farm US

Meaning of Life Disturbed US

The Game Disturbed US

Voices Disturbed US

Down with the Sickness Disturbed US

Track

Artist ID

1

2

2

Artist

ID Artist Name Country

1 Black Sabbath UK

2 Aerosmith US

Page 14: Mark Dixon 1 21 – Databases: Multiple Tables and Writing Data

Mark Dixon 14

Relations (tables)

Track Title

Paranoid

Falling in Love

Pink

Love in an Elevator

Smooth Criminal Alien Ant Farm US

Meaning of Life Disturbed US

The Game Disturbed US

Voices Disturbed US

Down with the Sickness Disturbed US

Track

Artist ID

1

2

2

2

Artist

ID Artist Name Country

1 Black Sabbath UK

2 Aerosmith US

Page 15: Mark Dixon 1 21 – Databases: Multiple Tables and Writing Data

Mark Dixon 15

Relations (tables)

Track Title

Paranoid

Falling in Love

Pink

Love in an Elevator

Smooth Criminal

Meaning of Life Disturbed US

The Game Disturbed US

Voices Disturbed US

Down with the Sickness Disturbed US

Track

Artist ID

1

2

2

2

3

Artist

ID Artist Name Country

1 Black Sabbath UK

2 Aerosmith US

3 Alien Ant Farm US

Page 16: Mark Dixon 1 21 – Databases: Multiple Tables and Writing Data

Mark Dixon 16

Relations (tables)

Track Title

Paranoid

Falling in Love

Pink

Love in an Elevator

Smooth Criminal

Meaning of Life

The Game Disturbed US

Voices Disturbed US

Down with the Sickness Disturbed US

Track

Artist ID

1

2

2

2

3

4

Artist

ID Artist Name Country

1 Black Sabbath UK

2 Aerosmith US

3 Alien Ant Farm US

4 Disturbed US

Page 17: Mark Dixon 1 21 – Databases: Multiple Tables and Writing Data

Mark Dixon 17

Relations (tables)

Track Title

Paranoid

Falling in Love

Pink

Love in an Elevator

Smooth Criminal

Meaning of Life

The Game

Voices Disturbed US

Down with the Sickness Disturbed US

Track

Artist ID

1

2

2

2

3

4

4

Artist

ID Artist Name Country

1 Black Sabbath UK

2 Aerosmith US

3 Alien Ant Farm US

4 Disturbed US

Page 18: Mark Dixon 1 21 – Databases: Multiple Tables and Writing Data

Mark Dixon 18

Relations (tables)

Track Title

Paranoid

Falling in Love

Pink

Love in an Elevator

Smooth Criminal

Meaning of Life

The Game

Voices

Down with the Sickness Disturbed US

Track

Artist ID

1

2

2

2

3

4

4

4

Artist

ID Artist Name Country

1 Black Sabbath UK

2 Aerosmith US

3 Alien Ant Farm US

4 Disturbed US

Page 19: Mark Dixon 1 21 – Databases: Multiple Tables and Writing Data

Mark Dixon 19

Relations (tables)

Track Title Artist ID

Paranoid 1

Falling in Love 2

Pink 2

Love in an Elevator 2

Smooth Criminal 3

Meaning of Life 4

The Game 4

Voices 4

Down with the Sickness 4

Track Artist

ID Artist Name Country

1 Black Sabbath UK

2 Aerosmith US

3 Alien Ant Farm US

4 Disturbed US

PrimaryKey

ForeignKey

Page 20: Mark Dixon 1 21 – Databases: Multiple Tables and Writing Data

Mark Dixon 20

Question: Keys

Name Population Land Mass ContIDUK 60776238 241590 1

Spain 40448191 499542 1Germany 82400996 349223 1

Egypt 80335036 995450 2Kenya 36913721 569250 2China 1321851888 9326410 3

Country Continent

ID Name

1 Europe

2 Africa

3 Asia

• Name a Primary Key

• Name a Foreign Key

ID in the Continent table

ContID in the Country table

Page 21: Mark Dixon 1 21 – Databases: Multiple Tables and Writing Data

Mark Dixon 21

People Database (with Hobbies)ID Surname Forenames Phone email

1 Dixon Mark 01752 232556 [email protected]

2 Smith John 01752 111111 [email protected]

3 Jones Sally 01752 888888 [email protected]

4 Bloggs Fred 01752 123123 [email protected]

5 Anderson Genny 01752 987987 [email protected]

HobbyID Description PersonID

1 Archery 1

2 Herpetology 1

3 Music 1

4 Football 2

5 Rugby 2

6 Hitting people with swords 1

Hobby

Person

Page 22: Mark Dixon 1 21 – Databases: Multiple Tables and Writing Data

Mark Dixon 22

Entity-relationship diagrams• Each table in db

– stores details of entity• shown as rectangular box

•Relationships between tables

–represent relationships between entities

•shown as line between entities (boxes)

Person Hobby

Page 23: Mark Dixon 1 21 – Databases: Multiple Tables and Writing Data

Mark Dixon 23

Relationship Types• One-to-one

• One-to-many

• Many-to-one

• Many-to-many– (can't be implemented in relational database)

A B

A B

A B

A B

Page 24: Mark Dixon 1 21 – Databases: Multiple Tables and Writing Data

Mark Dixon 24

Question: Which relationship type?

ID Surname Forenames Phone email

1 Dixon Mark 01752 232556 [email protected]

2 Smith John 01752 111111 [email protected]

3 Jones Sally 01752 888888 [email protected]

4 Bloggs Fred 01752 123123 [email protected]

5 Anderson Genny 01752 987987 [email protected]

HobbyID Description PersonID

1 Archery 1

2 Herpetology 1

3 Music 1

4 Football 2

5 Rugby 2

6 Hitting people with swords 1

Hobby

Person

Person

Hobby

Page 25: Mark Dixon 1 21 – Databases: Multiple Tables and Writing Data

Mark Dixon 25

SQL: Joining tables

SELECT * FROM Person, Hobby;

Two tables

Cartesian set(all recordcombinations):

ID Surname Forenames Phone email HobbyID Description PersonID1 Dixon Mark 01752 232556 [email protected] 7 Archery 12 Smith John 01752 111111 [email protected] 7 Archery 13 Jones Sally 01752 888888 [email protected] 7 Archery 14 Bloggs Fred 01752 123123 [email protected] 7 Archery 15 Anderson Genny 01752 987987 [email protected] 7 Archery 11 Dixon Mark 01752 232556 [email protected] 8 Herpetology 12 Smith John 01752 111111 [email protected] 8 Herpetology 13 Jones Sally 01752 888888 [email protected] 8 Herpetology 14 Bloggs Fred 01752 123123 [email protected] 8 Herpetology 15 Anderson Genny 01752 987987 [email protected] 8 Herpetology 11 Dixon Mark 01752 232556 [email protected] 9 Music 12 Smith John 01752 111111 [email protected] 9 Music 13 Jones Sally 01752 888888 [email protected] 9 Music 14 Bloggs Fred 01752 123123 [email protected] 9 Music 15 Anderson Genny 01752 987987 [email protected] 9 Music 11 Dixon Mark 01752 232556 [email protected] 10 Football 22 Smith John 01752 111111 [email protected] 10 Football 23 Jones Sally 01752 888888 [email protected] 10 Football 24 Bloggs Fred 01752 123123 [email protected] 10 Football 25 Anderson Genny 01752 987987 [email protected] 10 Football 21 Dixon Mark 01752 232556 [email protected] 11 Rugby 22 Smith John 01752 111111 [email protected] 11 Rugby 23 Jones Sally 01752 888888 [email protected] 11 Rugby 24 Bloggs Fred 01752 123123 [email protected] 11 Rugby 25 Anderson Genny 01752 987987 [email protected] 11 Rugby 21 Dixon Mark 01752 232556 [email protected] 12 Hitting people with swords 12 Smith John 01752 111111 [email protected] 12 Hitting people with swords 13 Jones Sally 01752 888888 [email protected] 12 Hitting people with swords 14 Bloggs Fred 01752 123123 [email protected] 12 Hitting people with swords 15 Anderson Genny 01752 987987 [email protected] 12 Hitting people with swords 1

Page 26: Mark Dixon 1 21 – Databases: Multiple Tables and Writing Data

Mark Dixon 26

SQL: Joining tables

SELECT *FROM Person, HobbyWHERE Person.ID = Hobby.PersonID;

Two tables

Matching recordsID Surname Forenames Phone email HobbyID Description PersonID

1 Dixon Mark 01752 232556 [email protected] 1 Archery 1

1 Dixon Mark 01752 232556 [email protected] 2 Herpetology 1

1 Dixon Mark 01752 232556 [email protected] 3 Music 1

1 Dixon Mark 01752 232556 [email protected] 6 Hitting people with swords 1

2 Smith John 01752 111111 [email protected] 4 Football 2

2 Smith John 01752 111111 [email protected] 5 Rugby 2

Page 27: Mark Dixon 1 21 – Databases: Multiple Tables and Writing Data

Mark Dixon 27

SQL: Joining tables

ID Surname

1 Dixon

1 Dixon

1 Dixon

1 Dixon

2 Smith

2 Smith

SELECT ID, SurnameFROM Person, HobbyWHERE Person.ID = Hobby.PersonID;

Page 28: Mark Dixon 1 21 – Databases: Multiple Tables and Writing Data

Mark Dixon 28

Question: SQL Joining Tables• Write an SQL query to join the following:

Track Title Artist ID

Paranoid 1

Falling in Love 2

Pink 2

Love in an Elevator 2

Smooth Criminal 3

Meaning of Life 4

The Game 4

Voices 4

Down with the Sickness 4

Track Artist

ID Artist Name Country

1 Black Sabbath UK

2 Aerosmith US

3 Alien Ant Farm US

4 Disturbed US

Page 29: Mark Dixon 1 21 – Databases: Multiple Tables and Writing Data

Mark Dixon 29

SQL: More• Loads more:

– group by– aggregate functions: average, count– inner joins– outer joins (left and right)

• Have a look at:– http://www.w3schools.com/sql/sql_join.asp

Page 30: Mark Dixon 1 21 – Databases: Multiple Tables and Writing Data

Mark Dixon 30

Example: Person v1 (Specification)

• User requirement:– Display people's details from database online– need 2 pages:

smithjonesdixon

list of people

jonessally

person's details

Page 31: Mark Dixon 1 21 – Databases: Multiple Tables and Writing Data

Mark Dixon 31

Example: PeopleList.aspx v1<%@ Page Language="VB" %><%@ Import Namespace="System.Data.OleDB" %><script runat="server">

Sub Page_Load() Dim cs As String = "Provider=Microsoft.ACE.OLEDB.12.0;" + _ "Data Source=" + Server.MapPath("People.accdb") + ";" Dim cn As New OleDbConnection(cs) Dim cmd As OleDbCommand Dim r As OleDbDataReader Dim s As String cmd = New OleDbCommand("SELECT * FROM Person;", cn) cn.Open() r = cmd.ExecuteReader() s = "" Do While r.Read() s = s & r("Surname") & "<br />" Loop cn.Close parData.InnerHtml = s End Sub</script>

<html> <head><title></title></head> <body> <p id="parData" runat="server"></p> </body></html>

Page 32: Mark Dixon 1 21 – Databases: Multiple Tables and Writing Data

Mark Dixon 32

Example: PeopleList.aspx v2<%@ Page Language="VB" %><%@ Import Namespace="System.Data.OleDB" %><script runat="server">

Sub Page_Load() Dim cs As String = "Provider=Microsoft.ACE.OLEDB.12.0;" + _ "Data Source=" + Server.MapPath("People.accdb") + ";" Dim cn As New OleDbConnection(cs) Dim cmd As OleDbCommand Dim r As OleDbDataReader Dim s As String cmd = New OleDbCommand("SELECT * FROM Person;", cn) cn.Open() r = cmd.ExecuteReader() s = "" Do While r.Read() s = s & "<a href='Person.aspx?id=" & r("ID") & "'>" s = s & r("Surname") & "</a><br />" Loop cn.Close parData.InnerHtml = s End Sub</script>

<html> <head><title></title></head> <body> <p id="parData" runat="server"></p> </body></html>

now links

Page 33: Mark Dixon 1 21 – Databases: Multiple Tables and Writing Data

Mark Dixon 33

Example: Person.aspx v2<%@ Page Language="VB" %><%@ Import Namespace="System.Data.OleDB" %><script runat="server">

Sub Page_Load() Dim cs As String = "Provider=Microsoft.ACE.OLEDB.12.0;" + _ "Data Source=" + Server.MapPath("People.accdb") + ";" Dim sql As String Dim cn As New OleDbConnection(cs) Dim cmd As OleDbCommand Dim r As OleDbDataReader Dim s As String sql = "SELECT * FROM Person WHERE id=" & Request.QueryString("id") cmd = New OleDbCommand(sql, cn) cn.Open() r = cmd.ExecuteReader() s = "" If r.Read() Then txtSurname.Value = r("Surname") End If cn.Close() End Sub</script>

<html> <head><title></title></head> <body> <a href="PeopleList2.aspx">Back to People List</a><br /> <form runat="server"> Surname: <input id="txtSurname" runat="server" /><br /> <input id="btnSave" type="submit" value="Save" runat="server" /> </form> </body></html>

reads querystring(from previous page)

displays data forselected record only

Page 34: Mark Dixon 1 21 – Databases: Multiple Tables and Writing Data

Mark Dixon 34

Example: Person v2 (Specification)

• User requirement:Display person’s details from database online

– Change surname and save to database

Page 35: Mark Dixon 1 21 – Databases: Multiple Tables and Writing Data

Mark Dixon 35

Changing Data• SQL

– INSERT: inserts a new recordINSERT INTO Person (Surname, Age) VALUES ('Smith', 21);

– UPDATE: makes changes to specified recordUPDATE Person Set Surname = 'Smith', Age = 21 WHERE id = 14;

– DELETE: deletes specified recordDELETE FROM Person WHERE id = 14

Page 36: Mark Dixon 1 21 – Databases: Multiple Tables and Writing Data

Mark Dixon 36

WARNING!!• All changes permanent (no undo)

• WHERE clause is CRITICAL

DELETE FROM Person;

Will delete ALL records in table

Page 37: Mark Dixon 1 21 – Databases: Multiple Tables and Writing Data

Mark Dixon 37

Example: Person.aspx v3 (error)<%@ Page Language="VB" %><%@ Import Namespace="System.Data.OleDB" %><script runat="server">Dim cs As String = "Provider=Microsoft.ACE.OLEDB.12.0;" + _ "Data Source=" + Server.MapPath("People.accdb") + ";"Dim cn As New OleDbConnection(cs)

Sub Page_Load() Dim sql As String Dim cmd As OleDbCommand Dim r As OleDbDataReader sql = "SELECT * FROM Person WHERE id=" & Request.QueryString("id") cmd = New OleDbCommand(sql, cn) cn.Open() r = cmd.ExecuteReader() If r.Read() Then txtSurname.Value = r("Surname") End If cn.Close() End Sub Sub btnSave_Click(s As Object, e As EventArgs) Handles btnSave.ServerClick Dim cmd As OleDbCommand Dim sql As String sql = "UPDATE [Person] " + _ " SET [Surname] = '" + txtSurname.Value + "'" + _ " WHERE id = " & Request.QueryString("id") & ";" cmd = New OleDbCommand(sql, cn) cn.Open() cmd.ExecuteNonQuery() cn.Close End Sub</script>

Save buttonexecutes SQL UPDATE

PROBLEM: Page_Loadre-reads old surname first

Page 38: Mark Dixon 1 21 – Databases: Multiple Tables and Writing Data

Mark Dixon 38

Example: Person.aspx v3b<%@ Page Language="VB" %><%@ Import Namespace="System.Data.OleDB" %><script runat="server">Dim cs As String = "Provider=Microsoft.ACE.OLEDB.12.0;" + _ "Data Source=" + Server.MapPath("People.accdb") + ";"Dim cn As New OleDbConnection(cs)

Sub Page_LoadComplete(s As Object, e As EventArgs) Dim sql As String Dim cmd As OleDbCommand Dim r As OleDbDataReader sql = "SELECT * FROM Person WHERE id=" & Request.QueryString("id") cmd = New OleDbCommand(sql, cn) cn.Open() r = cmd.ExecuteReader() If r.Read() Then txtSurname.Value = r("Surname") End If cn.Close() End Sub Sub btnSave_Click(s As Object, e As EventArgs) Handles btnSave.ServerClick Dim cmd As OleDbCommand Dim sql As String sql = "UPDATE [Person] " + _ " SET [Surname] = '" + txtSurname.Value + "'" + _ " WHERE id = " & Request.QueryString("id") & ";" cmd = New OleDbCommand(sql, cn) cn.Open() cmd.ExecuteNonQuery() cn.Close End Sub</script>

Save buttonexecutes SQL UPDATE

Fix: Use Page_LoadComplete

Page 39: Mark Dixon 1 21 – Databases: Multiple Tables and Writing Data

Mark Dixon 39

Example: Person.aspx v3cDim cs As String = "Provider=Microsoft.ACE.OLEDB.12.0;" + _ "Data Source=" + Server.MapPath("People.accdb") + ";"Dim cn As New OleDbConnection(cs)Dim sql As String

Sub Page_Load() cn.Open() End Sub

Sub btnSave_Click(s As Object, e As EventArgs) Handles btnSave.ServerClick Dim cmd As OleDbCommand sql = "UPDATE [Person] " + _ " SET [Surname] = '" + txtSurname.Value + "'" + _ " WHERE id = " & Request.QueryString("id") & ";" cmd = New OleDbCommand(sql, cn) cmd.ExecuteNonQuery() End Sub

Sub Page_LoadComplete(s As Object, e As EventArgs) Dim cmd As OleDbCommand Dim r As OleDbDataReader sql = "SELECT * FROM Person WHERE id=" & Request.QueryString("id") cmd = New OleDbCommand(sql, cn) r = cmd.ExecuteReader() If r.Read() Then txtSurname.Value = r("Surname") End If cn.Close() End Sub

• Page_Load: first• Click events• Page_LoadComplete:

last

Page 40: Mark Dixon 1 21 – Databases: Multiple Tables and Writing Data

Mark Dixon 40

Tutorial Exercise: Person• Task 1: Get the Person (v1) example from the lecture

working.• Task 2: Modify your code, so that forename is displayed as

well as surname (use a table).• Task 3: Get the Person (v2 and v3) example from the

lecture working.• Task 3: Modify your code, so that a line of text is displayed

confirming that data has been saved.• Task 4: Modify your code, so that an add button is

included, which allows a new record to be added.• Task 5: Modify your code, so that a delete button is

included, which allows the current record to be deleted.

Page 41: Mark Dixon 1 21 – Databases: Multiple Tables and Writing Data

Mark Dixon 41

Tutorial Exercise: Music• Task 1: Create the Music database (from the lecture) with the Track

and Artist tables.• Task 2: Create a web page to display a list of Artists.• Task 4: Change that web page, so that each artist name is a link to

another page, which displays all the tracks by that artist. Hint: Use query strings to pass the artist ID between pages.

Page 42: Mark Dixon 1 21 – Databases: Multiple Tables and Writing Data

Mark Dixon 42

How To: Database Permissions• Generally

– Read: works by default– Write: requires permissions

• Asp.Net pages run as user:– Visual Studio

• Logged in user (few problems)

– IIS• ASP.Net Account• NETWORKSERVICE (Server 2003)• IIS APPPOOL\DefaultAppPool (Windows 7)

Page 43: Mark Dixon 1 21 – Databases: Multiple Tables and Writing Data

Mark Dixon 43

How To: Database Permissions 1• In order for ASP to

write to a database– Need to give write

access account for database file (People.accdb)

• Right-click on file in File Explorer

• Click Properties• Click Security tab• Click Edit button

Page 44: Mark Dixon 1 21 – Databases: Multiple Tables and Writing Data

Mark Dixon 44

How To: Database Permissions 2• Click Add button

Page 45: Mark Dixon 1 21 – Databases: Multiple Tables and Writing Data

Mark Dixon 45

How To: Database Permissions 3• Click Advanced

button

Page 46: Mark Dixon 1 21 – Databases: Multiple Tables and Writing Data

Mark Dixon 46

•ClickFind button

Clickuser

ClickOK button

How To: Database Permissions 4

Page 47: Mark Dixon 1 21 – Databases: Multiple Tables and Writing Data

Mark Dixon 47

How To: Database Permissions 5• Select Internet

Guest Account

• Ensure writeaccess is on