C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
Relational Calculus
Types of Relational calculus:
1. Tuple Relational Calculus (TRC)
Notation:
{T | P (T)} or {T | Condition (T)}
Where T is the resulting tuples P(T) is the condition used to fetch T. For example:
{ T.name | Author(T) AND T.article = 'database' }
OUTPUT: This query selects the tuples from the AUTHOR relation. It returns a tuple with 'name' from Author who has written an article on 'database'. TRC (tuple relation calculus) can be quantified. In TRC, we can use Existential (∃) and Universal Quantifiers (∀). For example:
{ R| ∃T ∈ Authors(T.article='database' AND R.name=T.name)}
Output: This query will yield the same result as the previous one. 2. Domain Relational Calculus (DRC)
Notation:
{ a1, a2, a3, ..., an | P (a1, a2, a3, ... ,an)}
Where a1, a2 are attributes For example:
{< article, page, subject > | ∈ TheDeveloperBlog ∧ subject = 'database'}
Output: This query will yield the article, page, and subject from the relational TheDeveloperBlog, where the subject is a database.
Next TopicDBMS SQL Introduction
|