Please enable JavaScript.
Coggle requires JavaScript to display documents.
Databases
& Functional
Programming
(4.10), (4.12) - Coggle Diagram
Databases
& Functional
Programming
(4.10), (4.12)
Relational
Databases
Entity Relationship Modelling
Top-down technique, visualise data model, database design
Cardinality - One/many; crow's foot for many;
1:many most common (only one possible in database)
EntityName ( PrimaryKey, attribute1, attribute2, ...)
'PrimaryKey' is underlined; Composite Key is made of
foreign keys (also underlined)
Relational Databases
Database is an organised collection of data
Relational - most common data org; multiple tables
tables linked by relationships; column/rows = fields/records
Flatfile - all data, one table = data redundancy, inconsistency
Entity - real world object differentiable from other objects
Other Things
Data Integrity - accuracy, reliability of data
Referential Integrity - all foreign changes, in primary
Database Management Systems - software package
MySQL, SQLite etc.
Keys
Primary Key - field is unique ID for each record
Composite Key - unique ID but is multiple fields per record
Foreign Key - primary key of one table appears in another
Client-Server Databases
Client applications access database in server
Server listens for requests by clients; Multi-user systems
= concurrent requests; multiple servers for hi request volume
Transaction - support concurrent processing; one client
updating while another reads can cause concurrent problems
Database
Normalisation
Basics
1NF - "The Key" - atomic test, prim. key, no repeats
2NF - "The Whole Key" - Partial Dependencies
3NF - "And Nothing But The Key" - Transitive Dependencies
(non-key); 3NF also requires 2NF, 2NF also requires 1NF
Dependency?
A value that varies in line w/ another value
Don't assume dependencies, always check
Common Sense etc.
Post-Normalisation
Changes should leave table in 3NF
Acid Test - 'each attribute is dependent
on the key, the whole key, and nothing but the key.'
Just go the whole 1-2-3NF process again after completion
Anomalies
Something deviates from what is standard/normal/expected
Insertion - spec. attribute doesn't exist unless on a record
Deletion - spec. attribute no longer on record
Update - partial update = conflicting information
Benefits
Reduction of data duplication; Insertion/Update/Deletion
anomalies eradicated; time-consuming, complex, more
space needed to optimise data storage/retrieval
Spreadsheets solve basic needs, w/ advanced modelling
add-ons such as pivot tables, graphs etc.
SQL Fundamentals
Structured Query Language
Queries - insert/delete/update databases
Data Definition Language (DDL) - define/modify databases
Data Query Language (DQL) - retrieve database data
Data Manipulation Language (DML) - insert/update/delete
Data Control Language (DCL) - access permissions
Data Transaction Language (DTL) - manage transactions
Functional
Programming
Function Types
Function is ruel set connecting input to output
Every input needs to map to SOME output
Not every possible outputs maps to some input (in set)
Domain - Input; Co-Domain - Output; Range - actual outputs
Range is subset of Co-Domain
Function Type - f:: Domain -> Co-Domain
First-Class Object
Can expression appear, var assign, arg usage, funct. return (EVAC) functions are 1st Class here
Higher-order function - funct. accepts another funct. as arg.
Some Procedurals have funct. as 1st Class
Function Application
Giving inputs as arguments to a function
Multi-arg function can be partially applied to smaller
no. of args If you run a function that has two arguments
but w/ one argument, and then you put it into a variable
you get a new function w/ one argument >>> a partial
function because you partially 'applied the prev. function
Function Composition
Combine two functions together (g ∘ f = [g(f(x))])
Co-domain of 'f', matches domain of 'g'
Functional
Application
Writing Functional Programs
Haskell - Simple command line interface
Declaring Values - var are immutable (Haskell)
Functions - Static Typing = all function types known
at runtime (in Haskell
Lists In Functional Programming
Must be same type; all list iterations use recursion
Heads & Tails - head returns 1st element, tail returns rest
head (tail (tail list)) gives 3rd list element
No Loop counters as that requires a mutable variable
Prepend/Append Operator - adding items uses pointers to
track added values; String is a list of characters