Relational Database Model: Tables and Logic

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

Which of the following best describes the role of a relational model in database management?

  • It allows programmers to interact with data logically, rather than physically. (correct)
  • It focuses primarily on the hardware configurations of the database.
  • It manages the network connections between databases.
  • It presents a physical storage layout of data.

What is the significance of structural and data independence in the context of a table within a relational database?

  • It makes the table harder to modify without affecting other parts of the database.
  • It ensures the table is heavily dependent on other tables for its structure and data.
  • It allows for easier modifications without impacting other database elements. (correct)
  • It prevents any changes to the table's structure or data format.

How does a 'relation' relate to a 'table' in the context of relational databases, according to the model's creator, Codd?

  • A relation is a more complex structure than a table, incorporating multiple tables.
  • A relation is considered a specialized view derived from one or more tables.
  • A relation is synonymous with a table. (correct)
  • A relation is an outdated term, replaced by 'table' in modern database systems.

Within the structure of a relational database table, what is referred to as an 'attribute'?

<p>A column of the table. (B)</p> Signup and view all the answers

What term is used to describe a row in a relational database table?

<p>Tuple (C)</p> Signup and view all the answers

Why is it important for each cell in a relational database table to contain only atomic values?

<p>To ensure that each entry is indivisible, maintaining simplicity and data integrity. (C)</p> Signup and view all the answers

What requirement applies to all entries within a specific column in a relational database table?

<p>They must all conform to the same data format. (C)</p> Signup and view all the answers

What is defined as the 'attribute domain' in the context of relational databases?

<p>The specific range of values allowed for each column. (D)</p> Signup and view all the answers

A database designer is determining the structure of a table. How should the order of rows and columns be handled?

<p>The order is immaterial to the DBMS. (C)</p> Signup and view all the answers

What is a key requirement for the attributes of each table in a relational database?

<p>Each table must have an attribute or a combination of attributes that uniquely identifies each row. (B)</p> Signup and view all the answers

Why is defining a relational schema important for each entity in a database?

<p>It outlines the structure, including the table name and its attributes. (D)</p> Signup and view all the answers

Why should different entities be related to one another in a database through comparison of their values?

<p>They can only be meaningfully compared if their values are drawn from the same domain. (C)</p> Signup and view all the answers

What do the terms 'degree' and 'cardinality' refer to in the context of a relation?

<p>Degree refers to the number of attributes and cardinality refers to the number of tuples. (A)</p> Signup and view all the answers

You have a table representing departments in a university. It contains attributes for department name, address, and extension. If the table has 10 rows, what are the degree and cardinality?

<p>Degree: 3, Cardinality: 10 (C)</p> Signup and view all the answers

In the context of database keys, how does a 'composite key' differ from other types of keys?

<p>It is composed of more than one attribute. (A)</p> Signup and view all the answers

Which of the following describes a 'superkey'?

<p>Any key that uniquely identifies each row in a table. (D)</p> Signup and view all the answers

How does a 'candidate key' relate to a 'superkey'?

<p>A candidate key is a superkey without redundancies, also known as a minimal superkey. (A)</p> Signup and view all the answers

What is the main purpose of a 'primary key' in a database table?

<p>To uniquely identify each record in the table and ensure entity integrity. (B)</p> Signup and view all the answers

What are the implications of having a 'null' value in a database attribute?

<p>It can represent no data entry, an unknown value, or a 'not applicable' condition. (C)</p> Signup and view all the answers

Why is controlled redundancy necessary in relational databases?

<p>To facilitate linking of tables through shared attributes which enables relationships. (A)</p> Signup and view all the answers

In database terms, what does 'referential integrity' ensure?

<p>That foreign keys always refer to an existing valid tuple (row) in another relation. (D)</p> Signup and view all the answers

What is the primary purpose of a 'secondary key'?

<p>To be used strictly for data retrieval purposes. (C)</p> Signup and view all the answers

What best describes the function of a 'data dictionary' in a larger database system?

<p>It provides a detailed accounting of all tables within the user-created database. (B)</p> Signup and view all the answers

What is a key component of a 'data dictionary'?

<p>All the attribute names and characteristics for each table. (A)</p> Signup and view all the answers

