Relational Model Introduction

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson
Download our mobile app to listen on the go
Get App

Questions and Answers

What is a relation in the context of the relational model?

A relation is a table with columns and rows.

Define 'attribute' in the relational model.

An attribute is a named column of a relation.

What is a 'domain' in database terminology?

A domain is the set of allowable values for one or more attributes.

What is a 'tuple'?

<p>A tuple is a row of a relation.</p> Signup and view all the answers

Define the 'degree' of a relation.

<p>The degree of a relation is the number of attributes (columns) it contains.</p> Signup and view all the answers

What does 'cardinality' refer to in a relation?

<p>Cardinality refers to the number of tuples (rows) in a relation.</p> Signup and view all the answers

Define 'modality' in the context of relationships.

<p>Modality is the minimum number of entity occurrences that can be involved in a relationship.</p> Signup and view all the answers

What is a relational database?

<p>A relational database is a collection of relations (tables) that, as a group, contain the data describing a particular business environment.</p> Signup and view all the answers

Match the formal relational term with its common alternative.

<p>Relation = Table / File Tuple = Row / Record Attribute = Column / Field</p> Signup and view all the answers

Any subset of a Cartesian product is considered a relation.

<p>True (A)</p> Signup and view all the answers

What is a 'relation schema'?

<p>A relation schema is a named relation defined by a set of attribute and domain name pairs.</p> Signup and view all the answers

What is a 'relational database schema'?

<p>A relational database schema is the set of all relation schemas in the database, each with a distinct name.</p> Signup and view all the answers

The order of tuples (rows) within a relation is significant.

<p>False (B)</p> Signup and view all the answers

The order of attributes (columns) within a relation is significant.

<p>False (B)</p> Signup and view all the answers

Each cell of a relation contains exactly one _____ value.

<p>atomic (or single)</p> Signup and view all the answers

A relation can contain duplicate tuples (rows).

<p>False (B)</p> Signup and view all the answers

What is a 'superkey'?

<p>A superkey is an attribute, or set of attributes, that uniquely identifies a tuple within a relation.</p> Signup and view all the answers

What is a 'candidate key'?

<p>A candidate key is a minimal superkey with no redundancy.</p> Signup and view all the answers

What is a 'primary key'?

<p>A primary key is the candidate key that is selected to uniquely identify tuples within a relation.</p> Signup and view all the answers

What is an 'alternate key'?

<p>An alternate key is a candidate key that was not chosen to be the primary key of the relation.</p> Signup and view all the answers

Define 'foreign key'.

<p>A foreign key is an attribute or group of attributes in one relation that serves as the primary key of another relation.</p> Signup and view all the answers

What is the purpose of integrity constraints?

<p>Integrity constraints ensure that data in the database is accurate and consistent.</p> Signup and view all the answers

What are the two principal integrity rules in the relational model?

<p>Entity integrity and referential integrity.</p> Signup and view all the answers

What does a NULL value represent in a database?

<p>A NULL value represents a value for an attribute that is currently unknown or is not applicable for that specific tuple.</p> Signup and view all the answers

What does 'entity integrity' specify?

<p>Entity integrity specifies that no attribute of a primary key can be null.</p> Signup and view all the answers

What does 'referential integrity' specify?

<p>Referential integrity specifies that if a foreign key exists in a relation, its value must either match a candidate key value of some tuple in its home relation or be wholly null.</p> Signup and view all the answers

You can always insert a row into a child table, even if the foreign key value doesn't exist in the parent table's primary key.

<p>False (B)</p> Signup and view all the answers

You can always delete a row from a parent table, even if matching foreign keys exist in a child table.

<p>False (B)</p> Signup and view all the answers

Which referential integrity action prevents deleting or updating a parent key if child keys exist?

<p>RESTRICT (D)</p> Signup and view all the answers

Which referential integrity action propagates a delete or update from the parent key to dependent child keys?

<p>CASCADE (A)</p> Signup and view all the answers

What is a 'base relation'?

<p>A base relation is a named relation corresponding to an entity in the conceptual schema, whose tuples are physically stored in the database.</p> Signup and view all the answers

