Database Systems Marcus Kaiser School of Computing Science Newcastle University.

Slides:



Advertisements
Similar presentations
Data Definition and Integrity Constraints
Advertisements

Data Modeling. What are you keeping track of? You begin to develop a database by deciding what you are going to keep track of. Each thing that you are.
MSc IT UFCE8K-15-M Data Management Prakash Chatterjee Room 2Q18
Copyright © 2015 Pearson Education, Inc. Database Design Chapters 17 and
Accounting System Design
Concepts of Database Management Sixth Edition
Mid-term Exam Answer Keys Week 7 Spring I. Multiple Choices Questions Each may have more than one answer (6 x 4 = 24 points total)
Lecture Eleven Entity-Relationship Modelling
Chapter 4 ENTITY-RELATIONSHIP MODELLING.
CSE 1561 Designing Relational Databases Stephen Scott.
A Guide to MySQL 7. 2 Objectives Understand, define, and drop views Recognize the benefits of using views Use a view to update data Grant and revoke users’
SQL DDL constraints Restrictions on the columns and tables 1SQL DDL Constraints.
Chapter 4 Entity-Relationship modeling Transparencies © Pearson Education Limited 1995, 2005.
Relational Databases What is a relational database? What would we use one for? What do they look like? How can we describe them? How can you create one?
LOGICAL DATABASE DESIGN
APPENDIX C DESIGNING DATABASES
Mapping ERM to relational database
Database Systems Lecture 5 Natasha Alechina
Introduction To Databases IDIA 618 Fall 2014 Bridget M. Blodgett.
Page 1 ISMT E-120 Desktop Applications for Managers Introduction to Microsoft Access.
Entity-Relationship modeling Transparencies
IT 244 Database Management System Data Modeling 1 Ref: A First Course in Database System Jeffrey D Ullman & Jennifer Widom.
Entity-relationship Modeling Transparencies 1. ©Pearson Education 2009 Objectives How to use ER modeling in database design. The basic concepts of an.
PHP Programming with MySQL Slide 8-1 CHAPTER 8 Working with Databases and MySQL.
Chapter 1 Overview of Database Concepts Oracle 10g: SQL
Introduction to SQL Steve Perry
1 Chapter 1 Overview of Database Concepts. 2 Chapter Objectives Identify the purpose of a database management system (DBMS) Distinguish a field from a.
Chapter 5 Entity–Relationship Modeling
1 ER Modeling BUAD/American University Entity Relationship (ER) Modeling.
Data Modelling – ERD Entity Relationship Diagram’s Entity Relationship Diagrams and how to create them. 1.
Concepts and Terminology Introduction to Database.
Copyright  Oracle Corporation, All rights reserved. 4 CMIS Powell Oracle Designer: Creating the Database Design CMIS Powell.
Lecture 2 An Overview of Relational Database IST 318 – DB Admin.
Lecture 7 Integrity & Veracity UFCE8K-15-M: Data Management.
Management Information Systems MS Access MS Access is an application software that facilitates us to create Database Management Systems (DBMS)
DAY 12: DATABASE CONCEPT Tazin Afrin September 26,
Chapter 6 Database Administration
Database Management COP4540, SCS, FIU Constraints and security in SQL (Ch. 8.6, Ch22.2)
MS Access 2007 Management Information Systems 1. Overview 2  What is MS Access?  Access Terminology  Access Window  Database Window  Create New Database.
1 Outline  What is a Primary Key?  AutoNumber primary keys  Single-field primary keys  Composite-field primary key  About Foreign Keys  Database.
1 Relational Databases and SQL. Learning Objectives Understand techniques to model complex accounting phenomena in an E-R diagram Develop E-R diagrams.
M1G Introduction to Database Development 2. Creating a Database.
© Pearson Education Limited, Chapter 7 Entity-Relationship modeling Transparencies.
Chapter 1Introduction to Oracle9i: SQL1 Chapter 1 Overview of Database Concepts.
Database Fundamentals Lecture 4 Useful website for MySQL download language.com/workshops/Default.asp ?workshop=21.
M1G Introduction to Database Development 4. Improving the database design.
1 © Prentice Hall, 2002 Chapter 5: Logical Database Design and the Relational Model Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B.
INFORMATION TECHNOLOGY DATABASE MANAGEMENT. Adding a new field 1Right click the table name and select design view 2Type the field information at the end.
An Entity Relationship (ER) Diagram is a graphic that shows the interrelationship between entities in a database.
Description and exemplification of entity-relationship modelling.
Chapter 9 Logical Database Design : Mapping ER Model To Tables.
Database Design – Lecture 4 Conceptual Data Modeling.
INTRODUCTION TO DATABASE DESIGN. Definitions Database Models: Conceptual, Logical, Physical Conceptual: “big picture” overview of data and relationships.
The relational model A data model (in general) : Integrated collection of concepts for describing data (data requirements). Relational model was introduced.
1 DATABASE TECHNOLOGIES (Part 2) BUS Abdou Illia, Fall 2015 (September 9, 2015)
1 Database Systems Entity Relationship (E-R) Modeling.
Database: SQL, MySQL, LINQ and Java DB © by Pearson Education, Inc. All Rights Reserved.
Introduction to MySQL Ullman Chapter 4. Introduction MySQL most popular open-source database application Is commonly used with PHP We will learn basics.
Working with MySQL A290/A590, Fall /07/2014.
Data Modeling AND ER MODELS.
Database Security Database System Implementation CSE 507 Some slides adapted from Navathe et. Al.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 The Relational Model Chapter 3.
1 The Relational Data Model David J. Stucki. Relational Model Concepts 2 Fundamental concept: the relation  The Relational Model represents an entire.
Rationale Databases are an integral part of an organization. Aspiring Database Developers should be able to efficiently design and implement databases.
1 Entity Relationship Approach u Top-down approach to data modeling u Uses diagrams u Normalization - confirms technical soundness u Entity Relationship.
1 Section 1 - Introduction to SQL u SQL is an abbreviation for Structured Query Language. u It is generally pronounced “Sequel” u SQL is a unified language.
Database System Implementation CSE 507
CompSci 280 S Introduction to Software Development
אבטחת נתונים בסביבת SQL Data Security
INTRODUCTION A Database system is basically a computer based record keeping system. The collection of data, usually referred to as the database, contains.
Presentation transcript:

Database Systems Marcus Kaiser School of Computing Science Newcastle University

Security if a client wishes to access a database it sets up a session only registered users are allowed to set up sessions authentication takes place before the user can send queries the Database Server checks each query to ensure that the user is allowed to see the data he’s requesting e.g. the Head of Personnel connects and issues a query: what is A.N.Other’s salary she gets back the answer £20000 e.g. a secretary in Personnel connects and issues a query: what is A.N.Other’s salary he is told that he is not allowed to access that information

Security How to control what users read and write, e.g. - prevent tellers increasing their own bank balance restrict who can see salary information prevent deletion of information Solution: User privileges users have usernames that give them privileges SQL statements are checked to make sure a user has the required privileges

User privileges SQL has 9 types of privilege The main ones are the ability specify if tables (base & views) & attributes can be subject to the following…. Select, Insert, Delete, Update e.g. Staff(id, name, dept, address, salary) a user in the mail room may only be allowed to select id, name, dept,address a user in HR may only be allowed to select all attributes, update dept and address, and insert all attributes head of HR may be allowed to select, insert, delete and update all attributes

Granting Privileges Users can grant privileges to other users GRANT ON TO e.g. GRANT SELECT ON Staff TO npw1,njkw The database element is usually a table The privilege list is usually: select, update, insert, delete privileges can be qualified with column names e.g. GRANT SELECT(name,address) ON Staff TO nadb

Passing on Privileges Each privilege has an option: WITH GRANT OPTION if true then privilege can be passed on to another user For example: GRANT SELECT ON Staff TO nwp1 WITH GRANT OPTION This allows a user to pass on a subset of their own privileges to another user The inverse of GRANT is REVOKE

Database Design

Designing a Database Before creating a Database we need to design it Database design cannot be done purely mechanically but there are techniques which help The steps are: 1. Decide on what subjects are covered by the database 2. Decide how they are related to each other 3. Decide on what characteristics they have 4. Derive the database tables from the design 5. Create the database tables using database software