What is meant when a data dictionary is described as 'the database designer's database'?

<p>It stores the database's development history, capturing design decisions about tables and structures. (B)</p> Signup and view all the answers

How does a 'system catalog' relate to a 'data dictionary'?

<p>They are often used interchangeably, with the system catalog containing detailed descriptions of database objects. (A)</p> Signup and view all the answers

How can one query a 'system catalog'?

<p>Just like querying any user-created table. (A)</p> Signup and view all the answers

Which type of relationship is considered the relational modeling ideal and should be the norm in any relational design?

<p>1:* relationship (D)</p> Signup and view all the answers

If one entity can be related to only one other entity, what type of relationship exists?

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

Why are ':' relationships problematic in relational databases?

<p>They cannot be directly implemented in the relational model. (B)</p> Signup and view all the answers

How can a ':' relationship be addressed to properly fit the relational model?

<p>By changing it into two 1:* relationships using an intermediate composite entity. (D)</p> Signup and view all the answers

What is the standard method for implementing a 1:* relationship in a relational database?

<p>By putting the primary key of the '1' side on the table of the 'many' side as a foreign key. (A)</p> Signup and view all the answers

Where does data redundancy typically arise, and what can it lead to in a database?

<p>It leads to data anomalies and can destroy the effectiveness of the database. (D)</p> Signup and view all the answers

How do 'foreign keys' help manage data redundancy in relational databases?

<p>They control data redundancies by using common attributes shared by tables. (D)</p> Signup and view all the answers

How are indexes best described in relational databases?

<p>Indexes are used to logically access rows in a table. (D)</p> Signup and view all the answers

What is the purpose of the index key?

<p>It serves as the index's reference point. (A)</p> Signup and view all the answers

What does a unique index enforce in a database?

<p>An index in which the index key can have only one pointer (row) associated with it (C)</p> Signup and view all the answers

In a relational database, what is true about the number of tables each index is associated with?

<p>Each index is associated with only one table to maintain simplicity and focus. (B)</p> Signup and view all the answers

Why did Codd formulate his 12 rules for relational databases?

<p>Due to concern that many vendors were marketing products as “relational” even though those products did not meet minimum relational standards (A)</p> Signup and view all the answers

According to Codd's rules, how must all information in a relational database be represented logically?

<p>As column values in rows within tables. (D)</p> Signup and view all the answers

What does Codd's rule of 'Guaranteed Access' ensure in a relational database?

<p>That every value in a table is accessible through the combination of table name, primary key value, and column name. (A)</p> Signup and view all the answers

Flashcards

Relational Database Model

A logical way of viewing data, rather than physically.

Relational Model Components

The basic components are relations implemented through tables in a relational DBMS.

Table Structure

Tables are organized into rows (tuples) and columns (attributes).

Relational Database Topics

Relational database operators, data dictionary, and system catalog.

Signup and view all the flashcards

Data Redundancy Handling

Handled through relationships and proper database design.

Signup and view all the flashcards

Indexing

Used to speed up data retrieval.

Signup and view all the flashcards

Relational Model Advantage

Enables programmer to view data logically rather than physically.

Signup and view all the flashcards

Table Definition

Two-dimensional structure composed of rows and columns.

Signup and view all the flashcards

Entity Set

A group of related entities.

Signup and view all the flashcards

Relation

Synonym for table used by Codd.

Signup and view all the flashcards

Persistent Relation

A table whose contents can be permanently saved for future use.

Signup and view all the flashcards

Attributes

Columns in a relational model table.

Signup and view all the flashcards

Tuples

Rows in a relational model table.

Signup and view all the flashcards

Table Row (Tuple)

Represents a single entity occurrence and must be distinct.

Signup and view all the flashcards

Single Data Value

Atomic value within a cell in a relation.

Signup and view all the flashcards

Attribute Domain

Specific range of values for a column.

Signup and view all the flashcards

Degree of a Relation

Number of attributes in a relation.

Signup and view all the flashcards

Cardinality of a Relation

Number of tuples in a relation.

Signup and view all the flashcards

Attribute

Named column within a relational table, drawing values from a domain.

Signup and view all the flashcards

Domain

The set of possible values for an attribute.