What is a 'view' in a relational database?

<p>A view is the dynamic result of one or more relational operations operating on base relations to produce another relation. It's a virtual relation not usually stored physically.</p> Signup and view all the answers

Views are static snapshots of data from the time they were created.

<p>False (B)</p> Signup and view all the answers

List one purpose of using views.

<p>Provide a security mechanism (hiding parts of data), permit customized data access for users, or simplify complex operations on base relations.</p> Signup and view all the answers

Updates are generally allowed on views that involve multiple base relations or aggregation/grouping operations.

<p>False (B)</p> Signup and view all the answers

Flashcards

What is a Relation?

A table with columns and rows in a relational model.

What is an attribute?

A named column of a relation (table).

What is a Domain?

The set of permissible values for one or more attributes.

What is a Tuple?

A row in a relation (table).

Signup and view all the flashcards

What is Degree?

The number of attributes in a relation.

Signup and view all the flashcards

What is Cardinality?

The maximum number of entities involved in a relationship.

Signup and view all the flashcards

What is Modality?

Minimum entity occurrences in a relationship.

Signup and view all the flashcards

What is Relation Schema?

Named relation defined by attributes and domain pairs.

Signup and view all the flashcards

What is a Relational Database Schema?

Set of relation schemas with distinct names combined.

Signup and view all the flashcards

What is a Super Key?

Attribute that uniquely identifies a tuple.

Signup and view all the flashcards

What is a Candidate Key?

Minimal super key without redundancy.

Signup and view all the flashcards

Primary Key?

Candidate key chosen for unique tuple identification.

Signup and view all the flashcards

What is an Alternate Key?

Candidate key not chosen as primary key.

Signup and view all the flashcards

What is a Foreign Key?

Links tables by referencing primary key of another table.

Signup and view all the flashcards

What are Integrity Constraints?

Ensuring data in database tables is accurate.

Signup and view all the flashcards

What is Entity Integrity?

Each primary key attribute cannot contain null values.

Signup and view all the flashcards

What is Referential Integrity?

Foreign key must match primary key or be wholly null.

Signup and view all the flashcards

What is the RESTRICT action?

Application is not allowed to delete or modify parent keys.

Signup and view all the flashcards

What is the SET NULL action?

Child keys become NULL when parent key is deleted or modified.

Signup and view all the flashcards

What is the CASCADE action?

Operation cascades to dependent child keys.

Signup and view all the flashcards

What are General Constraints?

Rules defined by users to constrain enterprise aspects.

Signup and view all the flashcards

What is a Base Relation?

Named relation corresponding to an entity in conceptual schema.

Signup and view all the flashcards

What is a View?

Dynamic result of operations on base relations.

Signup and view all the flashcards

What is a Relation?

A table is physically represented as what?

Signup and view all the flashcards

Virtual Relation

Virtual relation produced upon request, not physically stored.

Signup and view all the flashcards

Study Notes

Introduction to the Relational Model

  • E. F. Codd first proposed the relational model in his paper 'A relational model of data for large shared data banks' in 1970.
  • Relational databases are founded on mathematical principles.
  • Relational databases are made of a group of relations that hold data describing a business environment.

Terminology

  • The relational model is based on the mathematical concept of a relation, and physically, this is represented as a table.
  • A relation is a table with columns and rows.
  • An attribute is a named column of a relation.
  • A domain is the set of allowable values for one or more attributes.
  • A tuple is a row of a relation.
  • Degree refers to the number of attributes in a relation.
  • Cardinality is the maximum number of entities in a relationship.
  • Modality is the minimum number of entity occurrences in a relationship.

Mathematical Relations

  • Relation means reviewing concepts from mathematics.
  • A Cartesian product, D1 X D2, is a set of all ordered pairs where the first element is a member of D1 and the second is a member of D2.
  • Any subset of a Cartesian product forms a relation
  • It's possible to denote relation pairs with conditions.

