logo
Published on

CH1. Concepts on One Page

Authors
  • avatar
    Name
    seren-wib
    Twitter
Contents

Concepts on One Page (2.1–2.2, 3.1)

For the "explain this" questions that are neither drawing nor SQL. What to memorize is the words in the tables and the counts.

1. What a DB is

TermMeaning
DatabaseA collection of related data
DBMSThe software that creates, fills, manipulates and shares that DB. Oracle, MySQL
Database systemDB + DBMS

3 problems with just storing data in files (why we use a DB)

ProblemWhat goes wrong
IntegrityNo length limits, duplicate entries, can't tell apart people with the same name
ManagementCan't find specific data quickly, things get tangled when many people write at once
DurabilityA failure mid-write corrupts the file and it can't be recovered

2. 4 characteristics of a DB system

CharacteristicIn one lineKey word
Self-describingStores not only the data but also its structure (metadata) inside the DBcatalog
Data abstractionPrograms see only the logical structure, not how it's stored on diskprogram-data independence
Multiple viewsShows the data differently to each userview = virtual table that isn't stored
Sharing & multiuser transactionMany users use one DB at the same timeconcurrency control, transaction

3. 5 advantages of a DB system

AdvantageIn one line
Controlling redundancyDon't keep the same data in several places → update once, save space, no inconsistency. Sometimes kept on purpose for performance
Enforcing integrity constraintsThe DBMS enforces the conditions data must satisfy (type, key, FK)
Storage structures & efficient searchingDisks are slow, so buffers and caches; indexes (B-tree, B+tree) to find things fast
Backup and recoveryKeep copies normally, restore to the state just before a failure
Restricting unauthorized accessPer-user privileges

When not using a DBMS is better: simple apps that don't change / strict real-time requirements / embedded systems short on space / a single user

4. 3 levels of data models

Data model: the set of concepts that describe a DB's structure. Data types, relationships, constraints, down to basic operations

ModelWhose eye levelConcepts usedExample
Conceptual (high-level)Usersentity, attribute, relationshipER diagram
Representational (middle)Users can understand it, and it's close to how data is storedrelation, tuple, attribute, domainTables. Most commercial DBMSs
Physical (low-level)Computer specialistsrecord format, ordering, access pathDisk layout, indexes

5. Three-schema architecture

Goal: separate application programs from the physical DB

LevelWhat it describesHow manyModel used
External (view)Only the part that user group seesMany
ConceptualLogical structure of the whole DB (entities, types, relationships, constraints)OneRepresentational
InternalPhysical storage structure, access pathsOnePhysical
  • Trap: the Conceptual level is written with the Representational model, not the Conceptual model
  • Mapping: converts requests and results between levels. Data exists only at the Internal level; the DBMS turns requests coming in from above into requests for the level below

6. 2 kinds of data independence

Data independence: changing one level's schema doesn't require changing the level right above it. The reason for stacking 3 levels. Only the mapping is fixed

Level changedLevel unaffectedExample
LogicalConceptualExternal, application programsAdding a column, splitting a table
PhysicalInternalConceptualSwapping an index, changing the file structure
  • Named after the level that changes. Touch tables → Logical, touch the disk → Physical / both end with "existing programs don't need changes"

7. DB design process

StepWhat you doOutput
1 Requirements collection & analysisGather users' data requirementsRequirements list
2 Conceptual designPick a model and turn it into a conceptual schemaER diagram
3 Logical designConceptual schema → DB schemaTables
4 Physical designDecide the storage structureFiles, indexes
  • Requirement wording → ER: "unique" = key, "several" = multivalued, "one" = cardinality
  • Good design: no Redundancy (the same information repeated), no Incompleteness (data that can't be represented)

8. 4 advantages of the relational model

AdvantageIn one line
SimplicityFlat tables are easy to understand
Data integrityConstraints keep data valid and consistent
Easy data manipulationManipulate with conditions in SQL
SecurityAuthentication, privileges, encryption

9. Numbers to memorize

How manyWhat
3File storage problems / data model levels / schema levels
4DB system characteristics / design steps / relational model advantages
5DB system advantages
2Data independence