All courses › Databases, Networks and Security

Databases, Networks and Security: free practice, theory and problems

Almost every app stores its data in a database: users, orders, measurements. A relational database stores data in tables, and you fetch exactly what you need with the query language SQL.

3 parts35 problems9 concepts explainedPractice examFree
Start practising for free →

Contents

  1. Relational databases and SQL
  2. IP networks and subnetting
  3. Cyber security

1. Relational databases and SQL

What is it about?

Almost every app stores its data in a database: users, orders, measurements. A relational database stores data in tables, and you fetch exactly what you need with the query language SQL.

In short

SELECT columns FROM table WHERE condition ORDER BY column;
SELECT s.name, e.course FROM Student s JOIN Exam e ON e.student_id = s.id;

The relational model

A relational database stores data in tables (relations) with rows (records) and columns (attributes). Each table has a primary key that uniquely identifies each row, and tables are linked by foreign keys pointing to the primary key in another table. An order, for example, points to the customer with a customer_id column.

Normalisation

The aim is to avoid redundancy – the same fact stored in several places that can become inconsistent.

An ER diagram (entity–relationship) is used to model before creating tables. Relationships can be one-to-one, one-to-many and many-to-many; the last is resolved with a junction table.

SQL in a nutshell

Transactions and ACID

A transaction is a group of operations that must happen completely or not at all – like a bank transfer. ACID stands for atomicity (all or nothing), consistency (the rules hold), isolation (concurrent transactions do not interfere) and durability (what is committed survives a power cut).

Performance and security

Indexes make searches fast but slow down inserts a little. SQL injection – user input interpreted as SQL – is one of the most common security flaws; always use parameterised queries. NoSQL databases (document, key–value, graph) are alternatives when data does not fit fixed tables.

How to solve the problems

  1. Read FROM first (which table), then WHERE (which rows), then SELECT (what is shown).
  2. Go through the rows one by one and check the condition.
  3. Apply the aggregate function to the remaining rows.

Example

The table Employee has the salaries 520,000, 610,000, 480,000 and 700,000. What does SELECT COUNT(*) FROM Employee WHERE salary > 500000; give?

  1. The rows with salary above 500,000: 520,000, 610,000 and 700,000.
  2. COUNT(*) counts them: the result is 3.

Common mistakes

FROM → WHERE → GROUP BY → SELECT → ORDER BY. Primary key identifies, foreign key links.

Concepts in this part

Practise relational databases and SQL in the app →

2. IP networks and subnetting

What is it about?

Everything connected to the internet has an IP address. To split a network into smaller parts, for example one for the office and one for production, you use subnetting. You also need to calculate how long it takes to send data.

In short

232−p−22^{32-p} - 2

because the network address (first) and the broadcast address (last) cannot be used by machines.

The layer model

Network communication is split into layers, each using the services of the layer below. In the TCP/IP model:

Addresses in practice

More on subnetting

The prefix sets the size: each bit borrowed from the host part halves the subnet and doubles the number of subnets. A /24 can be split into two /25 (126 hosts each), four /26 (62) or eight /27 (30). VLSM lets you use different sizes as needed, for example /30 (2 hosts) for point-to-point links between routers. Always plan for growth.

IPv6

IPv4 has only about 4.3 billion addresses, and they have run out. IPv6 has 128-bit addresses written in hexadecimal (2001:db8::1), so many that every device can have a public address without NAT.

Troubleshooting

ping tests whether a host replies, traceroute/tracert shows the path through the routers, ipconfig/ip addr shows your own configuration, and nslookup tests DNS. Often the problem is a wrong gateway, wrong subnet mask or DNS.

How to solve the problems

  1. Hosts: compute 232−p−22^{32-p} - 2.
  2. Network address: block size 232−p2^{32-p}, divide the last octet by it and round down.
  3. Time: convert MB to bits (⋅8\cdot 8) before dividing by Mbit/s.

Example

How long does it take to download 100 MB at 50 Mbit/s?

  1. 100 MB=800100\ \text{MB} = 800 Mbit.
  2. t=800/50=16t = 800/50 = 16 s.

Common mistakes

Hosts = 2^(32−p) − 2. Bytes × 8 = bits.

Concepts in this part

Practise iP networks and subnetting in the app →

3. Cyber security

What is it about?

Every engineer needs basic cyber security: data must be kept secret, not changed behind your back, and be available when needed. Many attacks start with a weak password or a tricked user.

In short

H=L⋅log⁡2NH = L\cdot\log_2 N

What must be protected?

ICT security is about protecting confidentiality (only the right people can see), integrity (data is not changed without authorisation) and availability (the system works when needed) – the CIA triad. A risk assessment combines likelihood and impact to prioritise measures.

Common attacks

Defence in depth

Regulation and incident response

GDPR requires personal data to be secured and breaches to be reported to the Data Protection Authority within 72 hours. NSM (the Norwegian National Security Authority) publishes basic principles for ICT security. During an incident: detect, contain, eradicate, recover and learn – and have the plan ready in advance.

How to solve the problems

  1. Entropy: multiply the length by log⁡2\log_2 of the number of possible characters.
  2. Cracking time: compute NLN^L and divide by guesses per second, then convert to a suitable unit.

Example

A password of 8 lowercase letters (26 possible characters):

  1. H=8⋅log⁡226≈8⋅4.70=37.6H = 8\cdot\log_2 26 \approx 8\cdot 4.70 = 37.6 bits.
  2. 268≈2.1⋅101126^8 \approx 2.1\cdot 10^{11} possibilities. At 101010^{10} guesses per second, all are tried in under half a minute.

Common mistakes

Strength = length × log₂(number of characters). Length beats complexity.

Concepts in this part

Practise cyber security in the app →

Example problems with solutions

Here are some of the problems in databases, Networks and Security. In the app, calculation problems get new numbers every time, so you can practise until it sticks – and take a practice exam with an indicative grade as you prepare for the exam.

Relational databases and SQL: What is a primary key in a table?

Answer: A column that identifies each row uniquely

The primary key is unique and never empty, so each row can be found unambiguously. A column pointing to another table is a foreign key.

IP networks and subnetting: How many usable host addresses does a /26 network have?

Answer: 62

232−26−2=64−2=622^{32-26} - 2 = 64 - 2 = 62.

Cyber security: How many bits of entropy does a random password of 8 lowercase letters (26 possible characters) have?

Answer: 37.604 bit

H=8⋅log⁡226≈8⋅4.70=37.6H = 8\cdot\log_2 26 \approx 8\cdot 4.70 = 37.6 bits.

Relational databases and SQL: The table Employee has the salaries 520,000, 610,000, 480,000 and 700,000. What does the query return?
SELECT COUNT(*) FROM Employee WHERE salary > 500000;

Answer: 3

The rows above 500,000 are 520,000, 610,000 and 700,000. COUNT(*) gives 3.

Practise all the problems →

Matches these university courses

The content follows the syllabus found in, for example: