Presentation is loading. Please wait.

Presentation is loading. Please wait.

Database Management Concepts

Similar presentations


Presentation on theme: "Database Management Concepts"— Presentation transcript:

1 Database Management Concepts
A2 Computing 3.9 Databases F453

2 Key Points Flat & Relational Entity Relationships Normalisation
Primary, Secondary, Foreign Keys Data Consistency Data Integrity Data Redundancy DBMS Data Dictionary DDL DML SQL

3 Database Terminology A database is…
A collection of data/tables/records Table names are also known as ENTITIES A record is… A collection of completed fields about a particular entity. A row in a database. TUPLE A field is…. Part of a record containing one specific data item. Eg. Name, Address, DOB, Genre ATTRIBUTE

4 Primary and Foreign Key
A Primary Key is a Unique Identifier within a table. Foreign key is a field in one table which is also the primary key of another table. Foreign keys are used to establish a relationship between the main table and other subsidiary tables.

5 Secondary Key A field that is unique to that record that isn’t the primary key, but it could be. Eg… EmployeeID, Name, NINumber, PhoneNo Primary Key Secondary Key

6 Flat File Databases FirstName Surname
ContactNo DateOfBirth Cost InstructorName John Hainsworth 25/05/1989 25 20 Hansworth 15 Tony Hodson 07/09/1984 Mike Setvenson 15/11/1990 Denton Sharon Hart 22/04/1985 Richard Ellis 12/08/1988 Muller Lucie Harris 14/12/1990 Beccy Lock 03/06/1984 Omar Ibqual 05/07/1991 Gareth Jones 26/06/1985 Seb 21/06/1986 10 Harries

7 Problems with Flatfile Databases
Duplicate records Spelling mistakes could be made If John changed his telephone number, it would have to be changed 3 times

8 Redundancy and Integrity
Data Redundancy Unnecessary duplication of data Data Integrity The consistency of data How correct it is

9 Relationships One to one An instructor teaches a course One to many
An instructor teaches more than one course Many to many Activity Instructor Activity Instructor Activity Instructor

10 Normalisation Breaks things down to smallest possible units
1st Normal Form 2nd Normal Form 3rd Normal Form

11 Problems with Data Redundancy and Integrity
Un-normalised StudentID Forename Surname ActivityID Activity Instructor 100012 David Jackson 1 4 3 Riding Windsurfing Climbing Susie Holman Jim Jackson David Smith 100011 Susie Thomas 100014 Jerry Kilmer 2 Windsurding 4x4 Driving Tom Wilson 100016 Lisa Terry Data is un-normalised. Problems with Data Redundancy and Integrity

12 1st Normal Form No repeating attributes Still has Data Redundancy
Primary Key StudentID Forename Surname ActivityID 100012 David Jackson 1 4 3 100011 Susie Thomas 100014 Jerry Kilmer 2 100016 Lisa Terry Foreign Key ActivityID Activity Instructor 1 Riding Susie Holman 2 4x4 Driving Tom Wilson 3 Climbing David Smith 4 Windsurfing Jim Jackson No repeating attributes Still has Data Redundancy Repeating Student Names Primary Key

13 2nd Normal Form Use Link Table StudentID Forename Surname 100012 David
Jackson 100011 Susie Thomas 100014 Jerry Kilmer 100016 Lisa Terry ActivityID Activity Instructor 1 Riding Susie Holman 2 4x4 Driving Tom Wilson 3 Climbing David Smith 4 Windsurfing Jim Jackson StudentID ActivityID 100012 1 3 100014 2 100016 Use Link Table

14 3rd Normal Form StudentID Forename Surname 100012 David Jackson 100011
Susie Thomas 100014 Jerry Kilmer 100016 Lisa Terry ActivityID Activity InstructorID 1 Riding 2 4x4 Driving 3 Climbing 4 Windsurfing Booking ID StudentID ActivityID 1 100012 2 3 100014 4 100016 InstructorID Instructor 1 Susie Holman 2 Tom Wilson 3 David Smith 4 Jim Jackson

15 Entity Relationship Diagram 3NF
3NF – Never have a Many to Many Relationship No repeating data fields (aside from primary and foreign keys) Student Booking Activity Instructor

16 Database Management System
DBMS Separates the physical data and the user interface that accesses the data Many different employees accessing the same data via a server Allows program-data independence

17 Problems with Sharing Data
Many users access the same data file Concurrent Access What if 2 users are trying to edit the same data item simultaneously? Database Management System Record Locking

18 DBMS example DBMS is a ‘layer’ of software that operates between the data and the applications that access the data

19 Role of DBMS Software that acts as an interface between user and database Allows the definition / creation / maintenance / manipulation of the database Creation and maintenance of the data dictionary Backup and recovery Security

20 Software used to control access to data
DBMS Database Management System provides an interface between the data and the user Software used to control access to data

21 Three levels of DBMS External Conceptual Internal
The users view of the data. The complexities of the data are hidden from the user so this view is the front-end. Conceptual The entities, structure, attributes and relationships. Internal This describes how the data is stored physically and how it will be accessed.

22 Advantages & Disadvantages of DBMS
Security Data Independence The data is independent from the programs and applications that interact with it Data is easily shared and distributed Disadvantages Expensive Closely monitor security System failure

23 Items in Data Dictionary
A file containing descriptions of data in database used by database managers when altering database structure names of tables characteristics of data (e.g. length, data type) relationships between data identifies primary keys identifies foreign keys defines access rights

24 Data definition language (DDL)
DDL is the language used to control the structure of the database (Schema) It is used to create new entities, attributes, keys and relationships. Create and manage Data Dictionary Access Rights Create Database Create Table PrimaryKey = PupilID

25 DDL Example

26 Common DDL commands

27 Data Manipulation Language - DML
Allows control and modification and manipulation of Data Insert Delete Amend Update Retrieve SQL - Query

28 DDL controls the data structure and DML controls the actual data
DDL & DML DDL controls the data structure and DML controls the actual data

29 Structured Query Language (SQL)
SQL is a 4th generation programming language that is used to create databases and insert, update and extract data Syntax gives a command word that tells system what operation to carry out instructions to tell system what parts of database to carry operation out on SQL is a DDL and a DML because it allows applications to query a database as well as inserting & updating data

30 Structured Query Language
Query a database using the following SQL commands: SELECT FROM WHERE ORDER BY

31 SQL Example Consider the table FORM To delete 7C from the table:
DELETE FROM Form WHERE Formname = ‘7C’ To insert a new row: INSERT INTO Form VALUES (‘7E’, ‘Mr Post’, 205) 205 doesn’t need quotes because it is numeric Formname Formteacher Formroom 7A Mr Brown 102 7B Mr Collins 301 7C Miss Jones 107 7D Mrs Smith 201

32 To create SQL reports Formname Formteacher Formroom 7A Mr Brown 102 7B Mr Collins 301 7C Miss Jones 107 7D Mrs Smith 201 7E Mr Post 205 SELECT * FROM Form WHERE Formteacher = “Mrs Smith” This gives: 7D Mrs Smith 201 SELECT Formroom from Form WHERE Formteacher = “Mrs Smith” This gives: 201 SELECT Formname FROM Form Where Formroom < 200 What does this do?


Download ppt "Database Management Concepts"

Similar presentations


Ads by Google