Professional Documents
Culture Documents
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.
Este unul dintre cele mai folosite modele de date și este implementat frecvent în sistemele de gestionare a bazelor de
date relaționale (RDBMS).
.
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.
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.
1. From
2. Where
3. Group by
4. Having
5. Select
6. Order by
7. Top/limit
8. Unique, primary key => iindex creation
Ddl
Dml
Dql
CURS 2-4
relation
• Keys can be
• 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
– 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
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
- Izolare
- Atomicitate
- Durabilitate
- Consistenta
Toate produsele din categoria laptop wor avea atributul os egal cu val windows
Extensibilitate
Toleranta la partitionare
Usirinta in mentenanta
2.
3,13
33, 19
11, 19
3.
4.
– NOT NULL
– PRIMARY KEY
– FOREIGN KEY
– DEFAULT
– UNIQUE
– CHECK
– INDEX
CHECK Constraint
• Limit the values for a specified column or limit the
user-defined/system functions
• Example:
ADD CONSTRAINT CK_Students_Valid_Id_Name CHECK (Id >= 0 AND Name <> ‘’);
Why Views?