diff --git a/Databases/Relational_Databases/Fundamental_database_concepts.md b/Databases/ACID_principle.md similarity index 61% rename from Databases/Relational_Databases/Fundamental_database_concepts.md rename to Databases/ACID_principle.md index 0eb0ce8..2a070dd 100644 --- a/Databases/Relational_Databases/Fundamental_database_concepts.md +++ b/Databases/ACID_principle.md @@ -1,15 +1,14 @@ --- categories: - Databases +tags: [relational-database] --- -# Fundamental database concepts +# ACID principle > A database is a collection of organised data that can be efficiently stored, sorted, and searched. -How the data is organised will often determine the _type_ of database used. There are many different types of database; some examples of the different types are relational, object-orientated, graphical, NoSQL, and distributed. - -## ACID principle +How the data is organised will often determine the _type_ of database used. There are many different types of database; some examples of the different types are relational, object-orientated, graphical, NoSQL, and distributed. All should meet the principles of ACID. To ensure the integrity of a database, each change or transaction must conform to a set of rules known as ACID: @@ -23,9 +22,3 @@ To ensure the integrity of a database, each change or transaction must conform t - once a change has been made, the data is safe, even in the event of system failure > Databases will have mechanisms for **backup**, **distribution**, and **redundancy**, to ensure data is not lost. - -## Database management system: DBMS - -A DBMS is software that can retrieve, add, and alter existing data in a database. MySQL, PostgreSQL, MongoDB, MariaDB are all examples of DBMSs. You can work with them via programming languages like PHP or through graphical clients such as PHPMyAdmin, MicrosoftSQL, Adminer etc. There is also SQLite which runs on the client not the server, so useful for learning and local development. SQLite is also useful when you need a database specific to a single device without networked communication, such as on mobile. - -There are also CLI tools for all the major databases. diff --git a/Databases/Relational_Databases/Relational_database_architecture.md b/Databases/Relational_Databases/Relational_database_architecture.md index b77f5a1..1976c52 100644 --- a/Databases/Relational_Databases/Relational_database_architecture.md +++ b/Databases/Relational_Databases/Relational_database_architecture.md @@ -1,7 +1,7 @@ --- categories: - Databases -tags: [relational-databases] +tags: [relational-database] --- # Relational database architecture @@ -16,9 +16,9 @@ A group of similar data with rows for **records** and columns for each **field** ## Record -A horizontal row: a collection of items which may be of different data types all relating to the individual or object that the record describes +A horizontal row: a collection of items which may be of different data types all relating to the individual or object that the record describes. A single _entry_ in the table. -### Field +## Field A vertical column: stores a single particular unit of data for each record. Each field must use the same data type. diff --git a/Databases/Relational_Databases/Primary_key.md b/Databases/Relational_Databases/Role_of_primary_key_in_relational_databases.md similarity index 76% rename from Databases/Relational_Databases/Primary_key.md rename to Databases/Relational_Databases/Role_of_primary_key_in_relational_databases.md index dfaa9b2..b589f82 100644 --- a/Databases/Relational_Databases/Primary_key.md +++ b/Databases/Relational_Databases/Role_of_primary_key_in_relational_databases.md @@ -8,7 +8,7 @@ tags: [relational-databases] > Every table in a relational database should have a **primary key**. A primary key is one **field that uniquely identifies each record**. -This is essential for carrying out operations across database tables and for creating and deleting database entires. It is also a safeguard: it means you can always identify a record by itself and don't have to rely on generic queries to identify it. +This is essential for carrying out operations across database tables and for creating and deleting database entires in accordance with the [ACID principle](/Databases/ACID_principle.md). It is also a safeguard: it means you can always identify a record by itself and don't have to rely on generic queries to identify it. Sometimes you will have a dedicated field such as `UNIQUE_ID` for the primary key. Other times you can use an existing field to fulfil that function. In both cases the following constraints **must be met:** diff --git a/Databases/Relational_Databases/Views_in_relational_databases.md b/Databases/Relational_Databases/Views_in_relational_databases.md new file mode 100644 index 0000000..b8f252b --- /dev/null +++ b/Databases/Relational_Databases/Views_in_relational_databases.md @@ -0,0 +1,11 @@ +--- +categories: + - Databases +tags: [relational-databases] +--- + +# Views in relational databases + +A view is a virtual table that is based on the result-set of a query. Although it doesn't actually exist in the same manner as an actual table it has exactly the same properties and functionality. Rather than adding the raw data manually, you derive it from logic applied to existing actual tables. + +This is a good way of dynamically generating data and is often employed as a way of creating mutations without changing the underlying data structure. In SQL, views can be created by combining `PRIMARY` and `FOREIGN` keys. diff --git a/Databases/SQL/1_Language_structure.md b/Databases/SQL/1_Language_structure.md deleted file mode 100644 index 7f66838..0000000 --- a/Databases/SQL/1_Language_structure.md +++ /dev/null @@ -1,35 +0,0 @@ ---- -categories: - - Databases - - Programming Languages -tags: [SQL] ---- - -# SQL: Language structure - -The structure or syntax of SQL is composite and mirrors that of a natural or logical language. There are overall statements (queries) which subdivide hierarchially into clauses, predicates, and expressions. - -## Query - -- A statement that updates or retrieves data from a table based on passed-in criteria -- The highest level in the syntax tree, equivalent to a sentence in natural language -- Examples: - - `SELECT` - - `UPDATE` - - `DELETE` -- Applied example: - - `SELECT name FROM model` - -## Clause - -- Typically provides parameters for a given query -- For example running a query against a specific table (`FROM`) that satisfies certain conditions (`WHERE`) - -## Predicates - -- A logical or numerical condition which is passed to a given clause. -- For example `WHERE` a given condition obtains - -### Expression - -- The lowest level of the hierarchy: field, row names etc diff --git a/Databases/SQL/8_CREATE.md b/Databases/SQL/8_CREATE.md deleted file mode 100644 index 4ccb66a..0000000 --- a/Databases/SQL/8_CREATE.md +++ /dev/null @@ -1,28 +0,0 @@ ---- -categories: - - Databases - - Programming Languages -tags: [SQL] ---- - -# SQL: CREATE - -## Create a table (`CREATE`) - -```sql -CREATE TABLE employee ( - employee_id text PRIMARY KEY, - first_name text, - surname text, - address_number integer, - address_1 text, - address_2 text, - locality text, - region text, - postal_code text, - phone_number text, - days_per_week real - ); -``` - -We specify the new table name first, then it's fields and their corresponding data types. We also set a primary key diff --git a/Databases/SQL/9_Utilising_foreign_keys.md b/Databases/SQL/9_Utilising_foreign_keys.md deleted file mode 100644 index 28ee17d..0000000 --- a/Databases/SQL/9_Utilising_foreign_keys.md +++ /dev/null @@ -1,45 +0,0 @@ ---- -categories: - - Databases - - Programming Languages -tags: [SQL] ---- - -# SQL: Creating relationships between tables with `PRIMARY` and `FOREIGN` keys - -We will demonstrate with an example. We already have the `sales` table. We want to create new table called `returns` that will sustain a one-to-one relationship with `sales`. We are going to use the `sale_id` as our foreign key in `returns`. This is the primary key in `sales`. - -The `sales` table: - -``` -sale_id model_id sale_date employee_id price ----------- ---------- ---------- ----------- ---------- -1 44 2020-07-27 tbishop 399.99 -2 22 2021-02-07 tbishop 200.99 -``` - -Creating the `returns` table and establishing relationship with `sales` using the `FOREIGN KEY` keyword: - -```sql -CREATE TABLE returns ( - return_id integer PRIMARY KEY, - sale_id integer NOT NULL, - date_returned text, - reason text, - FOREIGN KEY (sale_id) REFERENCES sales(sale_id) - ); -``` - -Here's an example with more than one foreign key: - -```sql -CREATE TABLE returns ( - return_id integer PRIMARY KEY, - sale_id integer NOT NULL, - employee_id text NOT NULL, - date_returned text, - reason text, - FOREIGN KEY(sale_id) REFERENCES sales(sale_id), - FOREIGN KEY(employee_id) REFERENCES employee(employee_id) - ); -``` diff --git a/Databases/SQL/Create_an_SQL_table.md b/Databases/SQL/Create_an_SQL_table.md new file mode 100644 index 0000000..0c8ffe2 --- /dev/null +++ b/Databases/SQL/Create_an_SQL_table.md @@ -0,0 +1,28 @@ +--- +categories: + - Databases + - Programming Languages +tags: [SQL, relational-database] +--- + +# Create an SQL table + +We create tables in an SQL database with the `CREATE` command. + +Below is an example of this in practice. Each field corresponds to a column. We specify the name of the field and its corresponding data-type. Every table must have a **primary key**. In the example, `employee_id` is the primary key. + +```sql +CREATE TABLE employee ( + employee_id text PRIMARY KEY, + first_name text, + surname text, + address_number integer, + address_1 text, + address_2 text, + locality text, + region text, + postal_code text, + phone_number text, + days_per_week real + ); +``` diff --git a/Databases/SQL/Delete_records_in_an_SQL_table.md b/Databases/SQL/Delete_records_in_an_SQL_table.md index 424e978..7beaa56 100644 --- a/Databases/SQL/Delete_records_in_an_SQL_table.md +++ b/Databases/SQL/Delete_records_in_an_SQL_table.md @@ -2,7 +2,7 @@ categories: - Databases - Programming Languages -tags: [SQL] +tags: [SQL, relational-database] --- # Deleting data in SQL diff --git a/Databases/SQL/Foreign_keys_in_SQL.md b/Databases/SQL/Foreign_keys_in_SQL.md new file mode 100644 index 0000000..aa4bd5a --- /dev/null +++ b/Databases/SQL/Foreign_keys_in_SQL.md @@ -0,0 +1,80 @@ +--- +categories: + - Databases + - Programming Languages +tags: [SQL, relational-database] +--- + +# Creating views with foreign keys + +We utilise **foreign** and [primary keys](/Databases/Relational_Databases/Primary_key.md) to create relationships between tables in SQL. Foreign keys link data in one table to the data in another table and are how we cross-reference data in SQL. + + + +In essence you use the primary key of one table to access data in another table. + +Let's say we have a `sales` table: + +| saleId | modelId | saleDate | employeeId | price | +| ------ | ------- | ---------- | ---------- | ------ | +| 1 | 44 | 2020-07-27 | tbishop | 399.99 | +| 2 | 22 | 2021-02-05 | tbishop | 200.99 | + +In SQL this would be set up as follows: + +```sql +CREATE TABLE sales ( + saleId integer PRIMARY KEY, + modelId integer, + saleDate date, + employeeId text, + price float +) +``` + +For every model that is sold it is possible for the customer to return it. This data will be kept in another table `returns`. Every model sold will have an entry in `sales` but may or may not have an entry in `returns` (not every customer will return an item). + +We want to establish a relationship between the two tables so that if an item is returned we can trace it back to its original sale. + +As the `saleId` is the primary key in `sales` this means it is a unique identifier for each model sold. We will therefore use this in our `returns` table to track the sale data. + +Here's our `returns` table: + +| returnId | saleId | returnDate | reason | +| -------- | ------ | ----------- | ---------------------------------------------- | +| 7899 | 1 | 2020-11-218 | New device issued under warranty due to defect | +| 6711 | 2 | 2022-09-02 | Returned gift | + +n this table `saleId` is identical to `saleId` in sales. It is the primary key in `sales` but a foreign key in `returns`. There is a one-to-one correspondance at work here. If a device has been returned it must have an entry in `returns` and the `salesId` of the entry in `returns` must match the `salesId` in `sales`. + +We already have the `sales` table. We want to create new table called `returns` that will sustain a one-to-one relationship with `sales`. We are going to use the `sale_id` as our foreign key in `returns`. This is the primary key in `sales`. + +We establish this with the following SQL: + +```sql +CREATE TABLE returns ( + returnId integer PRIMARY KEY, + saleId integer NOT NULL, + returnDate date, + reason text, + FOREIGN KEY (sale_id) REFERENCES sales(sale_id) + ); +``` + +https://www.cockroachlabs.com/blog/what-is-a-foreign-key/ + +--- + +Here's an example with more than one foreign key: + +```sql +CREATE TABLE returns ( + return_id integer PRIMARY KEY, + sale_id integer NOT NULL, + employee_id text NOT NULL, + date_returned text, + reason text, + FOREIGN KEY(sale_id) REFERENCES sales(sale_id), + FOREIGN KEY(employee_id) REFERENCES employee(employee_id) + ); +``` diff --git a/Databases/SQL/Insert_data_into_SQL_table.md b/Databases/SQL/Insert_data_into_SQL_table.md index 84b396a..45d7bac 100644 --- a/Databases/SQL/Insert_data_into_SQL_table.md +++ b/Databases/SQL/Insert_data_into_SQL_table.md @@ -2,7 +2,7 @@ categories: - Databases - Programming Languages -tags: [SQL] +tags: [SQL, relational-database] --- # Insert data into table with SQL `INSERT` statement diff --git a/Databases/SQL/Retrieve_data_from_SQL_table.md b/Databases/SQL/Retrieve_data_from_SQL_table.md index 290a706..23b76eb 100644 --- a/Databases/SQL/Retrieve_data_from_SQL_table.md +++ b/Databases/SQL/Retrieve_data_from_SQL_table.md @@ -2,7 +2,7 @@ categories: - Databases - Programming Languages -tags: [SQL] +tags: [SQL, relational-database] --- # Retrieve data from table with SQL `SELECT` statement diff --git a/Databases/SQL/7_ALTER.md b/Databases/SQL/Update_an_SQL_table.md similarity index 63% rename from Databases/SQL/7_ALTER.md rename to Databases/SQL/Update_an_SQL_table.md index eeb921c..efd0651 100644 --- a/Databases/SQL/7_ALTER.md +++ b/Databases/SQL/Update_an_SQL_table.md @@ -2,16 +2,16 @@ categories: - Databases - Programming Languages -tags: [SQL] +tags: [SQL, relational-database] --- -# SQL: ALTER +# Updating an SQL table -We use the `ALTER` query to add, remove and otherwise change the structural properties of a table. +We use the `ALTER` query to add, remove and otherwise change the structural properties of a table in the database. ## Add an additional field to existing table -This adds a `price` field to the `sales` table. The `price` field accepts data of the type `real` . `real` is a slightly less precise (less memory) version of float +This adds a `price` field to the `sales` table. The `price` field accepts data of the type `real`. ```sql ALTER TABLE sales ADD price real; diff --git a/Databases/SQL/Update_existing_data_in_SQL_table.md b/Databases/SQL/Update_existing_data_in_SQL_table.md index a24ee2c..fb6a000 100644 --- a/Databases/SQL/Update_existing_data_in_SQL_table.md +++ b/Databases/SQL/Update_existing_data_in_SQL_table.md @@ -2,7 +2,7 @@ categories: - Databases - Programming Languages -tags: [SQL] +tags: [SQL, relational-database] --- # Update existing data with the SQL `UPDATE` command diff --git a/Databases/SQL/Wildcards_in_SQL.md b/Databases/SQL/Wildcards_in_SQL.md index c98e1a3..91f02e4 100644 --- a/Databases/SQL/Wildcards_in_SQL.md +++ b/Databases/SQL/Wildcards_in_SQL.md @@ -2,7 +2,7 @@ categories: - Databases - Programming Languages -tags: [SQL] +tags: [SQL, relational-database] --- # Wildcards in SQL diff --git a/Electronics/Digital_Circuits/Clock_signals.md b/Electronics/Digital_Circuits/Clock_signals.md new file mode 100644 index 0000000..e69de29 diff --git a/Electronics/Digital_Circuits/Latches.md b/Electronics/Digital_Circuits/Latches.md index 0558c01..fe17d7c 100644 --- a/Electronics/Digital_Circuits/Latches.md +++ b/Electronics/Digital_Circuits/Latches.md @@ -12,11 +12,11 @@ The combinatorial digital circuits we have looked at so far have been non-sequen In contrast, a sequential digital circuit's output depends not only on its present set of inputs but also on past inputs to the circuit. It has some knowledge of its own previous state through the existence of memory - a component that allows for the **storage and retrieval of binary data**. -## What is a latch +## What is a latch? A latch is a circuit component that works as a very basic memory device. It is capable of setting and resetting a single bit. We can remember what it does by thinking of a door latch: once you turn the key the lock is set, when you turn it back it is unset. -The **SR Latch** (for "set/reset") has two inputs: S (for set) and R (for reset) and one output, Q. Q stands for the bit that is remembered. There is also not-Q which is the opposite of whatever Q is currently set to. +The **SR Latch** (for "set/reset") has two inputs: S (for set) and R (for reset) and one output, Q. Q stands for the bit that is remembered. There is also not-Q which is the opposite of whatever Q is currfently set to. > When S is set to 1, output Q becomes 1 also. When S goes to 0, Q remains 1. When R is set to 1, this clears the memory bit and Q becomes 0. Q remains at 0 even if R goes back to 0. @@ -29,10 +29,13 @@ This is represented more clearly in the table below: | 1 | 0 | 1 | Set | | 1 | 1 | X | Invalid, null | -// TODO add diagram of latch here +![](/img/sr_latch_diagram.png) ## Creating a latch circuit There is more than one way of implementing a latch with logic gates. We will look at two formulations which both use a single type of gate: [NANDs](/Hardware/Logic_Gates/Logic_gates.md#nand-gate) and [NORs](/Hardware/Logic_Gates/Logic_gates.md#nor-gate) (both universal logic gates). In each case, the gates are in a **cross-coupled configuration**. This basically means that the wires are crossed back on themselves such that the output of one is also an input of the other at a single stage in the sequence. + +![](/img/sr_latch_logic_circuit.png) +![](/img/nand_latch_logic_circuit.png) diff --git a/Mathematics/Prealgebra/Additive_identity.md b/Mathematics/Prealgebra/Additive_identity.md index ff6145a..47091dc 100644 --- a/Mathematics/Prealgebra/Additive_identity.md +++ b/Mathematics/Prealgebra/Additive_identity.md @@ -3,7 +3,6 @@ categories: - Mathematics tags: - theorems - - prealgebra --- # The Property of Additive Identity diff --git a/Mathematics/Prealgebra/Additive_inverse_property.md b/Mathematics/Prealgebra/Additive_inverse_property.md index 4fa6aa5..af3e78d 100644 --- a/Mathematics/Prealgebra/Additive_inverse_property.md +++ b/Mathematics/Prealgebra/Additive_inverse_property.md @@ -3,7 +3,6 @@ categories: - Mathematics tags: - theorems - - prealgebra --- **Let $a$ represent any member of $\mathbb{Z}$. Then there is a unique member of $\mathbb{Z}$ $-a$ such that:** diff --git a/Mathematics/Prealgebra/Commutativity.md b/Mathematics/Prealgebra/Commutativity.md index 3178acb..9fe8ffc 100644 --- a/Mathematics/Prealgebra/Commutativity.md +++ b/Mathematics/Prealgebra/Commutativity.md @@ -3,7 +3,6 @@ categories: - Mathematics tags: - theorems - - prealgebra --- # The Commutative Property of Addition and Multiplication diff --git a/Resources.md b/Resources.md index c700349..f5cdcde 100644 --- a/Resources.md +++ b/Resources.md @@ -1,19 +1,63 @@ # Resources -## Computer Science modules +## Backend (CPD) + +[roadmap.sh/backend](https://roadmap.sh/backend) + +[roadmap.sh/devops](https://roadmap.sh/devops) + +[roadmap.sh/software-design-architecture](https://roadmap.sh/software-design-architecture) + +_Clean Code_ (2008) R.C Martin + +_The Pragmatic Programmer_ (1999) Hunt and Thomas + +## C + +[Everything I wish I knew when I started learning C](https://tmewett.com/c-tips/) + +## Computer Science [Welcome to CS](https://runestone.academy/ns/books/published/welcomecs/index.html) +[roadmap.sh/computer-science](https://roadmap.sh/computer-science) + +_Structure and Interpretation of Computer Programs_ (1998) Abelson, Sussman + +_A Common Sense Guide to Data Structures and Algorithms_ (2017) Jay Wengrow + +_Cracking the Coding Interview_ (2009) McDowell [for useful algorithm exercises] + +## Electronics, hardware, computer architecture + +_How Computers Really Work_ (2020) Matthew Justice + +_But How Do It Know? The Basics of Computers for Everyone_ (2009) + +_The Essential Guide to Computing_ (2001) Garrison Walters + +_Fundamental Electrical and Electronic Principles_ (2008) Christopher Robertson + +[Computer Organisation and Design](https://learning.oreilly.com/library/view/computer-organization-and/9781483221182/) (2020) Hennesy and Patterson [O'Reilly] + +_Computer Systems: A Programmer's Perspective Third Ed._ (2016) Bryant and O'Halloran + +[How do transistors work, anyway?](https://lcamtuf.substack.com/p/how-do-transistors-work-anyway) + +## Linux + +_How Linux Works: What Every Superuser Should Know_ (2021) Brian Ward + +## Mathematics + +_The Logic Book_ + +_Foundation Mathematics for Computer Science_ (2015) John Vince + +_Algebra_ (2004) Gelfand and Shen + ## Python [Tiny Python Projects (O'Reilly)](https://learning.oreilly.com/library/view/tiny-python-projects/9781617297519/) [Learning Arduino with Python](https://realpython.com/arduino-python/) - -## C - -[Everything I wish I knew when I started learning C](https://tmewett.com/c-tips/) - -## Electronics - -[How do transistors work, anyway?](https://lcamtuf.substack.com/p/how-do-transistors-work-anyway) diff --git a/Topic_Log.md b/Topic_Log.md new file mode 100644 index 0000000..c4a065b --- /dev/null +++ b/Topic_Log.md @@ -0,0 +1,25 @@ +# Learning Topic Log + +## Bash + +- Best way to run a command in a script - is it to `echo` it? +- How to handle the return value of a command + - If it returns multiple values, how to isolate and loop through them +- What the weird variable symbols mean like errors and stuff + +## SQL + +- What is a _schema_ in MySQL/ SQL ? +- Proper definition of "migrating a database"? + +## GraphQL + +- What is a transformer + +## AWS + +- Start reading more specifically about key services: Lambda, step functions, CloudFormation, Elasticache, CloudFront, CloudWatch +- Do basic exercises from Amazon on aspects I am interested in to get a practical feel for it +- Elastic Beanstalk and how it differs from using multiple different services at once +- AWS Amplify +- Deploy my own website on AWS