Database Relations

  • Relation schema is a named relation defined by a set of attributes and domain name pairs.
  • Relational database schema includes a set of relation schemas, each with a distinct name.
  • Example of an employee's relation schema: Employees (empid, empname, empemail, empaddress, deptid).
  • Example of a department's relation schema: Departments (deptid, deptname, locid).
  • Example of a locations' relation schema: Locations (locid, locname, locaddress).

Properties of Relations

  • Relation names must be distinct within a relational schema.
  • Each cell of a relation contains exactly one atomic value.
  • Each attribute has a distinct name.
  • All values in an attribute come from the same domain.
  • Each tuple is distinct; no duplicate tuples exist.
  • The order of tuples has no theoretical significance.
  • The order of attributes has no significance.

Relational Keys

  • In each relation there are no duplicate tuples.
  • Relational keys are attributes used to identify each tuple uniquely.
  • Super key: Attribute or set of attributes that uniquely identify a tuple in a relation.
  • Candidate key: Minimal super key with no redundancy.
  • Primary key: Candidate key chosen to uniquely identify tuples within the relation.
  • Alternate Key: Candidate key not chosen as the primary key.
  • Foreign Key: Attribute or group of attributes that serves as the primary key of one relation and appears in another.

Integrity Constraints

  • Integrity constraints ensure data accuracy.
  • Inaccurate data can lead to an unreliable database system and affect business operations.
  • Null values represent values for an attribute that are unknown or not applicable.
  • Two principal rules for the relational model: entity integrity and referential integrity.

Integrity Constraint Rules

  • Entity Integrity: Primary key cannot be null, and it must be unique.
  • Referential Integrity: Foreign key must match a primary key value in its home relation or be wholly null.

Actions for Referential Integrity

  • For INSERT operations: Child table insert fails if no matching primary key exists in the parent table.
  • For DELETE operations: Deletion fails if matching foreign key exists in a child table.
  • For UPDATE operations: Update fails if a match foreign key exists in the child's table, also fails if there is no existing primary key in the parent's table.

ON DELETE and ON UPDATE Actions

  • ON DELETE and ON UPDATE actions for foreign keys can be: NO ACTION, RESTRICT, SET NULL, SET DEFAULT, or CASCADE.
  • If unspecified, the default action is NO ACTION.
  • NO ACTION: No special action occurs when a parent key is modified or deleted.
  • RESTRICT: Prohibits deleting (ON DELETE RESTRICT) or modifying (ON UPDATE RESTRICT) a parent key if child keys map to it.
  • SET NULL: Sets child key columns to SQL NULL values when a parent key is deleted (ON DELETE SET NULL) or modified (ON UPDATE SET NULL).
  • SET DEFAULT: Sets child key columns to a default value instead of NULL.
  • CASCADE: Propagates delete or update operations on the parent key to each dependent child key.
  • ON DELETE CASCADE: Each row in the child table associated with the deleted parent row is also deleted.
  • ON UPDATE CASCADE: Values stored in each dependent child key are modified to match the new parent key values.
  • General Constraints: Additional rules that have been specified by users or database administrators that define or constrain some aspect of the enterprise.

Views

  • Views are virtual relations that do not exist in the database but are produced upon request.
  • Contents of views are defined by queries on base relations.
  • Views are dynamic; changes to base relations are immediately reflected.

Purpose of Views

  • Views provide security by hiding parts of the database from certain users.
  • Views let users access data in a customized way.
  • Views simplify complex operations on base relations.

Updating Views

  • All updates to a base relation should reflect in all views referencing it.
  • If a view updates, the underlying base relation should mirror the change.
  • Updates are only allowed if the query involves a single base relation & contains a candidate key of the base relation.
  • Updates are not allowed if the query involves multiple base relations.
  • Updates are not allowed if the query involves aggregation or grouping operations.

Classes of Views

  • Views that are theoretically not updatable.
  • Views that are theoretically updatable.
  • Views that are partially updatable.

Studying That Suits You

Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

Quiz Team

Related Documents

More Like This

Relational Databases and SQL Quiz
5 questions
Relational Model Concepts
41 questions

Relational Model Concepts

TopNotchRaleigh8899 avatar
TopNotchRaleigh8899
Use Quizgecko on...
Browser
Browser