Presentation on theme: "1 Information Systems: Higher Database Systems. 2 AdamsAndrea D64 Carluke Street,JamestownGlasgow0141 092 7721 BairdHamish J7 Cedar Walk,Aberdeen01224."— Presentation transcript:
1 Information Systems: Higher Database Systems
2 AdamsAndrea D64 Carluke Street,JamestownGlasgow BairdHamish J7 Cedar Walk,Aberdeen DonaldLewisY8 Walker Road,Torry Aberdeen HastingsPaulI12 Seaview Terrace,Aviemore KindShona E159 Broomhill CourtAberdeen LeesBrianKRanchRock, ClearanceGlasgow RobertsonRoddyP254 North Road, CulterAberdeen St.JohnIanW18 Wilson Street,MuirTain HolmanClareC16a David HallElgin WilliamsKirstenA16 West HillsideEdinburgh Table DonaldLewisY8 Walker Road, TorryAberdeen A Simple Database A flat-file database contains only one table Very simple structure to the data Made up of records and fields
3 A Relational Database Data is stored in a set of tables Tables are joined by relational links This reduces duplication of data in database Also allows greater flexibility and efficiency
4 Tables in a Relational Database
5 Producing a Relational Database Analysis identify and organise data identify functions (I/P/O)identify functions Design create database structures (including keys)create database structures specify the characteristics of data and validity checks.specify the characteristics of data and validity checks Implementation implement structures and functions to create database. generate reports and evaluate system.
6 Data Modelling Data modelling produces a plan for a database system that can be implemented using any relational database software. 1.Identify data in current system. 2.Remove repeating groups by normalising the data. 3.Determine relationships between data items and create entity/relationship diagrams. 4.Create a data dictionary to describe the data items in the system. 5.Identify the inputs, processes and outputs required to make the system function.
7 Identify Primary Entities Primary entities are the groups of data items that make up the existing system. The key (or keys) that make each record in each entity unique are identified. The relationships between the entities are identified to allow normalisation later.
8 Normalisation Normalisation takes the data items (called attributes) of the existing entities and produces new entities that are easier to implement in a relational database. Generally, normalisation will produce a set of real world entities such as Customers, Orders etc.
9 First Normal Form To place data into first normal form, we remove any repeating groups within the primary entities. These repeating groups then become new entities, linked together by a one-to- many relationship. Relationships are created by including a primary key from one entity as a foreign key in another entity.
10 First Normal Form Here is un-normalised data from an existing system: - Here is the same data in First Normal Form: -
11 Relationships Relationships can be one of three types: One-to-One One-to-Many Many-to-Many For example: one customer has one address one customer can place many orders. many salespersons can sell to many customers.
12 Entity/Relationship Diagrams Entity - a collection of data (represented as a table in a database). Attribute - (a data item in an entity, a field in a database). Key Attribute - (an attribute that makes up the primary key or part of it). Relationship (a description of the relationship between two entities, normally from the one to the many side). An Attribute An Entity A Key Attribute A Relationshi p
13 Sample E/R Diagram (Film Number Film Title Film Certificate Film Rental Cost) (Video Tape Number *Film Number Video Tape in Stock) (Transaction Number *Customer Number *Video Tape Number Date Booked Out Date Returned) (Customer Number Customer Title Customer Firstname Customer Initials Customer Surname Customer Address Customer Post Code Customer Tel. No.) M 1 1 M 1 M Customers Films Video Tapes are rented on mak e Transactions
14 Data Dictionary A dictionary is a collection of data about data (meta data). It describes all the attributes and their properties: type required (or not) range format
15 Sample Data Dictionary
16 Functions (I/P/O) Functions that act on the database are either input, processing or output operations e.g. Editing data is an input operation Carrying out a calculation is a process Producing a report based on the data is an output. All the functions that act on one, some or all of the entities are identified.
17 What can functions do? Functions can be used to extend the capabilities of the database system beyond what the manual system currently does e.g. statistical reports can be produced data in entities can be cross-reference to ensure integrity operations can be automated (such as looking up over due books in a library system).
18 Example Functions
19 Database Design The finished design will include. data item names database structure data item characteristic validity checks This outcome is concerned with designing database structures for implementation. Ensure that the design closely matches the data model produced during the analysis.
20 Choosing field and table names Most relational database management systems have rules that govern how fields and tables are named. An RDBMS may only allow field and table names of a particular length and may prohibit certain characters from being included in data item names. For example, in Microsoft Access field and table names: Can be up to 64 characters long. Can include any combination of letters, numbers, spaces, and special characters except a period (.), an exclamation point (!), an accent grave (`), and brackets ([ ]). Can't begin with leading spaces. Can't include control characters (ASCII values 0 through 31).
21 Database Structure The structures designed for implementation in the RDBMS should match those in the analysis e.g. Tables will be implemented from entities Fields will represent attributes Relationships between tables should be established (one-to-many etc.) Functions should be created for the inputs, processes and outputs identified.
22 Keys and Indexes A primary key uniquely identifies each record in a table. A foreign key is a primary key from a table included in another table to form a relationship. An index is a quick reference created by a RDBMS to speed up the use of the database. If the RDBMS has the facility to index fields then all foreign and primary keys should be indexed.
23 Data Item Characteristics Appropriate field types should be selected to meet the requirements of the data dictionary produced from the analysis. The field types must be selected from those available in the RDBMS e.g. Dates should be represented using the Date type not Numbers. Money should be represented using the currency data types.
24 Data types available in Microsoft Access
25 Validity Checks Data entered into the database should be valid and correct. Validity checks ensure that the data entered meets certain rules such as: Presence (if the data must be in the field or not). Range (if the value entered is within a particular range). Restricted choice (a value entered must be from a specified list of possible values).
26 Detailed Data Dictionary The detailed data dictionary specifies how the data model will be implemented. It contains the following details about each field Name Type Size Validation Check Format Required (or not) Indexed (or not)
27 Example Detailed Data Dictionary
28 Relationships between fields Relationships between fields can be shown in the following format. [table.fieldname] 1:M [table.fieldname] Relationships are shown as follows: 1:M (one-to-many) M:M (many-to-many) 1:1(one-to-one) For example:
29 Appropriate Design If you have completed the detailed data dictionary and specified the relationships between the fields in the tables whilst considering the restrictions placed on you by the RDBMS that you have successfully met this performance criterion. When you are designing the database structures for your implementation you must always consider what your RDBMS is capable of doing. There is no point in designing a system that cannot be implemented with the software that you have available.