You are on page 1of 24

Metadata refers to data about data.

In the context of databases, metadata is information that describes the


characteristics of the data stored in the database. This information can include:

1. Data Definitions: Descriptions of data types, lengths, and formats used in the database.

2. Table and Column Descriptions: Information about the tables, columns, and their relationships.

3. Index Information: Details about indexes, including which columns are indexed and how the indexes
are structured.

4. Constraints: Information about constraints, such as primary keys, foreign keys, and unique constraints.

5. Security Information: Metadata may include details about user permissions and access controls.

6. Data Usage Statistics: Information about the usage patterns of data, which can be useful for
performance tuning and optimization.

Modelul Relațional de Date:

 Reprezintă datele ca tabele cu rânduri și coloane.

 Definește relațiile dintre tabele folosind chei.

 Este unul dintre cele mai folosite modele de date și este implementat frecvent în sistemele de gestionare a bazelor de
date relaționale (RDBMS).

Modelul de Date Entitate-Relație (ER Model):

 Reprezintă entități (obiecte, lucruri) și relațiile dintre ele printr-un diagramă.


 Entitățile sunt reprezentate ca dreptunghiuri, iar relațiile sunt reprezentate prin linii care leagă entitățile

.
Relational Database Management System RDBMS
Clasificarea instructiunilor sql:
DML= data manipulation language : SELECT, INSERT DELETE, UPDATE, MERGE
DDL data definition language : CREATE, ALTER, DROP, RENAME, TRUNCATE, COMMENT
Components of a DBMS
• Query processor
• DML preprocessor
• DDL compiler
• Data dictionary
• Run-time database
manager
Superkey = an attribute or set of attributes that uniquely identifies a tuple within a
Relation

Relational Integrity
• Entity Integrity: in a relation/table, a primary key of a
tuple, or any part of it, can never take a null value.

• Referential Integrity: if a foreign key exists in a


relation, either the foreign key value must match a
candidate key value of some tuple in its home relation
or the foreign key value must be wholly null.
FUNCTIONAL DEPENDENCY

FD3. (Tranzitivitate) Daca r satisface X → Y ¸si Y → Z, atunci r satisface X → Z.


FD4. (Pseudotranzitivitate) Daca r satisface X → Y ¸si Y W → Z, atunci r satisface XW → Z
FD5. (Uniune) Daca r satisface X → Y ¸si X → Z, atunci r satisface X → Y Z.
FD6. (Descompunere) Daca r satisface X → Y Z, atunci r satisface X → Y ¸si X → Z.
Insertion Anomaly:
 An insertion anomaly occurs when it is not possible to add data to the database without including additional,
unnecessary information.
 This typically happens when there is a dependency between two sets of data, and one cannot be added until the other
is present.
 For example, consider a table where information about a student's courses cannot be added until the student has
enrolled in at least one course. This can lead to the need for dummy or placeholder records.

Deletion Anomaly:
 A deletion anomaly occurs when deleting data from the database results in the loss of unintended information.
 This typically happens when there is a dependency between two sets of data, and removing one set of data also
removes information in another set.
 For example, consider a table where information about a professor is stored along with the courses they teach. If a
professor teaches only one course and that course is canceled, deleting the course information would also delete the
professor's details.

Modification Anomaly:

 A modification anomaly occurs when updating data in the database leads to inconsistencies.
 This can happen when the same information is stored in multiple places, and updating one instance of the
information does not update all instances.
 For example, consider a table where the price of a product is stored in multiple records. If the price changes,
updating one record might lead to inconsistencies if all records are not updated.
Normalization involves breaking down large tables into smaller ones and establishing
relationships between them to eliminate or reduce these update anomalies.

Lossless join decomposition is an important concept in database normalization.


It ensures that when a relation (table) is decomposed into smaller relations, and later these
smaller relations are joined together, the original information can be reconstructed without
loss of information. This is crucial for maintaining the consistency and integrity of the
database.

1. From
2. Where
3. Group by
4. Having
5. Select
6. Order by
7. Top/limit
8. Unique, primary key => iindex creation

Limbaje ale bazei de date

 Ddl
 Dml
 Dql

CURS 2-4

Superkey = an attribute or set of attributes that uniquely identifies a tuple within a

relation

• Keys can be

– Single attribute = a key consisting of exactly one attribute

– Composite key = a key consisting of more than one attribute

• Candidate key = a superkey such that no proper subset is a superkey within the

relation

– Uniqueness – the values of the candidate key uniquely identify each tuple

– Irreductibility – no proper subset of K has the uniqueness property

• Candidate key can be

– Primary Key = a candidate key selected by the database designer to uniquely

identify tuples within a relation

– Alternate Keys = all other candidate keys, except the one elected to be the primary

key
• Foreign key = an attribute or a set of attributes within one relation that matches the

candidate key of other (possibly the same) relation


JOINS

Right outer join


Right Semi join

Anti join

Union

Set difference
Intersection
CURS 5 6
Check 2nd normal form

Daca a mai era in dreapra vreunei reguli at inlocuiam cu substitutia si verificam iar daca e
candidate key cu subseturile si updatam lista de atribute prime

Adica daca orice subset al ck are regula ca determina un non prime att => nu e 2nd form
3rd formal form

Cautam candidate key


Scriem prime atr
Vedem daca npa->npa
BCNF
TRANZACTIE:

- Izolare
- Atomicitate
- Durabilitate
- Consistenta
 Toate produsele din categoria laptop wor avea atributul os egal cu val windows

mysql> SELECT JSON_OBJECT('id', 87, 'name', 'carrot');


+-----------------------------------------+
| JSON_OBJECT('id', 87, 'name', 'carrot') |
+-----------------------------------------+
| {"id": 87, "name": "carrot"} |
 +-----------------------------------------+

 SELECT JSON_OBJECT('name', 'Jim', 'age', 20);


 +---------------------------------------+
 | JSON_OBJECT('name', 'Jim', 'age', 20) |
 +---------------------------------------+
 | {"age": 20, "name": "Jim"} |
 +---------------------------------------+
1.Nu reprezinta o cerinta pt sist de gestiune al bz de date

 Extensibilitate
 Toleranta la partitionare
 Usirinta in mentenanta

2.

 3,13
 33, 19
 11, 19

3.
4.

5. Ce nu este sql ? - Un limbaj de programare orientata pe obiecte


CONSTRAINTS

Common SQL constraints are

– NOT NULL

– PRIMARY KEY

– FOREIGN KEY

– DEFAULT

– UNIQUE

– CHECK

– INDEX
CHECK Constraint
• Limit the values for a specified column or limit the

values in certain columns based on other values in

other columns of the same row

• The predicate cannot contain queries, but may call

user-defined/system functions

• Example:

ALTER TABLE Students

ADD CONSTRAINT CK_Students_Valid_Id_Name CHECK (Id >= 0 AND Name <> ‘’);

Why Views?

• Hide some data from some users

• Make some queries easier

• Modularity of database access (customized access =

access to parts of the database)

• Powerful and flexible security mechanism


Clientul C1 executa tranzactiile T1:T2 si clientul C2 executa concurent tranzactille T3:T4. Cate
"equivalent sequential orders" sunt posibile pentru aceste patru tranzactii? Permutari de 4 => 24
None
aca T(X) este o tabela si myview o vedere care din urm comenzi sql sunt valide ? - Select * from
myview - Alter view myview as select * from t - Drop view myview

Care dintre urmatoarele afirmatii sunt adevarate *


o Mai multe procese pot sa detina Shared locks pentru aceeasi resursa
9 Un singur proces poate sa detina un Exclusive lock pentru o resursa

You might also like