BAZE DE DATE c1 - 2 - 2022

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 14

Baze de date

Curs 1 + 2 – Introducere in baze de date


Prof. Univ. Dr. Diaconita Vlad
https://online.ase.ro
Curs online ORACLE ACADEMY DATABASE DESIGN AND PROGRAMMING WITH SQL
Obiective
• Înțelegerea problemelor de stocare a datelor atunci cand se utilizeaza
foi de calcul sau fișiere text
• Înțelegerea modului în care bazele de date rezolva diferitele
complicații asociate cu utilizarea listelor
Scopul unei baze de date
• Oferirea de facilitati CRUD
• Stocarea datele conform unui model de date
• Stocarea datelor cât și metadatelor
• Stocarea si gestionarea de alte obiecte ale bazei de date: tabele
virtuale, funcții, proceduri, secvențe etc.
Probleme cu stocarea datelor într-o foaie de lucru
Employee Name Telephone HireDate Salary Job Sal min/Sal Department Department Manager
ID Max adress

Magdalen Centre,
The Oxford Neena Kochhar
101 William Gietz 515.123.8181 07.06.1994 8300 Public Accountant 5000/10000 Accounting Science Park
Magdalen Centre,
Accounting The Oxford
102 Shelley Higgins 515.123.8080 07.06.1994 12000 Manager 11000/14000 Accounting Science Park Neena Kochhar
Magdalen Centre,
Administration The Oxford Steven King
103 Jennifer Whalen 515.123.4444 17.09.1987 4400 Assistant 3000/7000 Administration Science Park
Magdalen Centre,
The Oxford Steven King
104 Steven King 515.123.4567 17.06.1987 24000 President 20000/30000 Executive Science Park
Magdalen Centre,
Administration The Oxford
105 Neena Kochhar 515.123.4568 21.09.1989 17000 Vice President 16000/20000 Executive Science Park Steven King
Magdalen Centre,
Administration The Oxford
106 Lex De Haan 515.123.4569 13.01.1993 17000 Vice President 16000/20000 Executive Science Park Steven King

107 Ismael Sciarra 515.124.4369 30.09.1997 7700 Accountant 5000/10000 Finance 9702 Chester Road Ismael Sciarra

108 John Chen 515.124.4269 28.09.1997 8300 Accountant 5000/10000 Finance 9702 Chester Road Ismael Sciarra

109 Luis Popp 515.124.4567 07.12.1999 6900 Accountant 5000/10000 Finance 9702 Chester Road Ismael Sciarra
Jose Manuel
110 Urman 515.124.4469 07.03.1998 7800 Accountant 5000/10000 Finance 9702 Chester Road Ismael Sciarra
Anomalii de actualizare
Employee Name Telephone HireDate Salary Job Sal min/Sal Department Department Manager
ID Max adress

Magdalen Centre,
The Oxford Neena Kochhar
101 William Gietz 515.123.8181 07.06.1994 8300 Public Accountant 5000/10000 Accounting Science Park
Magdalen Centre,
Accounting The Oxford
102 Shelley Higgins 515.123.8080 07.06.1994 12000 Manager 11000/14000 Accounting Science Park Neena Kochhar
Magdalen Centre,
Administration The Oxford Steven King
103 Jennifer Whalen 515.123.4444 17.09.1987 4400 Assistant 3000/7000 Administration Science Park
Magdalen Centre,
The Oxford Steven King
104 Steven King 515.123.4567 17.06.1987 24000 President 20000/30000 Executive Science Park
Magdalen Centre,
Administration The Oxford
105 Neena Kochhar 515.123.4568 21.09.1989 17000 Vice President 16000/20000 Executive Science Park Steven King
Magdalen Centre,
Administration The Oxford
106 Lex De Haan 515.123.4569 13.01.1993 17000 Vice President 16000/20000 Executive Science Park Steven King

107 Ismael Sciarra 515.124.4369 30.09.1997 7700 Accountant 5000/10000 Finance 9702 Chester Road Ismael Sciarra

108 John Chen 515.124.4269 28.09.1997 8300 Accountant 5000/10000 Finance 9702 Chester Road Ismael Sciarra

