Presentation is loading. Please wait.

Presentation is loading. Please wait.

1st December 2015Birkbeck College, U. London1 Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems.

Similar presentations


Presentation on theme: "1st December 2015Birkbeck College, U. London1 Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems."— Presentation transcript:

1 1st December 2015Birkbeck College, U. London1 Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems sjmaybank@dcs.bbk.ac.uk Autumn 2015 Week 10b: Relational Databases

2 1st December 2015Brookshear, Section 9.12 Definition of a Database A collection of data with internal links that make the information accessible from a variety of perspectives.

3 1st December 2015Birkbeck College3 Very Large Databases Facebook357 PB CERN (Higgs Boson)200 PB Microsoft Hotmail150 PB German Climate Computing Centre (DKRZ) 60 PB 1PB=10 15 Bytes = 0.15MB for every person on Earth See en.wikipedia.org/wiki/Petabyte

4 1st December 20154 Different Perspectives In an employee database, list  All employees in personnel  All job titles in Accounts  All employees under 30  All departments with 50 or more employees  … Brookshear, Section 9.2

5 1st December 2015Brookshear, Section 9.15 File Oriented Information System Customer service dept Customer records Payroll records Payroll dept Employee records Employee dept

6 1st December 2015Brookshear, Section 9.16 Database Oriented Information System Customer service dept Integrated database Payroll dept Employee dept

7 1st December 2015Brookshear, Section 9.17 Database Model User’s concept of the database Eg. in a relational database model the user sees all the data in tables The actual storage and management of the data may not correspond to the database model.

8 1st December 2015Brookshear, Section 9.28 Table in a Relational Database 102Sperry1 The Lane 103Univac15 Retail Road 54Honeywell205 North Street Customer Num NameAddress

9 1st December 2015Birkbeck College9 User Interface

10 1st December 2015Brookshear, Section 9.110 Layers in a Database Implementation Applications Software: user interface, including implementation of the database model. Database Management System: updates the database and supplies data to the applications software. User Applications Software DBMS Actual data

11 1st December 2015Brookshire, Section 9.111 Advantages of Splitting AS from DBMS The user sees only the database model. The true complexity of the database is hidden. The DBMS can be changed without affecting users. The AS can be tailored for different groups of users. Easier access control because all access is through a single DBMS.

12 1st December 2015cf. Brookshear, Section 9.112 Database Consisting of a Single File Order num Customer name Customer address PriceDue date Product 37Sperry1 The Lane£10001.7.06Plate 43Univac15 Retail Road£20005.5.06Case 20Honeywell205 North Street £34002.4.06Panel If a customer has no orders, then all information about that customer is lost.

13 1st December 2015Brookshear, Section 9.213 Relational Model All data is organised into rectangular tables called relations. Each row (or tuple) is a single data item. Each column is an attribute, taking values in a specified domain. The table heading is not a row in the table. 102Sperry1 The Lane 103Univac15 Retail Road 54Honeywell205 North Street Customer Num NameAddress Table heading

14 1st December 2015Brookshear, Section 9.214 Advantages and Disadvantages Advantages:  When a table is updated, the information in the other tables is unchanged  Information is not duplicated. Disadvantage:  Once the relations are established they cannot be easily changed.

15 1st December 2015Birkbeck College15 Relational Database 37102£10001.7.06Plate 43103£20005.5.06Case 2054£34002.4.06Panel 102Sperry1 The Lane 103Univac15 Retail Road 54Honeywell205 North Street Order Num Customer Num PriceDue date Product Order file Customer file Customer Num NameAddress What is the address of Sperry? What is the total value of the orders placed with Honeywell? How many different products are there on order? How many different products are there?

16 1st December 2015Brookshear, Section 9.216 Table Structure Each table should correspond to a single concept or task Each row of a table should be uniquely identified by a key Avoid including the same information in different tables

17 1st December 2015cf. Brookshear, Section 9.217 Keys Primary key: an attribute whose value uniquely identifies a tuple. Composite key: a minimal set of attributes whose values together uniquely identify a tuple Foreign key: set of attributes pointing to a primary key or a composite key in another table.

18 1st December 2015Birkbeck College18 Examples of Keys 37102£10001.7.06Plate 43103£20005.5.06Case 2054£34002.4.06Panel 102Sperry1 The Lane 103Univac15 Retail Road 54Honeywell205 North Street Order Num Customer Num PriceDue date Product Order file Customer file Customer Num NameAddress Primary keys: Order Num in the Order file, Customer Num in the Customer file Foreign key: Customer Num in the Order file

19 1st December 2015Birkbeck College19 Problem Find the names of all customers who have ordered products with a total value of £3000 or less.

20 1st December 2015Brookshear, Section 9.220 Lossless Decomposition In lossless decomposition a relation (table) is decomposed into smaller relations without loss of information. Aim: to produce a better table structure.

21 1st December 2015cf Brookshear, Section 9.221 Original Relation 37102£10001.7.06PlateSperry1 The Lane 43103£20005.5.06CaseUnivac15 Retail Road 2054£34002.4.06PanelHoneywell205 North Street Order no. Customer no. PriceDue date ProductNameAddress Original table

22 1st December 2015Brookshear, Section 9.222 Example of a Lossless Decomposition 37102£10001.7.06Plate 43103£20005.5.06Case 2054£34002.4.06Panel 102Sperry1 The Lane 103Univac15 Retail Road 54Honeywell205 North Street Order no. Custo mer no. PriceDue date Product Order fileCustomer file Customer no. NameAddress

23 1st December 2015Brookshear, Section 9.223 Original Relation 203AssistantFinance 17ManagerFinance 18ManagerPlanning Empl Id Job Title Dept

24 1st December 2015Brookshear, Section 9.224 Example of a Lossy Decomposition 203Assistant 17Manager 18Manager AssistantFinance ManagerFinance ManagerPlanning Empl Id Job Title Dept

25 1st December 2015Brookshear, Ch. 9, Problem 2825 Problem 2 NameDepartmentTel.No. JonesSales555-2222 SmithSales555-3333 BakerPersonnel555-4444 DepartmentTel.No. What is the difference in the information supplied by the single relation and the two relations NameDepartment JonesSales SmithSales BakerPersonnel Sales555-2222 Sales555-3333 Personnel555-4444

26 1st December 2015Birkbeck College26 Problem 3 Let R(X,Y,Z) be a relation with attributes X, Y, Z, and let R(X,Y) and R(Y,Z) be relations obtained by decomposing R(X,Y,Z). Prove that if Y is a key for R(X,Y), then the decomposition is lossless. See S. Sumathi and S. Esakkirajan, Fundamentals of relational database management systems.


Download ppt "1st December 2015Birkbeck College, U. London1 Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems."

Similar presentations


Ads by Google