Decide what Subjects are Covered by the Database Rules: Look at what the subject is about, rather than the conclusions you want to find Think about the subject independently of any particular database software (or computing at all) Don’t design database on computer Focus on the data you are likely to collect, rather than how a computer will organise the data

Decide on what subjects are covered by the DB Subjects are called Entities: things that hold interest for you in your database represent a class of things precise definition different for every database you create

Example: a Crime database The police want to track cases When a robbery has happened who is involved? What was taken? Did this go to court? What was the verdict? What are the Entities (subjects) here? Police Officer Stolen Item Case Result

Example: a Crime database e.g. The police want to track cases we begin by drawing the Entities:

Decide how the entities are related to one another Relationships a significant association between the entities represented as a diamond Each relationship has: a name a degree (more on this later) Names Pick a simple word that encapsulates the relationship Concentrate on the main entities first: the rest can come later when you understand the problem better

Naming relationships

The Degree of Relationship One-to-One One occurrence of an entity is uniquely related to another entity e.g: a crime database: each case has one unique result

The Degree of Relationship One-to-Many an occurrence of one entity can be related many times to another entity e.g: a crime database: many items can be stolen in one case

The Degree of Relationship Many-to-Many there can be many occurrences of one entity related to many occurrences of another entity e.g: a crime database: many officers can work on a case, and an officer can work on many cases

Deciding on the Attributes of the Entities Attributes are details about the state of an entity They are things we want to know about an entity Ensure each has a unique name within the Entity They are usually drawn as spokes on Entity-Relationship diagrams:

Attributes: Primary Keys Make sure that each Entity has an Attribute (or set of Attributes) which allow it to be uniquely identified This is called the primary key (often called ID, use underscore in the ER model) If there might be some doubt about whether or not a set of attributes is unique, then add an extra attribute containing a unique number/code. e.g. for Officers: Name and DOB may be enough: but the id attribute is guaranteed to be unique

Deriving the Database tables from the Design The Entities are Tables The Attributes are their columns Using the database software manual, find out what the possible column types are and decide on the right one for each attribute Once this is done, the tables can be created Next any initial data is entered into the tables Any standard Queries Forms and Reports are designed and implemented Now the database is ready for use police officer id station dob rank address name

Representing Relationships through Foreign Keys A FOREIGN KEY in one table points to a PRIMARY KEY in another table. They are used to represent relationships

Representing 1-1 Relationships Assume each table has an id column which is its key Then we can add a foreign key column to either table i.e. Add a CaseId column to Result, or a ResultId column to Case

Representing 1-many Relationships Assume each table has an id column which is its key Then we must add a foreign key column to the table at the many end of the relationship i.e. Add a Case Id column to the Stolen Item table

Representing 1-to-Many Relationships -- Table `StolenItem` CREATE TABLE `StolenItem` ( `stolenItemId` INT UNSIGNED NOT NULL AUTO_INCREMENT, `stolenItemName` VARCHAR(45) NOT NULL, `caseItemId` INT UNSIGNED NOT NULL AUTO_INCREMENT, PRIMARY KEY (`stolenItemId`) );

Representing Many-to-Many Relationships To implement in a relational database, these are split up into two relationships, with a newly created entity intervening

Representing Many-to-Many Relationships In the Police example we create a new entity which matches Cases to Officers:

Representing Many-to-Many Relationships -- Table `Officer` CREATE TABLE `Officer` ( `officerId` INT UNSIGNED NOT NULL AUTO_INCREMENT, `officerName` VARCHAR(45) NOT NULL, PRIMARY KEY (`officerId`) ); -- Table `Case` CREATE TABLE `Case` ( `caseId` INT UNSIGNED NOT NULL AUTO_INCREMENT, `caseName` VARCHAR(45) NOT NULL, PRIMARY KEY (`caseId`) ); -- Table `OfficerCase` CREATE TABLE `OfficerCase` ( `Case_caseId` INT UNSIGNED NOT NULL, `Officer_officerId` INT UNSIGNED NOT NULL, PRIMARY KEY (`Case_caseId`, `Officer_officerId`) );

Summary Security: grant access and pass access to others Primary and foreign keys: unique identifiers Degree of a relationship: 1:1 1:Many or 1:n Many:Many or n:m (create intervening entity) Quick overview to SQL: