Docsity

Chapter_2_Relational_Databases_and_SQL, Lecture notes of Computer Fundamentals

Toggle sidebar
bg1
APPLIED COMPUTING • CHAPT ER 2
Relational Databases & SQL
Schema Design, Normalization, and Query Optimization
2.1 Core Relational Architecture
Tables (Relations): Structured collections of rows (tuples) and columns (attributes).
Primary Keys (PK): Unique, non-null identifiers for each record in a table.
Foreign Keys (FK): Attributes referencing a primary key in another table to enforce referential integrity.
ACID Properties: Atomicity, Consistency, Isolation, and Durability guarantee reliable transaction processing.
2.2 Normalization Forms (1NF to 3NF)
First Normal Form (1NF): Every cell holds an atomic (single) value; no repeating groups or arrays.
Second Normal Form (2NF): Satisfies 1NF and eliminates partial dependencies on composite primary keys.
Third Normal Form (3NF): Satisfies 2NF and removes transitive dependencies (non-key columns depend only on the PK ).
Trade-off Note: Analytical warehouses sometimes intentionally denormalize schemas (Star/Snowflake) to accelerate read-
heavy aggregations.
ENTITY-RELATIONSHIP SKETCH (1-TO-MANY)
STUDENTS (1) --- 1 : N ---> SUBMISSIONS (N)
student_id (PK)
full_name
email
submission_id (PK)
student_id (FK)
score
2.3 Essential Query Patterns & Indexing
Execution Order: FROM & JOIN → WHERE → GROUP BY → HAVING → SELECT → ORDER BY → LIMIT.
Joins: INNER JOIN returns matching rows; LEFT JOIN preserves all records from the left table regardless of match.
B-Tree Indexes: Speed up equality and range lookups on frequently filtered columns at the cost of extra disk space and slower
writes.
Quick Study Tip: Filter rows early with WHERE before grouping with GROUP BY to reduce memory overhead.
Original Study Notes • Ready for Upload
•
•
•
•
•
•
•
•
•
•
•
Page 1 of 1

Partial preview of the text

Download Chapter_2_Relational_Databases_and_SQL and more Lecture notes Computer Fundamentals in PDF only on Docsity!

APPLIED COMPUTING • CHAPTER 2

Relational Databases & SQL

Schema Design, Normalization, and Query Optimization

2.1 Core Relational Architecture

Tables (Relations): Structured collections of rows (tuples) and columns (attributes). Primary Keys (PK): Unique, non-null identifiers for each record in a table. Foreign Keys (FK): Attributes referencing a primary key in another table to enforce referential integrity. ACID Properties: Atomicity, Consistency, Isolation, and Durability guarantee reliable transaction processing.

2.2 Normalization Forms (1NF to 3NF)

First Normal Form (1NF): Every cell holds an atomic (single) value; no repeating groups or arrays. Second Normal Form (2NF): Satisfies 1NF and eliminates partial dependencies on composite primary keys. Third Normal Form (3NF): Satisfies 2NF and removes transitive dependencies (non-key columns depend only on the PK). Trade-off Note: Analytical warehouses sometimes intentionally denormalize schemas (Star/Snowflake) to accelerate read- heavy aggregations.

ENTITY-RELATIONSHIP SKETCH (1-TO-MAN Y) STUDENTS (1) --- 1 : N ---> SUBMISSIONS (N) student_id (PK) full_name email

submission_id (PK) student_id (FK) score

2.3 Essential Query Patterns & Indexing

Execution Order: FROM & JOIN → WHERE → GROUP BY → HAVING → SELECT → ORDER BY → LIMIT. Joins: INNER JOIN returns matching rows; LEFT JOIN preserves all records from the left table regardless of match. B-Tree Indexes: Speed up equality and range lookups on frequently filtered columns at the cost of extra disk space and slower writes.

Quick Study Tip: Filter rows early with WHERE before grouping with GROUP BY to reduce memory overhead.

Original Study Notes • Ready for Upload

Page 1 of 1