Redirecting to
NADOS


  Prev   Next
Relational Model: represents the database as a collection of relations (tables). Relation: it is the table which contains rows and columns. Tuple: one row or entity of a relation (table) which contains single record. Attribute: each column in a relation (table). Attribute are the properties which defines a relation. Domain: possible values an attribute can take in a relation. Relation Schema: represents the name of the relation with its attribute. Degree: total number of attributes (column) in a relation. Cardinality: total number of tuples (rows) in a relation. relation Relational Model and CODD's rule: relational-model-introduction-and-codd-rules Relation Model: relational-model Difference Between DBMS and RDMS: dbms_vs_rdbms More differences between DBMS and RDMS: 1. difference-dbms-vs-rdbms 2. difference-between-rdbms-and-dbms Constraints in Relational Model: Constraints are the conditions which must hold for data present in database. These constraints checked before any operation on database. Purpose of Constraints is to maintain the data integrity during any operation like insert, update, delete. Constraints ensure the correctness of data in the database. Types of Constraints: 1. Domain Constraint. 2. Tuple Uniqueness Constraint. 3. Key Integrity Constraint. 4. Referential Integrity Constraint. 5. Entity Integrity Constraint. 1. Domain Constraint: Column of a relation allows only a same type of data to enter, based on its data type. The column doesn't accept the values of any other data type. e.g. column - Id int (10) Since Id column is of int type so, Id column allows only values of int type. domain_constraint 2. Tuple Uniqueness Constraint: It specifies that each tuple in a relation must be identified uniquely. tuple_uniqueness_constraint 3. Key integrity Constraint: Primary key and foreign key are used to define relationships between tables. Primary Key: -only one primary key is allowed in a relation. -All the values of primary key must be unique. -value of primary key can't be null. -Primary key uniquely identifies each record in a relation. primary_key 4. Foreign key constraint (Referential Integrity Constraints): Referential Integrity Constraint enforced when foreign key references the primary key of a relation. It specifies that values taken by foreign key must present in the primary key of other relation. foreign_key 5. Entity Integrity Constraint: Entity Integrity Constraint specifies that primary key Value can't be null as primary key is used to identify unique tuple in relation and if primary key allows null value then we are not able to identify unique tuple. entity_contraints Keys in Relational Model: keys Super key: it is a set of one or more attributes to uniquely identify tuples in a relation or we can say that it is a group of single or multiple keys which identifies tuples (rows) in a relation(table). Candidate key: the minimal set of attributes which can uniquely identify a tuple, or we can say that a super key with no repeated attribute. It is a subset of Super Key or minimal superkey. Primary key: a column or group of columns that uniquely identifies tuples in a relation. The primary key value cannot be null. Primary key can be selected from one of the candidate keys and becomes the identifying key of a relation. It is a subset of Candidate key. Alternate Key: All the candidate keys other than primary key. It is also known as secondary key. Composite Key: A key that consists of more than one attribute to uniquely identify tuple in a relation. Composite key may or may not be a part of foreign key. Foreign Key: when attribute of one relation references the primary key of another table. It is used to create a relationship with other relation (table). foreign_key Learn keys in detail with examples: dbms-keys Anomalies in Relational model: There is different type of anomalies that can occur in poorly planned, unnormalized databases. These anomalies can occur when the constraints are missing, or the normalization level is incorrect. Types of Anomalies: Insert Anomaly, Update Anomaly, Delete Anomaly Insert Anomaly: this anomaly occurs when attributes cannot be inserted into the database without the presence of another attribute. This mainly occurs due to inserting inconsistent data into a relation. insert_anomaly We can't add a new department unless we have at least one employee maps to the department. e.g. if we want to add a new department i.e. Sales then we can't add that department until there is at least one employee maps to the Sales Department. Update Anomaly: this anomaly occurs when one or more instances of duplicate data is updated, but not all. update_anomaly Suppose HOD of CSE department has been changed, now current HOD of CSE department is 'New_HOD_Name'. So, for updating a single entity we have to update all the instance of HOD of CSE department. Delete Anomaly: this occurs when certain attributes are lost because of the deletion of other attributes. Suppose student Ram leaves the department EEE then all the information about department EEE is lost. Video on these Anomalies: Anomalies in Relational Model
 
Run
Id Name