Data Management
Matthew Barnes
Contents
Navigating the Unix file system 7
Unix pipes, processes and filters 14
Running a process when logged off 14
Elements of an HTTP response 20
Keys and functional dependencies 24
Bad relations and anomalies 29
Aggregate functions with unary operator 34
SQL - Structured Query Language 42
Data definition language (DDL) 42
Data manipulation language (DML) 42
Data Protection and the GDPR 49
Owner |
Group |
Other |
||||||||||||||||||
|
|
|
Owner |
Group |
Other |
||||||||||||||||||
|
|
|
Binary |
Decimal |
Meaning |
000 |
0 |
No permissions |
001 |
1 |
Execute only |
010 |
2 |
Write only |
011 |
3 |
Write + Execute |
100 |
4 |
Read only |
101 |
5 |
Read + Execute |
110 |
6 |
Read + Write |
111 |
7 |
All permissions |
Person accessing |
Operation |
Type of permission |
‘u’ - user |
‘+’ - grant |
‘r’ = read |
‘g’ - group |
‘-’ - revoke |
‘w’ = write |
‘o’ - others |
‘=’ - set |
‘x’ = execute |
‘a’ - all |
|
‘-’ = none |
Command |
Meaning |
screen |
Create a new screen |
screen -d |
Detach from existing screen |
screen -list |
List available screens |
screen -r <id> |
Resume screen given ID |
CTRL-D |
Kill screen |
Filter |
Function of filter |
head |
Takes first 10 lines |
tail |
Takes last 10 lines |
sort |
Organises data |
wc |
Prints number of newlines |
uniq |
Remove duplicate lines |
du |
Estimate file space usage |
xargs |
Build + execute command lines |
Command |
Function of command |
find |
Search for files in directory hierarchy |
tar |
Create file archive / extract |
gzip/gunzip & zip/unzip |
Compress files |
nohup |
Run command in background |
parallel |
Run jobs in parallel |
basename |
Removes parent folders from pathname e.g. basename /home/jsmith = jsmith |
cut |
Extract sections from each line of input |
w3m |
Text-based WWW browser |
More regex syntax:
Layer |
Explanation |
Examples |
Application |
Protocols that software uses to communicate over networks |
HTTP (documents), FTP (files), SMTP (sending mail), POP (receiving mail) |
Transport |
Protocols that manage how the data is sent to the recipient |
TCP (establishing a connection, make sure that each system receives messages), UDP (fire and forget) |
Internet |
Protocols that manage how the packets are structured and distributed |
IP, ICMP, IGMP |
Link |
Protocols concerning the physical hardware used for sending data |
DSL, Ethernet, ARP |
Method |
Meaning |
GET |
Request for a web page or object from a server |
POST |
Send data/information about client to server |
PUT |
Send document to server |
DELETE |
Delete object on server |
HEAD |
Request information about page/document |
TRACE |
Trace proxies or tunnels in path from client to server |
OPTION |
Determines server capabilities |
<menu id="file" value="File"> |
{"menu": { |
x,y |
First name |
Last name |
Age |
Sex |
Matthew |
Barnes |
19 |
M |
Elon |
Musk |
46 |
M |
Melinda |
Gates |
53 |
F |
hPdmrLZk |
Barnes |
99 |
F |
First name |
Last name |
Age |
Sex |
Matthew |
Barnes |
19 |
M |
Elon |
Musk |
46 |
M |
Melinda |
Gates |
53 |
F |
hPdmrLZk |
Barnes |
99 |
F |
First name |
Last name |
Age |
Sex |
Matthew |
Barnes |
19 |
M |
Elon |
Musk |
46 |
M |
Melinda |
Gates |
53 |
F |
hPdmrLZk |
Barnes |
99 |
F |
Matthew |
Patrick |
31 |
M |
Xn |
Value |
Explanation |
X0 |
{A, C} |
In the beginning, we start with the values in X, that is, the set we want to determine if it is a superkey or not. |
X1 |
{A, C} ∪ {E, H} |
In F, there is a C → EH, and we have a ‘C’ in X0. Therefore, we can union the result of that functional dependency with our X and increment its index. |
X1 |
{A, C, E, H} |
It should now look like this. |
X2 |
{A, C, E, H} ∪ {H} |
In F, there is an AC → H, and we have an ‘A’ and a ‘C’ in X1, so we can union ‘H’ with our X. |
X2 |
{A, C, E, H} |
Hmm, that didn’t seem to do anything. Additionally, there are no more functional dependencies of interest for us to look at. Therefore, this will be our output: this is {A, C}+. |
Xn |
Value |
Explanation |
X0 |
{A, B} |
In the beginning, we start with the values in X, that is, the set we want to determine if it is a superkey or not. |
X1 |
{A, B} ∪ {C, D} |
In F, there is an AB → CD, and we have an ‘A’ and a ‘B’ in X0. Therefore, we can union the result of that functional dependency with our X and increment its index. |
X1 |
{A, B, C, D} |
It should now look like this. |
X2 |
{A, B, C, D} ∪ {E, H} |
In F, there is a C → EH, and we now have a ‘C’ in X1 so we can union ‘H’ and ‘E’ with our X. |
X2 |
{A, B, C, D, E, H} |
Now we have this. |
X3 |
{A, B, C, D, E, H} ∪ {G} |
In F, there is a D → G. Since we have ‘D’ in X3, we can union ‘G’ with our X. |
X3 |
{A, B, C, D, E, H, G} |
We’re done here now; there are no more functional dependencies of interest. This is {A, B}+. |
|
|
|
= |
|
|
|
|
= |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
STUDENT_ID |
AVERAGE_SCORE |
1 |
5.78 |
2 |
4.89 |
3 |
3.68 |
4 |
8.45 |
Stand users |
||||
Stand user |
Stand name |
Birthyear |
Part |
Stand Type |
Joseph Joestar |
Hermit Purple |
1920 |
Part 2, Part 3, Part 4 |
Tool Stand |
Joseph Joestar |
Hermit Purple |
1920 |
Part 2, Part 3, Part 4 |
Integrated Stand |
Jotaro Kujo |
Star Platinum |
1970 |
Part 3, Part 4, Part 5, Part 6 |
Close-range Stand |
Jotaro Kujo |
Star Platinum |
1970 |
Part 3, Part 4, Part 5, Part 6 |
Range Irrelevant |
Josuke Higashikata |
Crazy Diamond |
1983 |
Part 4 |
Close-range Stand |
Yoshikage Kira |
Killer Queen |
1966 |
Part 4 |
Close-range Stand |
Stand users |
|||
Stand user (PK) |
Stand name |
Birthyear |
Stand type (PK) |
Joseph Joestar |
Hermit Purple |
1920 |
Tool Stand |
Joseph Joestar |
Hermit Purple |
1920 |
Integrated Stand |
Jotaro Kujo |
Star Platinum |
1970 |
Close-range Stand |
Jotaro Kujo |
Star Platinum |
1970 |
Range Irrelevant |
Josuke Higashikata |
Crazy Diamond |
1983 |
Close-range Stand |
Yoshikage Kira |
Killer Queen |
1966 |
Close-range Stand |
Stand user parts |
|
Stand user (PK) |
Part (PK) |
Joseph Joestar |
Part 2 |
Joseph Joestar |
Part 3 |
Joseph Joestar |
Part 4 |
Jotaro Kujo |
Part 3 |
Jotaro Kujo |
Part 4 |
Jotaro Kujo |
Part 5 |
Jotaro Kujo |
Part 6 |
Stand users |
||
Stand user (PK) |
Stand name |
Birthyear |
Joseph Joestar |
Hermit Purple |
1920 |
Jotaro Kujo |
Star Platinum |
1970 |
Josuke Higashikata |
Crazy Diamond |
1983 |
Yoshikage Kira |
Killer Queen |
1966 |
Stand user parts |
|
Stand user (PK) |
Part (PK) |
Joseph Joestar |
Part 2 |
Joseph Joestar |
Part 3 |
Joseph Joestar |
Part 4 |
Jotaro Kujo |
Part 3 |
Jotaro Kujo |
Part 4 |
Jotaro Kujo |
Part 5 |
Jotaro Kujo |
Part 6 |
Stand types |
|
Stand name (PK) |
Stand type (PK) |
Hermit Purple |
Tool Stand |
Hermit Purple |
Integrated Stand |
Star Platinum |
Close-range Stand |
Star Platinum |
Range Irrelevant |
Crazy Diamond |
Close-range Stand |
Killer Queen |
Close-range Stand |
Protagonists |
||
Part (PK) |
Protagonist |
Stand name |
Part 2 |
Joseph Joestar |
Hermit Purple |
Part 3 |
Jotaro Kujo |
Star Platinum |
Part 4 |
Josuke Higashikata |
Crazy Diamond |
Protagonists |
|
Part (PK) |
Protagonist |
Part 2 |
Joseph Joestar |
Part 3 |
Jotaro Kujo |
Part 4 |
Josuke Higashikata |
Stands |
|
Protagonist (PK) |
Stand name |
Joseph Joestar |
Hermit Purple |
Jotaro Kujo |
Star Platinum |
Josuke Higashikata |
Crazy Diamond |
Enrolment |
||
Student ID (PK) |
Subject (PK) |
Professor |
101 |
Java |
P.Java |
101 |
C++ |
P.Cpp |
102 |
Java |
P.Java2 |
103 |
C# |
P.Csharp |
104 |
Java |
P.Java |
Students-Professors |
|
Student ID (PK) |
Professor (PK, FK) |
101 |
P.Java |
101 |
P.Cpp |
102 |
P.Java2 |
103 |
P.Csharp |
104 |
P.Java |
Professors-Subjects |
|
Professor (PK) |
Subjects |
P.Java |
Java |
P.Cpp |
C++ |
P.Java2 |
Java |
P.Csharp |
C# |
CREATE DATABASE databasename; |
DROP TABLE IF EXISTS Student; |
CREATE TABLE Student |
CREATE TABLE Student
class integer,
FOREIGN KEY (class) REFERENCES Class(ID) |
|
|
|
|
|
|
|
|
|
|
|
|
SQL |
Relational Algebra |
SELECT |
Projection |
FROM |
Cartesian product |
WHERE |
Selection |