Ch2: Relational Database

0.0(0)
studied byStudied by 1 person
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/31

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

32 Terms

1
New cards

Why use a database instead of flat files?

While all flat files & databases ensure : Persistency

Databases offer Persistency & Durability:

  • structured storage

  • fast search

  • concurrent access

  • flexible query language (just relational databases)

  • data consistency (just relational databases)

2
New cards

What is a database?

A: A collection of related data with implicit meaning. Can be of any size & complexity.

3
New cards

What is metadata?

A: Data that describes the structure and constraints of the database (e.g., data types, relationships) stored in a catalog.

4
New cards

What are the core tasks of a DBMS (database management system)?

A:

DBMS creates and maintains databases:

  1. Define the database (schema)

  2. Construct the database (populate)

  3. Manipulate data (query, updating, generating)

  4. Enable sharing (concurrency)

5
New cards

What is a transaction in a DBMS?

A: A program or process tasked by DBMS that reads from or writes to a database. DBMS ensures its ACID properties.

6
New cards

What is a key problem with traditional file-based systems and how does database approach solve data redundancy?

A: Data redundancy and inconsistency due to duplicate data being stored in multiple files and formats.

→ By centralizing data storage and allowing multiple applications to access a single version of the data.

7
New cards

What is data abstraction in the context of a DBMS, and why is it important?

A:

Data abstraction hides low-level data storage and implementation details from users (e.g., data models)

→ allows program-data independence + provides conceptual representation of the data

8
New cards

What is concurrency control?

A: Ensuring correct results when multiple users access or update the database at the same time, ensured by ACID properties.

9
New cards

What does ACID stand for?

A:

  • Atomicity: all or nothing

  • Consistency: preserves valid states

  • Isolation: transactions don't interfere

  • Durability: changes persist after committed

10
New cards

What is a relational data model?

A: A model where data is organized into relations (tables), each with rows (tuples) and columns (attributes), based on a schema.

11
New cards

What is the difference between a schema and a state?

A:

  • Schema: Description of structure (type pf metadata), e.g., column names, types

  • State: Actual content (records) at a point in time

12
New cards

What are the three types of data models?

A:

  1. High-level (Conceptual) – close to user view (e.g., ER model)

  2. Low-level (Physical) – describes storage details (specialist view)

  3. Representational – between the two (e.g., relational model)

13
New cards

Who proposed the relational model and when?

A: Ted Codd in 1970 at IBM, quickly became standard bc of simplicity & mathematical foundation.

14
New cards

What is a tuple in a relation?

A: A row (record) representing an instance of an entity or relationship.

15
New cards

What is a domain in relational databases?

A: The set of valid atomic values an attribute can take (e.g., integers, strings, date).

16
New cards

What is a relation schema?

A: The structure of a relation, denoted as R(A1,A2,...,An), where Ai are attributes.

17
New cards

What does the arity (or degree) of a relation refer to?

A: The number of attributes (columns) in a relation.

18
New cards

What are NULL values used for?

A: Representing unknown, inapplicable, or missing attribute values-but best avoided when possible due to ambiguity.

19
New cards

What possible constraints on the values in a data base state:

A:

  • Implicit constraints (inherent)

  • Explicit constraints (in schema, integrity constraints)

  • Semantic constraints (≠ expressed explicitly in the schema)

20
New cards

What are the main types of relational integrity constraints?

A:

  1. Domain constraints: w/i each tuple, the value of each attribute A must be an atomic value of domain dom(A)

  2. Key constraints: tuple w/i a relation are unique

  3. Null constraints: specify whether/not 0 values are permitted for an attribute

  4. Entity Integrity: primary keys cannot be NULL — ensures each tuple is uniquely identifiable.

  5. Referential Integrity: ensures that foreign keys point to existing tuples or are NULL

21
New cards

What is the difference between a superkey and a key?

A:

  • A superkey is any set of attributes that uniquely identifies a row

  • A key is a minimal superkey — the smallest such set without redundancy

22
New cards

What is a primary key?

A: The designated candidate key used to uniquely identify tuples in a relation.

23
New cards

What is a candidate key?

A: A relation can have more than 1 key, each key that could serve as the unique identifier for a tuple, is called a candidate key

24
New cards

What is a foreign key?

A: An attribute in one table that references the primary key in another table — enforces referential integrity.

25
New cards

What SQL command is used to define a table?

A: CREATE TABLE

26
New cards

What are the basic update operations in SQL?

A:

  • INSERT — add tuples

  • DELETE — remove tuples

  • UPDATE — change values in existing tuples

27
New cards

How is a primary key declared in SQL?

A: PRIMARY KEY (attribute_name)

28
New cards

What is the basic structure of a SQL SELECT query?

A:

SELECT columns FROM table WHERE condition;

29
New cards

How does SQL treat NULL in comparisons?

A: NULL makes conditions UNKNOWN, requiring special handling with IS NULL or three-valued logic.

30
New cards

What is three-valued logic in SQL?

knowt flashcard imageknowt flashcard imageknowt flashcard image

31
New cards

What is the purpose of the EXISTS keyword?

A: Tests if a subquery returns any tuples; returns TRUE if at least one row exists.

32
New cards

what are the different types of joined tables?