Signup and view all the flashcards

Functional Dependence

B is functionally dependent on A if each value in column A determines one and only one value in column B.

Signup and view all the flashcards

Composite Key

Composed of more than one attribute.

Signup and view all the flashcards

Key Attribute

Any attribute that is part of a key.

Signup and view all the flashcards

Superkey

A key that uniquely identifies each row in a table.

Signup and view all the flashcards

Candidate Key

A superkey without redundancies.

Signup and view all the flashcards

Primary Key

Unique to ensure each row is uniquely identified.

Signup and view all the flashcards

Entity Integrity

A table exhibiting entity integrity.

Signup and view all the flashcards

Nulls

No data entry in a field.

Signup and view all the flashcards

Controlled Redundancy

Makes the relational database work, sharing attributes between tables.

Signup and view all the flashcards

Foreign Key (FK)

Attribute whose values match primary key values in another table.

Signup and view all the flashcards

Referential Integrity

FK contains a value referring to an existing tuple in another relation.

Signup and view all the flashcards

Secondary Key

Key used for data retrieval but doesn't guarantee unique outcomes.

Signup and view all the flashcards

Entity Integrity Requirement

All primary key entries are unique and not null.

Signup and view all the flashcards

Data Dictionary

Metadata about database tables.

Signup and view all the flashcards

Data Dictionary Purpose

Provides detailed accounting of all tables within the database.

Signup and view all the flashcards

System Catalog

Contains metadata describing all objects within the database.

Signup and view all the flashcards

One to Many Relationship (1:*)

Ideal database design.

Signup and view all the flashcards

One to One Relationship (1:1)

Rare relationships, can mean design errors.

Signup and view all the flashcards

Many to Many Relationships (:)

Implemented by breaking up into a set of 1:* relationships.

Signup and view all the flashcards

Data Redundancy

destroy the effectiveness of the database

Signup and view all the flashcards

Indexes

Logically access rows.

Signup and view all the flashcards

Study Notes

Chapter 3 Study Notes

  • The relational database model takes a logical view of data.
  • Basic components of the relational model that are relations implemented through tables, in a relational DBMS.
  • Relations are organized in tables of rows (tuples) and columns (attributes).
  • Relational database operators, the data dictionary, and the system catalog are essential components.
  • Data redundancy is handled in the relational database model.
  • Indexing refers to the systematic arrangement of data to facilitate easy retrieval and usage. This process is crucial in various fields such as databases, libraries, and information systems, where vast amounts of information need to be organized efficiently. By creating indices, one can enhance the speed and efficiency of searching for specific data, allowing users to locate relevant information quickly. Various indexing techniques exist, such as inverted indexing, which is commonly used in search engines, and B-trees, often employed in database systems. Understanding the principles and methods of indexing is essential for effective data management and retrieval. plays a crucial role in enhancing the performance of relational databases by significantly speeding up data retrieval processes. It allows for efficient querying, sorting, and filtering, thereby improving overall database efficiency.

Logical View of Data

  • The relational model enables programmers to view data logically instead of physically.
  • Tables offer structural and data independence.
  • Tables resemble a file from a conceptual point of view.
  • Tables are easier to understand than hierarchical and network database predecessors.

Tables and Relations

  • A table is a two-dimensional structure composed of rows and columns
  • A table contains group of related entities, also known as an entity set.
  • Terms 'entity set' and 'table' are often used interchangeably.
  • Table can also be called a relation.
  • Codd, the creator of the relational model, used "relation" as a synonym for table.
  • Tables can be thought of as persistent relations, where contents are saved for future use.
  • Columns of tables are called attributes and rows of tables are called tuples.

Properties of a Relation in a Relational Database

  • A table is perceived as a two-dimensional structure composed of rows and columns.
  • Each table row, also known as a tuple, represents a single entity occurrence within the entity set and must be distinct. Duplicate rows are not allowed in a relation.
  • Each table column represents an attribute, with each column having a distinct name.
  • Each cell, or the intersection of a column and row, should contain only one data value.
  • Multiple values are not allowed in cells of a relation.
  • All values in a column must conform to the same data format, e.g., if an attribute is assigned an integer data format, all values in the column representing that attribute must be integers.
  • Each column has a specific range of values known as the attribute domain.
  • The order of the rows and columns is immaterial to the DBMS.
  • Each table must have an attribute, or a combination of attributes, that uniquely identifies each row.

