|
| 1 | +--- |
| 2 | +tags: |
| 3 | + - OMSCS |
| 4 | + - DB |
| 5 | +--- |
| 6 | +# 01 - Fundamentals of Databases |
| 7 | + |
| 8 | +- high level overview of what a DB is |
| 9 | +- it's a "model of reality" |
| 10 | +- why use models at all? |
| 11 | +- when to use a Database Management System (DBMS) |
| 12 | + |
| 13 | +## Models of Reality |
| 14 | +- a model is a means of communication |
| 15 | +- users of a model must have a certain amount of knowledge in common |
| 16 | +- a model |
| 17 | + - only emphasizes selected aspects |
| 18 | + - is described in some language |
| 19 | + - can be erroneous |
| 20 | + - may have features that do not exist in reality |
| 21 | + |
| 22 | +## To use or not to use a DBMS |
| 23 | +### To Use |
| 24 | +- data-intensive applications |
| 25 | +- persistent storage of data |
| 26 | +- centralized control of data |
| 27 | +- control of redundancy |
| 28 | +- control of consistency and integrity |
| 29 | + - consistency = whether you can derive contradictions from within the DB itself |
| 30 | +- multiple user support |
| 31 | + - flight reservation |
| 32 | + - point of sale transactions |
| 33 | +- sharing of data |
| 34 | +- data documentation |
| 35 | +- data independence |
| 36 | +- control of access and security |
| 37 | +- backup and recovery |
| 38 | +### Not To Use |
| 39 | +- the initial investment in hardware, software, and training is too high |
| 40 | +- the generality is not needed |
| 41 | + - overhead for security, concurrency, and recovery is too high |
| 42 | +- data and apps are simple and stable |
| 43 | +- real-time requirements cannot be met by it |
| 44 | +- multiple user access is not needed |
| 45 | + |
| 46 | +## Outline of Major Topics |
| 47 | +- data modeling |
| 48 | +- process modeling |
| 49 | +- database efficiency |
| 50 | + |
| 51 | +## Data Modeling |
| 52 | +![[Pasted image 20250831114949.png]] |
| 53 | + |
| 54 | +- the model represents a perception of structures of reality |
| 55 | +- the data modeling process is to fix a perception of structures of reality and represent this perception |
| 56 | +- in the data modeling process, we select aspects and abstract |
| 57 | + |
| 58 | +## Process Modeling |
| 59 | +![[Pasted image 20250831114933.png]] |
| 60 | + |
| 61 | +- the use of the model reflects processes of reality |
| 62 | +- processes may be represented |
| 63 | + - embedded in program code |
| 64 | + - executed ad-hoc |
| 65 | + |
| 66 | +![[Pasted image 20250831114914.png]] |
| 67 | + |
| 68 | +## Data Models |
| 69 | +- data structures |
| 70 | +- constraints |
| 71 | +- operations |
| 72 | +- keys / identifiers |
| 73 | +- integrity / consistency |
| 74 | +- null values |
| 75 | +- surrogates |
| 76 | + |
| 77 | +## Architecture |
| 78 | +- database |
| 79 | + - ANSI/SPARC 3-Level DB Architecture |
| 80 | + - data independence |
| 81 | +- DBMS |
| 82 | + |
| 83 | +## Metadata |
| 84 | + |
| 85 | +## Example of Data Models |
| 86 | +> A data model is not the same as a model of data. |
| 87 | +
|
| 88 | +- Entity-Relationship Model |
| 89 | +- Relational Model |
| 90 | +- Hierarchical Model (legacy, IBM IMS, XML) |
| 91 | + |
| 92 | + |
| 93 | +### Relational Model |
| 94 | +#### Data Structures |
| 95 | +- data is represented in tables |
| 96 | +- tables have a name |
| 97 | +- tables have columns |
| 98 | +- columns have a data type |
| 99 | +- tables have rows |
| 100 | +- schema represents aspects of the data (the structure) |
| 101 | +- The schema is not expected to change (much) |
| 102 | +#### Constraints |
| 103 | +- constraints express rules that cannot be expressed by the data structures alone (more than just type constraints) |
| 104 | +- validation rules |
| 105 | +- foreign key relations |
| 106 | +- unique constraints |
| 107 | +- > dates must be after "1900-01-01" |
| 108 | +#### Operations |
| 109 | +- operations support change and retrieval of data |
| 110 | +- CRUD operations |
| 111 | +- list operation |
| 112 | +- filtering |
| 113 | +- etc |
| 114 | + |
| 115 | +## Keys and Identifiers |
| 116 | +- keys are uniqueness constraints |
| 117 | +- keys are used for reference and lookup of rows |
| 118 | + |
| 119 | +## Integrity and Consistency |
| 120 | +- **integrity**: Does the DB reflect reality well? |
| 121 | +- **consistency**: Is the DB without internal conflicts? |
| 122 | + |
| 123 | +## Null Values |
| 124 | +- it's "advanced 0" |
| 125 | +- represents the lack of a value, not a value itself |
| 126 | +- also represents values which are "inapplicable" to the specific row ("catch-all" forms) |
| 127 | + |
| 128 | +## Surrogates - Things and Names |
| 129 | +- "Leo" |
| 130 | +- "GTO1" |
| 131 | +- "49" |
| 132 | +- **name-based**: a thing is what we know about it |
| 133 | +- surrogates are system-generated, unique, internal identifiers |
| 134 | + |
| 135 | +![[Pasted image 20250831120057.png]] |
| 136 | + |
| 137 | +![[Pasted image 20250831120320.png]] |
| 138 | + |
| 139 | + |
| 140 | +## ANSI/SPARC 3-Level DB Architecture |
| 141 | +### Separating Concerns |
| 142 | +- a DB is divided into schema and data |
| 143 | +- the schema describes the intention (types) |
| 144 | +- the data describes the extension (data) |
| 145 | + |
| 146 | +![[Pasted image 20250901150105.png]] |
| 147 | + |
| 148 | +- benefits include |
| 149 | + - it's possible to change how data is stored without changing the application which uses the data |
| 150 | +- physical data independence is a measure of how much the internal schema can change without affecting the application programs |
| 151 | +- logical data independence is a measure of how much the conceptual schema can change without affecting the application programs |
| 152 | +### Conceptual Schema |
| 153 | +- describes conceptually relevant, general, time-invariant structural aspects of reality |
| 154 | +- excludes aspects of data representation, physical organization, and access |
| 155 | +- applications can only "see" these structures |
| 156 | +### External Schema |
| 157 | +- describes parts of the information in the conceptual schema in a form convenient to a particular user group's view |
| 158 | +- is derived from the conceptual schema |
| 159 | +### Internal Schema |
| 160 | +- describes how the information described in the conceptual schema is physically represented to provide the overall best performance |
| 161 | +- includes indexes |
| 162 | + |
| 163 | +## ANSI/SPARC DBMS Framework |
| 164 | +![[Pasted image 20250901150809.png]] |
| 165 | + |
| 166 | +- hexagons are different people/roles |
| 167 | +- triangle is where schema definitions are stored |
| 168 | +- squares are processors |
| 169 | +- 2 main parts |
| 170 | + - schema compiler |
| 171 | + - query transformer |
| 172 | + |
| 173 | +## Metadata |
| 174 | +- system metadata |
| 175 | + - where data came from |
| 176 | + - how data is changed |
| 177 | + - how data is stored |
| 178 | + - how data is mapped |
| 179 | + - who owns data |
| 180 | + - who can access data |
| 181 | + - data usage history |
| 182 | + - data usage statistics |
| 183 | +- business metadata |
| 184 | + - what data is available |
| 185 | + - where data is located |
| 186 | + - what the data means |
| 187 | + - how to access data |
| 188 | + - predefined reports |
| 189 | + - predefined queries |
| 190 | + - how current the data is |
| 191 | +- importance |
| 192 | + - system metadata is critical in a DBMS |
| 193 | + - business metadata is critical in a data warehouse |
0 commit comments