109 Luis Popp 515.124.4567 07.12.1999 6900 Accountant 5000/10000 Finance 9702 Chester Road Ismael Sciarra
Jose Manuel
110 Urman 515.124.4469 07.03.1998 7800 Accountant 5000/10000 Finance 9702 Chester Road Ismael Sciarra
Anomalii de stergere
Employee Name Telephone HireDate Salary Sal min/Sal Job Department Department Manager
ID Max adress

Magdalen Centre,
The Oxford Neena Kochhar
101 William Gietz 515.123.8181 07.06.1994 8300 5000/10000 Public Accountant Accounting Science Park
Magdalen Centre,
Accounting The Oxford
102 Shelley Higgins 515.123.8080 07.06.1994 12000 11000/14000 Manager Accounting Science Park Neena Kochhar
Magdalen Centre,
Administration The Oxford Steven King
103 Jennifer Whalen 515.123.4444 17.09.1987 4400 3000/7000 Assistant Administration Science Park
Magdalen Centre,
The Oxford Steven King
104 Steven King 515.123.4567 17.06.1987 24000 20000/30000 President Executive Science Park
Magdalen Centre,
Administration The Oxford
105 Neena Kochhar 515.123.4568 21.09.1989 17000 16000/20000 Vice President Executive Science Park Steven King
Magdalen Centre,
Administration The Oxford
106 Lex De Haan 515.123.4569 13.01.1993 17000 16000/20000 Vice President Executive Science Park Steven King

107 Ismael Sciarra 515.124.4369 30.09.1997 7700 5000/10000 Accountant Finance 9702 Chester Road Ismael Sciarra

108 John Chen 515.124.4269 28.09.1997 8300 5000/10000 Accountant Finance 9702 Chester Road Ismael Sciarra

109 Luis Popp 515.124.4567 07.12.1999 6900 5000/10000 Accountant Finance 9702 Chester Road Ismael Sciarra
Jose Manuel
110 Urman 515.124.4469 07.03.1998 7800 5000/10000 Accountant Finance 9702 Chester Road Ismael Sciarra
Anomalii de stergere
Employee Name Telephone HireDate Salary Sal min/Sal Job Department Department Manager
ID Max adress

Magdalen Centre,
The Oxford Neena Kochhar
101 William Gietz 515.123.8181 07.06.1994 8300 5000/10000 Public Accountant Accounting Science Park
Magdalen Centre,
Accounting The Oxford
102 Shelley Higgins 515.123.8080 07.06.1994 12000 11000/14000 Manager Accounting Science Park Neena Kochhar
Magdalen Centre,
Administration The Oxford Steven King
103 Jennifer Whalen 515.123.4444 17.09.1987 4400 3000/7000 Assistant Administration Science Park
Magdalen Centre,
The Oxford Steven King
104 Steven King 515.123.4567 17.06.1987 24000 20000/30000 President Executive Science Park
Magdalen Centre,
Administration The Oxford
105 Neena Kochhar 515.123.4568 21.09.1989 17000 16000/20000 Vice President Executive Science Park Steven King
Magdalen Centre,
Administration The Oxford
106 Lex De Haan 515.123.4569 13.01.1993 17000 16000/20000 Vice President Executive Science Park Steven King

107 Ismael Sciarra 515.124.4369 30.09.1997 7700 5000/10000 Accountant Finance 9702 Chester Road Ismael Sciarra

108 John Chen 515.124.4269 28.09.1997 8300 5000/10000 Accountant Finance 9702 Chester Road Ismael Sciarra

109 Luis Popp 515.124.4567 07.12.1999 6900 5000/10000 Accountant Finance 9702 Chester Road Ismael Sciarra
Jose Manuel
110 Urman 515.124.4469 07.03.1998 7800 5000/10000 Accountant Finance 9702 Chester Road Ismael Sciarra
Anomalii de adaugare
Employee Name Telephone HireDate Salary Sal min/Sal Job Department Department Manager
ID Max adress

Magdalen Centre,
The Oxford Neena Kochhar
101 William Gietz 515.123.8181 07.06.1994 8300 5000/10000 Public Accountant Accounting Science Park
Magdalen Centre,
Accounting The Oxford
102 Shelley Higgins 515.123.8080 07.06.1994 12000 11000/14000 Manager Accounting Science Park Neena Kochhar
Magdalen Centre,
Administration The Oxford Steven King
103 Jennifer Whalen 515.123.4444 17.09.1987 4400 3000/7000 Assistant Administration Science Park
Magdalen Centre,
The Oxford Steven King
104 Steven King 515.123.4567 17.06.1987 24000 20000/30000 President Executive Science Park
Magdalen Centre,
Administration The Oxford
105 Neena Kochhar 515.123.4568 21.09.1989 17000 16000/20000 Vice President Executive Science Park Steven King
Magdalen Centre,
Administration The Oxford
106 Lex De Haan 515.123.4569 13.01.1993 17000 16000/20000 Vice President Executive Science Park Steven King

