Slides about Database Management. The Pdf explores the logical model of databases, focusing on the relational model, its fundamental principles, characteristics, and operators. The Presentation, suitable for University students of Computer science, provides practical examples to illustrate the application of these concepts.
See more45 Pages


Unlock the full PDF for free
Sign up to get full access to the document and start transforming it with AI.
3.
Logical model . It allows us to translate the abstract representation (conceptual model) into a data representation that is still free from physical details but concrete, as it is present in the DBMS.
1Database Management II. Data and Computers c) Relational model
2II. Data and Computers Database Management
PATIENT Pat.no. Name Gender Birth date Address City Phone no. 12 Johnson, M. male Aug 12-1934 4808 Main St New York (123) 456-789 66 Smith, A.F. fem ale Mar 13-1950 12 Hill Lane Baltimore 45 Brown, M. male Dec 03-1960 234 NewRd. Boston (987)-654-321 Tuple Attributo Tuple: Different information about the same entity Attribute: Same information for different entities
3II. Data and Computers Database Management
Relationship Schema and Relationship Instance: Patient (number, name, gender, date of birth, address, city, telephone number)
PATIENT Pat.no. Name Gender Birth date Address City Phone no. 12 Johnson, M. male Aug 12-1934 4808 Main St NewYork (123) 456-789 66 Smith, A.F. fem ale Mar 13-1950 12 Hill Lane Baltimore NULL 45 Brown, M. male Dec 03-1960 234 NewRd. Boston (987)-654-321 Instance
4II. Data and Computers Database Management
SUPER KEY = Any set of attributes in a relationship that satisfies the property of not having the same combination of attribute values for two or more tuples.
Identification code Surname Name Date of birth Place of birth Pathology 123 Rossi Luigi 01/01/1950 Ancona Hypertension 124 Rossi Dario 01/01/1950 Milano Diabetes 125 Rossi Luca 03/05/1940 Perugia Infarction 126 Neri Luca 03/05/1940 Roma Renal colic 127 Neri Luca 20/04/1952 Torino Respiratory problems
5II. Data and Computers Database Management
KEY = It is a minimal superkey, i.e. a superkey in which it is not possible to find a proper subset of attributes that retains the property of being a superkey.
Identification code Surname Name Date of birth Place of birth Pathology 123 Rossi Luigi 01/01/1950 Ancona Hypertension 124 Rossi Dario 01/01/1950 Milano Diabetes 125 Rossi Luca 03/05/1940 Perugia Infarction 126 Neri Luca 03/05/1940 Roma Renal colic 127 Neri Luca 20/04/1952 Torino Respiratory problems Minimal superkey?
6II. Data and Computers Database Management
Identification code Surname Name Date of birth Place of birth Pathology 123 Rossi Luigi 01/01/1950 Ancona Hypertension 124 Rossi Dario 01/01/1950 Milano Diabetes 125 Rossi Luca 03/05/1940 Perugia Infarction 126 Neri Luca 03/05/1940 Roma Renal colic 127 Neri Luca 20/04/1952 Torino Respiratory problems Key Key
7II. Data and Computers Database Management
DEFINITION OF PRIMARY KEY A proper subset K of attributes such that
8II. Data and Computers Database Management Query languages for the relational model can be divided into two categories:
A. Algebraic languages (procedural or navigational languages), where a question is formulated by means of an expression constructed by operators acting on relations (union, projection, selection, Cartesian product, natural join ... ). The answer to the question is the relationship resulting from the evaluation of the expression.
B. Languages based on relational calculus (non-procedural or declarative languages), where questions are expressed by specifying predicate calculus formulas. The answer to the question is the relation whose tuples satisfy the property that is stated in the question itself.
Procedure to get the result vs. properties of the result Ex: SQL
9Database Management II. Data and Computers RELATIONAL ALGEBRA
10II. Data and Computers Database Management A few premises
11II. Data and Computers Database Management Main operations of relational algebra
12Database Management II. Data and Computers Select (a)
Allows to select a subset of tuples in a relation Syntax: NewRelation& O(condition) (RelationName)
13II. Data and Computers Database Management Esempio:
Identification code Surname Name Date of birth Place of birth Department 123 Rossi Luigi 01/01/1950 Ancona Cardiology 124 Rossi Dario 01/01/1950 Milano Surgery 125 Rossi Luca 03/05/1940 Perugia Surgery 126 Neri Luca 03/05/1940 Roma Emergency 127 Neri Luca 20/04/1952 Torino Surgery NewPatient <- O(Department = Surgery) Patient) NewPatient (Department = Surgery) AND (ID = 125) (Patient)
14II. Data and Computers Database Management
NewPatient <- O(Department = Surgery) (Patient) 124 Rossi Dario 01/01/1950 Milano Surgery 125 Rossi Luca 03/05/1940 Perugia Surgery 127 Neri Luca 20/04/1952 Torino Surgery NewPatient&O(Department (Department = Surgery) AND (ID = 125) (Patient) 125 Rossi Luca 03/05/1940 Perugia Chirurgia
15Database Management II. Data and Computers Project (Tt)
Creates a new relation that contains the tuples that match the tuples of the starting relation but are limited to the attribute values that are specified in the operation Syntax: NewRelation& -T (Attribute List) (RelationName)
16II. Data and Computers Database Management Example:
Identification code Surname Name Date of birth Place of birth Department 123 Rossi Luigi 01/01/1950 Ancona Cardiology 124 Rossi Dario 01/01/1950 Milano Surgery 125 Rossi Luca 03/05/1940 Perugia Surgery 126 Neri Luca 03/05/1940 Roma Emergency 127 Neri Luca 20/04/1952 Torino Surgery NewPatient& -T(Surname, Name, Date of Birth) 'Patient) NewPatient&T(Surname, (Patient)
17II. Data and Computers Database Management Example:
NewPatient& T (Surname, Name, Date of Birth) (Patient) Surname Name Date of birth Rossi Luigi 01/01/1950 Rossi Dario 01/01/1950 Rossi Luca 03/05/1940 Neri Luca 03/05/1940 Neri Luca 20/04/1952
18II. Data and Computers Database Management Example:
NewPatient& -T(Surname, Name) (Patient) Surname Name Rossi Luigi Rossi Dario Rossi Luca Neri Luca
19Database Management II. Data and Computers Rename (p)
Allows to rename the attributes of a relationship to standardize the names of attributes that have similar meaning but come from different relationships. Syntax: NewRelation& P(Renaming Criteria) (Relation1)
20Database Management II. Data and Computers Union (u)
Allows to construct a new relationship that includes all the tuples that are present in multiple starting relations Syntax: NewRelation <- Relation1 u Relation2