Relational Schema

  • A relational schema can be defined for each entity.
  • A relational schema is a textual representation of database tables.
  • Each table is described by its name followed by the list of its attributes in parentheses, exemplified by LECTURER(EMP_NUM, LECTURER_OFFICE, LECTURER_EXTENSION, LECTURER_HIGH_DEGREE).

Attributes and Domains

  • Each attribute is a named column within the relational table and draws its values from a domain.
  • A domain is the set of possible values for an attribute.
  • The domain of values for an attribute should contain only atomic values and any one value should not be divisible into components.
  • Only attributes with one value are allowed.
  • Each domain is defined by its data type, for example, string, integer.
  • Relating different entities to one another can only be achieved by comparison of their values.
  • Values can only be meaningfully compared if they are drawn from the same domain.

Degree and Cardinality in the Relational Model

  • Degree and cardinality are two key properties.
  • A relation with N columns and N rows has a degree of N and a cardinality of N.
  • The degree of a relation is the number of its attributes.
  • The cardinality of a relation is the number of its tuples.
  • The product of a relation's degree and cardinality is the number of attribute values it contains.

Keys

  • STU_NUM determines STU_LNAME.
  • STU_NUM determines STU_LNAME, STU_FNAME, and STU_INIT.
  • STU_LNAME does not determine STU_NUM.
  • STU_CLASS depends on Hours completed.
  • Functional dependence is when the attribute B is functionally dependent on A if each value in column A determines one and only one value in column B.
  • For example, STU_PHONE is functionally dependent in STU_NUM.
  • STU_NUM is not functionally dependent on STU_PHONE because phone 2267 is associated with two student numbers.

Relational Database Keys

  • A composite key is composed of more than one attribute.
  • A key attribute is any attribute that is part of a key.
  • A superkey is any key that uniquely identifies each row.
  • A candidate key is a superkey without redundancies, also it is a minimal superkey.
  • STU_NUM and STU_LNAME together are a superkey but not a candidate key.
  • A primary key must be unique to ensure that each row is uniquely identified.
  • Primary keys exhibit entity integrity and cannot contain nulls.
  • Primary keys are underlined in relational schemas like: LECTURER(EMP_NUM, LECTURER_OFFICE, LECTURER_EXTENSION, LECTURER_HIGH_DEGREE).
  • Nulls represent no data entry but should be avoided in attributes other than the primary key when possible.
  • Nulls can represent an unknown attribute value, a known but missing attribute value, or a "not applicable" condition.
  • Nulls can create problems when functions, like COUNT, AVERAGE, and SUM, are used.
  • Nulls can create logical problems when relational tables are linked.
  • Controlled redundancy helps make the relational database work.
  • Tables within the database must share the attributes that enable them to be linked together.
  • Occurrences of values in a table are not redundant when they are required to make the relationship work.
  • Redundancy exists only when there is unnecessary duplication of attribute values.
  • Foreign keys (FK) are attributes whose values match primary key values in the related table, they establish a referential integrity.
  • Referential integrity is when a foreign key contains a value that refers to an existing valid tuple in another relation.
  • Secondary keys are strictly for data retrieval and provides key as CUST_LNAME, and CUST_PHONE to return data.
  • Secondary keys do not necessarily yield a unique outcome.

Integrity Rules

  • Entity integrity ensures all primary key entries are unique and no part of a primary key can be null.
  • Each row has a unique identity, and foreign key values can properly reference primary key values.
  • Referential integrity dictates that a foreign key may have a null entry or match a primary key value in the related table. Every non-null foreign key must reference an existing primary key value.
  • In the absence of a corresponding value, it's possible for an attribute to not have one; however, there cannot be an invalid entry.
  • The referential integrity constraint prevents the deletion of a row in one table if its primary key has matching foreign key values in another table.
  • NOT NULL constraint prevents a table entry from being saved without a value in a specific column.
  • UNIQUE constraint restricts placing any duplicate values in a column

