Docsity

Relational Algebra: Concepts, Operations, and Codd's Rules, Study notes of Database Management Systems (DBMS)

Partial preview of the text

Download Relational Algebra: Concepts, Operations, and Codd's Rules and more Study notes Database Management Systems (DBMS) in PDF only on Docsity!

Relational Model

Relational Model

  • It was proposed by Dr. E.F. Codd.
  • It uses the concept of relations to represent each and every file.
  • Relations are Two-Dimensional Tables.
  • It is easy to implement and easy to simplification in the operations to manipulate the data.
  • This is the most popular data model.
  • It uses the primary key and secondary key to connect any two files.
  • Dr. Edgar F. Codd (E.F. Codd) in 1985 presents his 13 rules for a database to test the concept of DBMS against his relational model, and if a database follows the rule, it is called a true relational database (RDBMS).

Codd Rules

  • Rule 1: Information Rule
  • A database contains various information, and this information must be stored in each cell of a table in the form of rows and columns.
  • Rule 2: Guaranteed Access Rule
  • Every single or precise data (atomic value) may be accessed logically from a relational database using the combination of primary key value, table name, and column name.
  • Rule 3: Systematic Treatment of Null Values

Codd Rules

  • This rule defines the systematic treatment of Null values in database records. The null value has various meanings in the database, like missing the data, no value in a cell, inappropriate information, unknown data and the primary key should not be null.
  • Rule 4: Active Online Catalog
  • The structure description of the entire database must be stored in an online catalog, known as data dictionary , which can be accessed by authorized users.

Codd Rules

  • All the views of a database, which can theoretically be updated, must also be updatable by the system
  • Rule 7: Relational Level Operation (High-Level Insert, Update and delete) Rule
  • A database system should follow high-level relational operations such as insert, update, and delete in each level or a single row.
  • It also supports union, intersection and minus operation in the database system.
  • Rule 8: Physical Data Independence

Codd Rules

  • The data stored in a database must be independent of the applications that access the database.
  • Any change in the physical structure of a database must not have any impact on how the data is being accessed by external applications.
  • Rule 9: Logical Data Independence Rule • It is similar to physical data independence.
  • It means, if any changes occurred to the logical level (table structures), it should not affect the user's view (application).

Codd Rules

  • The end-user must not be able to see that the data is distributed over various locations.
  • Users should always get the impression that the data is located at one site only.
  • This rule has been regarded as the foundation of distributed database systems.
  • Rule 12: Non-Subversion Rule
  • If a system has an interface that provides access to low- level records, then the interface must not be able to

Codd Rules

subvert the system and bypass security and integrity constraints.

  • Tuple − A single row of a table, which contains a single record for that relation is called a tuple.
  • Relation instance − A finite set of tuples in the relational database system represents relation instance. Relation instances do not have duplicate tuples.
  • Relation schema − A relation schema describes the relation name (table name), attributes, and their names.
  • Relation key − Each row has one or more attributes, known as relation key, which can identify the row in the relation (table) uniquely.
  • Attribute domain − Every attribute has some pre-defined value scope, known as attribute domain.

Terminologies

  • Fundamental Operations
  • Select (σ)
  • Project (∏)
  • Union Operation ( 𝖴 )
  • Set Difference (−)
  • Cartesian Product (Χ)
  • Rename Operation (ρ)
  • Additional Operations
    • Set Intersection (∩)
    • Assignment Operation (=)
    • Natural Join ( ⋈ )
    • Division Operation (÷)
    • Outer Join
    • Left Outer Join ( ⟕ )
    • Right Outer Join ( ⟕ )
    • Full Outer Join ( ⟕ )

Relational Algebra

Example-

  • Q: Write a RA expression to find all the instrcutors working in “finance” department.
  • σDept_Name=“Finance”(Instructor)
  • Output:

Example-

  • Q: Find all instructors with salary greater than 87000.
  • σSalary>87000(Instructor)
  • Output:

Project (∏)

  • Returns argument relation with certain attributes left out.
  • It’s a unary operator.
  • In result, duplicate values are skipped.
  • Syntax: ∏attribute1, attriobute2,... (Relation)

Example - 1

  • Q: List all instructor ‘ID’, ‘Name’ and ‘Salary’.
  • ∏ID, Name, Salary (INSTRUCTOR) • Output: