Presentation is loading. Please wait.

Presentation is loading. Please wait.

44271: Database Design & Implementation Physical Data Modelling Ian Perry Room: C49 Tel Ext.: 7287

Similar presentations


Presentation on theme: "44271: Database Design & Implementation Physical Data Modelling Ian Perry Room: C49 Tel Ext.: 7287"— Presentation transcript:

1 44271: Database Design & Implementation Physical Data Modelling Ian Perry Room: C49 Tel Ext.: 7287 E-mail: I.P.Perry@hull.ac.ukI.P.Perry@hull.ac.uk http://itsy.co.uk/ac/0405/sem3/44271_DDI/

2 Ian PerrySlide 244271: Database Design & Implementation: Physical Data Modelling The ‘Data Modelling Stack’

3 Ian PerrySlide 344271: Database Design & Implementation: Physical Data Modelling What is a Physical Data Model? The Physical Implementation (hardware & software) of a Logical Data Model: it is useless to progress to this stage of database development if your Logical Data Model is NOT demonstrably ‘robust’. Physical Data Model must enable: data to be stored (& maintained) in structured manner. an ‘accurate’ implementation of the logical data model. retrieval of specific groupings of data (information?). refer back to the original business requirements. There may be several software constraints: depending upon the software application chosen.

4 Ian PerrySlide 444271: Database Design & Implementation: Physical Data Modelling Our Physical ‘World’? RDBMS Software: Microsoft Access In this physical world we must be able to: Create Translate our Relational Schema into a Database. Populate This Database with ‘test’ data. Query Ask questions of the Database.

5 Ian PerrySlide 544271: Database Design & Implementation: Physical Data Modelling Properties of RDBMS Software Modification: To Schema: creating & deleting relations (i.e. Tables). adding attributes to, or removing attributes from, existing relations. To Data: creating & deleting tuples (i.e. Records) updating attribute values in a tuple (i.e. Data held in Fields) Interrogation: Relational Algebra Relational Calculus (SQL)

6 Ian PerrySlide 644271: Database Design & Implementation: Physical Data Modelling Logical => Physical i.e. translate our Relational Schema into a Database Storage Model: Schema => Database Relations => Tables Attributes => Field Names Domains => Data Type Field Size Input Mask Validation Rule etc. Key Fields=> Relationships

7 Ian PerrySlide 744271: Database Design & Implementation: Physical Data Modelling The SSC Database Relations Staff (StaffID, FirstName, SurName, ScalePoint, DOB) Student (EnrolNo, FirstName, SurName, OLevelPoints, Tutor) Course (CourseCode, Name, Duration) Team (CourseCode, StaffID) Pay (ScalePoint, RateOfPay) ER Diagram Staff Course Student 1MMM

8 Ian PerrySlide 844271: Database Design & Implementation: Physical Data Modelling Physical Implementation

9 Ian PerrySlide 944271: Database Design & Implementation: Physical Data Modelling Relational Algebra With most (all?) Relational DataBase Management Systems the means of database interrogation is based upon: Relational Algebra (E. F. Codd, 1972) As represented by the 3 primary functions of: SELECT PROJECT JOIN

10 Ian PerrySlide 1044271: Database Design & Implementation: Physical Data Modelling Example Relations (Relational Algebra) EmpNoENameESalaryDept JNameEmpNoHours Employee (EmpNo, EName, ESalary, Dept) Assignment (JName, EmpNo, Hours) Job (JName, Budget) JNameBudget

11 Ian PerrySlide 1144271: Database Design & Implementation: Physical Data Modelling SELECT Extracts TUPLES (Rows) from a relation subject to required conditions on attributes in that relation. e.g.: SELECT Employee WHERE ESalary > 13000 NB. SELECT Employee WHERE ESalary > 13000 GIVING Temp1 Would ‘create’ a new relation, i.e. Temp1

12 Ian PerrySlide 1244271: Database Design & Implementation: Physical Data Modelling PROJECT Extracts COLUMNS from a relation in a named order by attribute. e.g.: PROJECT Employee OVER EName, Dept