Data Dictionary

  • Data dictionaries provide detailed accounting of all tables found within the user/designer-created database.
  • A data dictionary contains at least all the attribute names and characteristics for each table in the system.
  • Data dictionaries contain metadata, which is data about data.
  • Data dictionaries are sometimes described as "the database designer's database" because they record the design decisions about tables and their structures.
  • A system catalog is a detailed system data dictionary that describes all objects within the database, including table creator and creation date.
  • Terms "system catalog” and “data dictionary” are often used interchangeably.
  • Can be queried just like any user/designer-created table.

Relationships within the Relational Database

  • 1:* relationships should be the norm in relational database design and are the ideal relationship.
  • 1:1 relationships should be rare in any relational database design.
  • : relationships cannot be implemented as such in the relational model.
  • : relationships can be changed into two 1:* relationships.

The 1:* Relationship

  • 1:* relationships are a relational database norm is found in any database environment.
  • They are implemented by putting the primary key of the "1" side on the table of the "many" side as a foreign key.

The 1:1 Relationship

  • With a 1:1 relationship, one entity can be related to other entity, and vice versa
  • 1:1 relationships implies that entity components are not defined properly.
  • It could mean that the two entites actually belong in the same table
  • As rare as 1:1 relationships should be, certain conditions absolutely require their use

The : Relationship

  • The *: * relationship occurs by students enrolling for courses
  • : * can be implemented by breaking it up to produce a set of 1: relationships.
  • *: * can avoid problems inherent to relationship by creating a composite entity or bridge entity.
  • A composite entity requires *: to 1: conversion.
  • The composite entity table must contain at least the primary keys of original tables.
  • The linking table contains multiple occurrences of the foreign key values.
  • Additional attributes may be assigned as needed.

Data Redundancy Revisited

  • Data redundancy leads to data anomalies.
  • Anomalies can destroy the effectiveness of the database.
  • Foreign keys control data redundancies by using common attributes shared by tables.
  • Foreign keys are crucial to exercising data redundancy control.
  • Sometimes, data redundancy is necessary.

Indexes

  • Indexes are an arrangement used to logically access rows in a table.
  • An index key is the index's reference point, points to data location identified by the key, and supports Ordered arrangement of keys and pointers.
  • A unique index means the index key can have only one pointer value (row) associated with it.
  • Each index is associated with only one table.

Codd's Relational Database Rules

  • In 1985, Codd published a list of 12 rules to define a relational database system because vendors were marketing products as relational even though those products did not meet minimum relational standards.
  • Rule 0: The database must use its relational facilities exclusively to manage the database.
  • Rule 1: All information is logically represented as column values in rows within tables.
  • Rule 2: Every value is accessible through a combination of table name, primary key value and column name.
  • Rule 3: Nulls must be treated in a systematic way, independent of data type.
  • Rule 4: Metadata must be stored as ordinary data within the database and use standard database relational language.
  • Rule 5: The database must support one declarative language with data definition, view definition, data manipulation, integrity constraints, authorization and transaction management.
  • Rule 6: Any view that is theoretically updatable must be updatable through the system.
  • Rule 7: The database must support set-level inserts, updates and deletes.
  • Rule 8: Application programs and ad hoc facilities are logically unaffected when physical access methods or storage structures are changed.
  • Rule 9: Application programs and ad hoc facilities are logically unaffected when changes are made to the table structures.
  • Rule 10: All relational integrity constraints must be definable in the relational language and stored in the system catalog, not at the application level.
  • Rule 11: The end users and application programs are unaware and unaffected by the data location.
  • Rule 12: There must not be a way to bypass the integrity rules of the database.

Summary

  • Relations are basic building blocks of relational database.
  • Keys are central to the use of relational tables.
  • Keys define functional dependencies: superkey, candidate key, primary key, secondary key, foriegn key.
  • Each table row must have a primary key which uniquely identifies all attributes.
  • Tables can be linked by common attributes where primary key can appear as foreign key in another table for linking.
  • Good design begins by identifying appropriate entities and attributes and the relationships among the entities as relationships (1:1, 1:*, and :).

Studying That Suits You

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

Quiz Team

Related Documents

More Like This

Use Quizgecko on...
Browser
Browser