107 Ismael Sciarra 515.124.4369 30.09.1997 7700 5000/10000 Accountant Finance 9702 Chester Road Ismael Sciarra

108 John Chen 515.124.4269 28.09.1997 8300 5000/10000 Accountant Finance 9702 Chester Road Ismael Sciarra

109 Luis Popp 515.124.4567 07.12.1999 6900 5000/10000 Accountant Finance 9702 Chester Road Ismael Sciarra
Jose Manuel
110 Urman 515.124.4469 07.03.1998 7800 5000/10000 Accountant Finance 9702 Chester Road Ismael Sciarra
1001 Westfield
Shipping Road John Chips
JOBS
JobID Title MinSalary MaxSalary

Public

Baze de date relaționale 1

2
Accountant

Accounting
Manager
7000

11000
10000

14000

• Stochează datele în tabele, fiecare entitate 3


Administration
Assistant 4000 8000
informațională este stocată în propria tabela.
• Tabelele sunt legate folosind perechi de valori EMPLOYEES
• Minimizează redundanța EmpID FirstN LastNa Salary DepID JobID
ame me

Employe Name Salary Departme Departme Manag Job Min/ 101 William Gietz 8300 10 1
e ID nt nt adress er max
salary 102 Shelley Higgins 12000 10 2
Magdalen
Neena 103 Jennifer Whalen 4400 20 3
Centre, The
101 William Gietz 8300 Accounting Oxford Science Kochhar
Public
Park Accountant 7000/10000
Magdalen
DEPARTMENTS
Centre, The Neena DepID Name Adress Manager
102 Shelley Higgins 12000 Accounting
Oxford Science Kochhar Accounting 11000/1400
Park Manager 0
Magdalen Magdalen
Jennifer Centre, The Steven King Centre, The
103 Whalen 4400 Administration Oxford Science Administrati 10 Accounting 105
Oxford Science
Park on Assistant 4000/8000 Park

… 20 Administration
Magdalen
Centre, The
Oxford Science
100
Park
Tabele si legături
Departments
Department_id
Employees
Department_name
Employee_id
Manager_id
First_Name
FullAdress
Last_Name
Telephone
Seniority Hire_date Jobs
Age Birth_Date Job_id
Department_id Job_title
Job_id Min_Salary
Max_Salary
Dep_Adresses

Tabele si legături Department_id –PK compus +


FK
Adress_ID –PK compus + FK
Departments
Department_id - PK
Employees
Department_name
Employee_id- PK
ManagerID - FK
First_Name
AdressID
Last_Name
Telephone Adresses
Hire_date Jobs Adress_ID - PK
Birth_Date Job_ID - PK Street
Salary JobName Number
ManagerID Min_Salary Apartment
Department_id - FK Max_Salary ZipCode
Job_ID - FK City
Country
Structured Query Language
SELECT
EMPLOYEES.EMPLOYEE_ID,
EMPLOYEES.FIRST_NAME,
EMPLOYEES.LAST_NAME,
EMPLOYEES.PHONE_NUMBER,
EMPLOYEES.HIRE_DATE,
EMPLOYEES.SALARY,
JOBS.JOB_TITLE,
DEPARTMENTS.DEPARTMENT_NAME
FROM EMPLOYEES, JOBS, DEPARTMENTS
WHERE EMPLOYEES.DEPARTMENT_ID=DEPARTMENTS.DEPARTMENT_ID AND
EMPLOYEES.JOB_ID=JOBS.JOB_ID
Fisiere vs Baze de date
• Redundanta ridicata • Redundantă limitată
• Prezinta anomalii de • Rezolvă anomaliile de
actualizare actualizare
• Suport limitat pentru • Oferă suport pentru descrierea
descrierea legăturilor legăturilor dintre date
complexe dintre datele din • Ofera suport pentru acces
companii simultan

You might also like