13 Ian PerrySlide 1344271: Database Design & Implementation: Physical Data Modelling JOIN COMBINES RELATIONS which have a common attribute to generate a temporary relation containing all of the attributes from both relations. e.g: JOIN Employee AND Assignment OVER EmpNo NB. This temporary relation contains only one instance of the ‘EmpNo’ Attribute.

14 Ian PerrySlide 1444271: Database Design & Implementation: Physical Data Modelling Asking ‘Complex’ Questions What are the Names, Jobs and Hours worked by those in the Sales Dept? PROJECT ( SELECT ( JOIN Employee AND Assignment OVER EmpNo) WHERE Dept = 'Sales') OVER EName, JName, Hours NB. The final relation is constructed by working from the innermost nesting outwards.

15 Ian PerrySlide 1544271: Database Design & Implementation: Physical Data Modelling Structured Query Language SQL is the most often used method for accessing relational databases. A ‘software interpretation’ of Codd's Relational Algebra. Remember: SELECT - extracts TUPLES from a relation subject to required conditions on attributes in the relation. PROJECT - extracts COLUMNS from a relation in a named order by attribute. JOIN - COMBINES RELATIONS which have a common attribute to generate a temporary relation containing all of the attributes from both relations. SQL ‘works’ for all RDBMS applications: e.g. Access, Oracle, MySQL, etc.

16 Ian PerrySlide 1644271: Database Design & Implementation: Physical Data Modelling The SQL ‘SELECT’ Statement SQL Syntax SELECT {column_name [, column_name,... ] } FROM table_name [ table_alias ] [ WHERE condition [ AND/OR condition [, AND/OR condition,... ] ] ] [ GOUP BY column_name [, column_name,... ] [ HAVING condition ] ] [ ORDER BY {column_name/column_number [,... ] } ] Don’t worry, it is not a frightening as it looks!

17 Ian PerrySlide 1744271: Database Design & Implementation: Physical Data Modelling Example Relations (SQL) SurnameNameDeptPositionAge Staff (Surname, Name, Dept, Position, Age) Course (CourseNo, CourseName, Level, Surname) CourseNoCourseNameLevelSurname

18 Ian PerrySlide 1844271: Database Design & Implementation: Physical Data Modelling The ‘simplest’ SELECT SELECT * FROM staff ; A SELECT of all Tuples (rows) from a Table called staff.

19 Ian PerrySlide 1944271: Database Design & Implementation: Physical Data Modelling A ‘more useful’ SELECT SELECT name, surname, age, position FROM staff WHERE age > 35 OR position = 'CLERK' GROUP by age ; A PROJECT of specific columns of the staff Table (in a named order), with some SELECTion of conditions.

20 Ian PerrySlide 2044271: Database Design & Implementation: Physical Data Modelling Previous SQL Statement Produces:

21 Ian PerrySlide 2144271: Database Design & Implementation: Physical Data Modelling SELECTing from 2 Tables SELECT S.name, S.surname, S.age, C.courseno FROM staff S, course C WHERE S.surname = C.surname AND age > 50 ; JOINs the Tables staff and course to create a temporary table and PROJECTs columns from this new table based on the SELECTion criteria.

22 Ian PerrySlide 2244271: Database Design & Implementation: Physical Data Modelling Previous SQL Statement Produces:

23 Ian PerrySlide 2344271: Database Design & Implementation: Physical Data Modelling Query-By-Example (QBE) SQL can be difficult to learn, however, most RDBMS software has a QBE interface: which presents the user with ‘lists’ of things to choose from. Using this 'point-&-click' QBE interface, we don’t have to know (much) about: Field Names, Logical Operators, etc. can easily set up relationships between tables: Staff.SURNAME = Course.SURNAME and apply criteria for selection, e.g.: Staff.AGE > 50

24 Ian PerrySlide 2444271: Database Design & Implementation: Physical Data Modelling This Week’s Workshop Provides a ‘gentle’ Introduction to Microsoft Access Showing you how to build, and then ask questions of, relatively simple Relational Databases. i.e.: Databases consisting of two, or three, Tables.


Download ppt "44271: Database Design & Implementation Physical Data Modelling Ian Perry Room: C49 Tel Ext.: 7287"

Similar presentations


Ads by Google