Docsity

POSE DB and SQL lecture notes, Schemes and Mind Maps of Database Management Systems (DBMS)

Partial preview of the text

Download POSE DB and SQL lecture notes and more Schemes and Mind Maps Database Management Systems (DBMS) in PDF only on Docsity!

UNIVERSITY of GREENWICH

Principles of Software

Engineering

Structure Physical design.

SQL basics.

Dr. E. I. Popa

Last lecture we looked at

Structured Analysis and Structured Design

It looks at how data iis modelled , stored and processed.

Structured Analysis Tools

Entity Relationships Analysis - ERD

entities in the business environment relationships (or associations) among those entities attributes (properties) of both the entities and their relationships

Data Flow Diagrams

Source/Sink – outside systems

Data Flow - data in motion

Process-transforms incoming data flows into outgoing data

flow

Store - collection of data packets at rest

Dr. E. I. Popa 2

The database environment

To be able to function, an organisation needs

information, e.g. list of books in a library, customer

details in a retail business, etc

A major requirement of any computer system is to

store and retrieve data in a way that is meaningful

to the end user

Data: Meaningful facts, text, graphics, images,

sound, video segments.

Dr. E. I. Popa 4

The database environment

Database: An organized collection of logically related

data.

Databases : computer structures that save, organize,

protect, and deliver data.

A system that contains databases is called a database

management system, or DBM.

A DBMS is a data storage and retrieval system which

permits data to be stored non-redundantly while

making it appear to the user as if the data is well-

integrated

Dr. E. I. Popa 5

Database physical design

Created after completing the logical

The physical design of a database optimizes

performance while ensuring data integrity by

avoiding unnecessary data redundancies.

During physical design:

the entities are transformed into tables,

the instances are transformed into rows,

the attributes are transformed into columns.

Dr. E. I. Popa 7

Database physical design

Some decisions that affect the physical design:

How to translate entities into physical tables

What attributes to use for columns of the physical

tables

Which columns of the tables to define as keys

How to normalize the tables

Note In some cases denormalising data might improve

performance

How to resolve many-to-many relationships

Dr. E. I. Popa 8

A primary key uniquely identifies a record in a table. It should be UNIQUE (not duplicated) Data from records is depending on primary key given a ‘LecturerId’ we can find their FirstName, LastName and Email Notations: depicted with a HASH #, underlined , a prefix /suffix PK Accessing records via Primary Key

Dr. E. I. Popa 10

LecturerId FirstName LastName EMail

1 Elena Popa [email protected] 2 Markus Wolf [email protected] 5 Peter Smith [email protected] Primary key Unique

LecturerID FirstName LastName EMail

Module ID LecturerID StartDate ModuleName

COMP1821 1 15/09/2019 Software Engineering COMP1549 2 15/09/2019 Programming COMP1765 5 07/01/2020 Introduction to compilers COMP1471 1 15//01/2020 Enterprise Systems etc etc etc etc

ModuleTable

LecturerTable

FOREIGN KEY is used to RELATE tables Relationships

PRIMARY KEY

Dr. E. I. Popa 11

1 Elena Popa [email protected] 2 Markus Wolf [email protected] 5 Peter Smith [email protected]

LecturerID FirstName LastName EMail

Module ID LecturerID StartDate ModuleName

COMP1821 1 15/09/2019 Software Engineering COMP1549 2 15/09/2019 Programming COMP1765 5 07/01/2020 Introduction to compilers COMP1471 1 15//01/2020 Enterprise Systems etc etc etc etc

ModuleTable

LecturerTable

Relationships

Dr. E. I. Popa 13

1 Elena Popa [email protected] 2 Markus Wolf [email protected] 5 Peter Smith [email protected] You can enforce a constraint, it requires a related record, REFERENTIAL INTEGRITY means that the references between tables are correct

Data normalisation

Normalisation is the process of organizing data in

a database.

“improves” a database design by generating relations

that are of higher normal forms.

It includes

creating tables

establishing relationships between those tables

according to rules designed both to protect the data

and to make the database more flexible by eliminating

redundancy and inconsistent dependency.

Redundant data wastes disk space and creates maintenance

problems.

Dr. E. I. Popa 14

Example: First Normal Form

We say a relation is in 1NF if all values stored in the relation

are single-valued and atomic.

The following in not in 1NF

Dr. E. I. Popa 16

LecturerID Phone Degrees

333 233 - 1231 BA, BSc, PhD

679 233 - 1231 BSc, MSc

Degrees is a multi-valued field:

Lecturer 679 has two degrees: BSc and MSc

Lecturer 333 has three degrees: BA, BSc, PhD

Dr. E. I. Popa 17

First Normal Form

LecturerID Degree

333 BA

333 BSc

333 PhD

679 BSc

679 MSc

LecturerID EmpPhone

An outer join between Employee and EmployeeDegree will

produce the information we saw before

Lecturer

LecturerDegree

UNIVERSITY of GREENWICH

SQL basics.

Dr. E. I. Popa

SQL a standard language for storing, manipulating and retrieving data in databases. an abbreviation for Structured Query Language. Pronounced as the letters ‘S-Q-L’, or as ‘See-Quel’. Something of a misleading name as its is not just a query language. SQL is easy to learn The statements are made up of a small set of descriptive English words. SQL is very powerful complex and sophisticated operations can be performed by cleverly using the simple language elements.

Dr. E. I. Popa 20