LEFT(ThisString : STRING, x : INTEGER) RETURNS STRINGReturns the leftmost x characters.
Example: LEFT("ABCDEFGH", 3) returns "ABC".
Computers store all data as binary (base 2). Humans group binary into hexadecimal (base 16) because each hex digit maps to exactly 4 bits, making long binary strings readable.
| Decimal | Binary | Hex |
|---|---|---|
| 0-9 | 0000-1001 | 0-9 |
| 10 | 1010 | A |
| 15 | 1111 | F |
| 255 | 1111 1111 | FF |
Binary prefixes use powers of 1024 (210): kibi (KiB) = 1024, mebi (MiB) = 10242, gibi (GiB) = 10243, tebi (TiB) = 10244. Decimal prefixes use powers of 1000: kilo = 103, mega = 106, giga = 109, tera = 1012.
Each decimal digit (0-9) is encoded in 4 bits independently. The number 47 in BCD is 0100 0111, not 00101111. Used where decimal accuracy matters (calculators, currency).
The most significant bit becomes the sign bit with a negative place value. In 8-bit two's complement the range is −128 to +127.
| ASCII | Unicode |
|---|---|
| 7/8 bits (128/256 characters) | 16/24/32 bits (millions of characters) |
| English alphabet only | All world scripts |
| Small files | Larger files |
| No multi-language support | Superset of ASCII, backward compatible |
Bitmap images store a colour value for every pixel.
| Parameter | Effect |
|---|---|
| Higher bit depth | Larger file size, richer & more realistic colours |
| Higher resolution | Larger file size, sharper image, less pixelation |
Vector images store geometric coordinates, drawing commands, and object properties (colour/line width). Advantages: resize without pixelation, smaller file size. Disadvantages: poor compression, unsuitable for photos. For logos & line art only.
Sound is captured by sampling amplitude at regular intervals.
| Parameter | Effect |
|---|---|
| Higher sampling rate | Larger file, smaller quantisation error, closer to original sound |
| Higher bit depth | Larger file, wider dynamic range, more accurate amplitude recording |
Reduce file size, speed up transmission, and save storage space.
The original file can be restored completely. It only removes redundant data, so it is suitable for text and executable files. Examples include RLE and FLAC.
Unnoticeable details are discarded to achieve a higher compression ratio. It is suitable for audio, images, and video. Examples include MP3 and JPEG.
Consecutive identical data is encoded as a repeat count plus a value. Its weak point is that files without repeated data can become larger.
| LAN | WAN |
|---|---|
| Small geographic range | Cross-region coverage |
| Private self-owned cables & hardware | Relies on public operator infrastructure |
Central server provides resources, clients send access requests. Advantages: centralised security & backup, uniform resource management. Examples: web server, print server, file server.
All devices equal, data stored separately on each device. Disadvantages: no unified security/backup, virus spread easily, offline devices lose shared data.
| Thin Client | Thick Client |
|---|---|
| Server completes all computation & storage | Local device handles most computation |
| Client only sends requests & displays results | Server only offers auxiliary functions |
| Highly dependent on network | Can work offline |
| Topology | Pros | Cons |
|---|---|---|
| Bus | Cheap, simple | Single cable fault paralyses whole network |
| Star | Single device fault isolated, easy maintenance & expansion | Central switch is a single point of failure |
| Mesh | Highly resilient (multiple paths) | Expensive, complex routing |
| Hybrid | Combines multiple topology types | Needs dedicated connecting hardware |
| Public Cloud | Private Cloud |
|---|---|
| Third-party service over public internet | Dedicated internal network for single organisation |
| Open to all authorised users | Full user control |
Pros: Access anywhere with internet, provider handles backup & maintenance. Cons: Inaccessible without network, data security relies on third party.
| Medium | Advantages | Disadvantages |
|---|---|---|
| Copper (Twisted Pair) | Low cost, easy installation | Electromagnetic interference, short distance |
| Fibre Optic | High bandwidth, anti-interference, hard to tap | High cost, easy damage from sharp bending |
| Wireless (WiFi/Microwave/Satellite) | Mobile device support, no wiring | Signal attenuation, easy interception & interference |
| Device | Function |
|---|---|
| NIC/WNIC | Unique MAC address, send/receive wired/wireless data |
| Switch | Forward data packets to target device by MAC address |
| WAP | Convert wired network to WiFi for wireless device access |
| Repeater | Recover attenuated digital signals for long-distance transmission |
| Bridge | Connect two LANs with identical communication protocols |
Core Functions: Connect different networks (LAN to WAN); Forward packets based on destination IP; Maintain routing table; Assign private IP addresses to internal devices.
Working Flow: Device listens to channel before sending → sends data only when idle → collision triggers a jam signal → devices wait a random time to resend.
| Internet | WWW |
|---|---|
| Global interconnected network system | Collection of web pages on internet |
| Based on TCP/IP | Uses HTTP/HTML |
| Underlying hardware infrastructure | Accessed via browsers |
Workflow: Browser sends domain request to DNS server → DNS matches the domain to its IP and caches the result → returns the IP to the browser.
| Primary (RAM) | Secondary (HDD/SSD/USB) |
|---|---|
| Temporary storage for running programs | Permanent storage for file saving, backup & data transfer |
| Volatile (lose data without power) | Non-volatile (retain data) |
| RAM | ROM |
|---|---|
| Read & write | Read-only |
| Volatile | Non-volatile |
| Store running software | Store boot BIOS firmware |
| SRAM | DRAM |
|---|---|
| Flip-flop storage, no refresh needed | Capacitor charge storage, regular refresh required |
| Fast, high cost | Low cost, large capacity |
| Used for CPU cache | Main memory |
| Type | Feature |
|---|---|
| PROM | One-time programmable |
| EPROM | Erase via UV light, need disassembly |
| EEPROM | Electric erase on-device, support partial rewrite, firmware update support |
| Medium | How it stores | Examples |
|---|---|---|
| Magnetic | Magnetised regions on a spinning platter | HDD, magnetic tape |
| Optical | Pits and lands read by a laser | CD, DVD, Blu-ray |
| Solid-state | Floating-gate transistors | SSD, USB drive, SD card |
| Device | How it works |
|---|---|
| Laser Printer | Laser forms electrostatic image on photosensitive drum, toner adheres to charged area, transfer & fuse toner onto paper |
| 3D Printer | Additive manufacturing, print layer by layer based on CAD model, temperature sensor prevents overheat |
| Microphone | Sound wave vibrates diaphragm, convert mechanical vibration to electrical signal |
| Speaker | Convert electrical audio signal to vibration to generate sound wave |
| HDD | Rotating magnetic platters, read/write head record magnetic signals; low cost, large capacity |
| SSD | NAND flash memory, no moving parts; fast read/write, shock resistant, quiet |
| Touchscreen (Resistive) | Two conductive layers contact under pressure to calculate coordinate |
| Touchscreen (Capacitive) | Human finger absorbs electric charge, corner sensors locate touch point |
| Gate | Symbol notation | Output is 1 when… |
|---|---|---|
| AND | A · B | both inputs are 1 |
| OR | A + B | at least one input is 1 |
| NOT | A′ | input is 0 |
| NAND | (A · B)′ | NOT both inputs are 1 |
| NOR | (A + B)' | both inputs are 0 |
| XOR | A ⊕ B | inputs differ |
| Monitoring System | Control System |
|---|---|
| Only collect sensor data | Includes sensors + actuators + feedback |
| No automatic mechanical action | Auto-adjusts parameters |
Sensor Types: temperature, pressure, infrared, sound, light, accelerometer. Actuator: converts electrical signal to mechanical movement. Feedback Function: output result adjusts input value, keeps system within set range.
| Register | Full Name | Purpose |
|---|---|---|
| PC | Program Counter | Address of next instruction to fetch |
| MAR | Memory Address Register | Memory address for read/write |
| MDR | Memory Data Register | Data transferred between CPU & memory |
| CIR | Current Instruction Register | Store executing instruction |
| ACC | Accumulator | Store arithmetic operation values |
| Status Reg | Status Register | Operation flags (overflow, zero result etc.) |
| Bus | Direction | Carries |
|---|---|---|
| Address Bus | Unidirectional | Memory/IO address |
| Data Bus | Bidirectional | Data content |
| Control Bus | Bidirectional | Read/write, interrupt timing signals |
An interrupt is a signal that pauses normal CPU execution so a higher-priority task can be handled.
Handling: save state on stack — run ISR (interrupt service routine) — restore state — resume.
Sources: hardware fault, IO request, program runtime error, time slice end.
First Pass: scan code, build symbol table for labels & memory addresses. Second Pass: replace symbolic labels with absolute memory addresses, generate machine code.
| Mode | Operand means… |
|---|---|
| Immediate | The actual value (e.g. LDM #5) |
| Direct | The address that holds the value (LDD 100) |
| Indirect | The address that holds the address (LDI 100) |
| Indexed | Address = base + index register (LDX 100) |
| Relative | Offset from current instruction address, supports relocatable code |
Instruction Categories: data movement, IO, arithmetic, conditional/unconditional jump, comparison.
| Utility | Function |
|---|---|
| Disk Formatter | Partition disk, create file system, mark bad sectors |
| Virus Checker | Scan, quarantine, delete malicious programs, update virus database |
| Defragmenter | Rearrange split file fragments, reduce hard disk seek time |
| Disk Repair | Recover corrupted data, mark unusable bad sectors |
| Compression Tool | Shrink file size |
| Backup Tool | Create recoverable file copies |
| Firewall | Block unauthorised external network access |
Library: precompiled reusable functions, save development time, fully tested.
| Type | Behaviour | Use |
|---|---|---|
| Compiler | Translates the whole program once — executable. Fast at runtime; source code hidden. | Production builds. |
| Interpreter | Translates and runs line-by-line. Real-time error report; slower execution. | Scripting, interactive use. |
| Assembler | Translates assembly → machine code. | Low-level programming. |
| Feature | Description |
|---|---|
| Code | Auto-complete, context prompt |
| Error Detection | Real-time syntax highlighting |
| Presentation | Code fold, auto indent, color coding |
| Debug | Breakpoint, single step run, variable watch window |
| Concept | Definition |
|---|---|
| Security | Prevent data loss, damage & unauthorised access |
| Privacy | Restrict personal sensitive data from irrelevant viewers |
| Integrity | Guarantee data accurate, complete & uncorrupted |
| Threat | Description |
|---|---|
| Virus | Self-replicating program, damages local data |
| Spyware | Steals keyboard input data & transmits to third party |
| Hacker | Unauthorised remote access to devices |
| Phishing | Fake email/website tricks users into submitting private info |
| Pharming | Malware redirects users to fake counterfeit websites |
Regular backup, disk mirroring (two identical storage disks), UPS uninterruptible power supply.
| Validation (Check input reasonableness) | Verification (Check no error in input/transmission) |
|---|---|
| Presence check: field cannot be blank | Double data entry, manual visual comparison |
| Range check: numeric value within fixed interval | Parity check (byte/block): add parity bit to fix 1 count |
| Format/length check: match specified character rule | Checksum: calculate total of transmitted data, compare at receiver |
| Check digit: weighted sum modulo operation verify digit correctness |
Eight Principles: Prioritise public interest; Serve client & employer fairly; Ensure high-quality product; Independent objective judgment; Standardised team management; Fair to colleagues; Continuous self-learning & professional promotion.
| Type | Feature |
|---|---|
| Open Source | Full source code provided, user modify & redistribute freely |
| Shareware | Free trial period, full function unlock after payment, source code hidden |
| Commercial Software | Paid authorisation, no source code, official technical support |
| Freeware | Zero cost use, forbid modification & reverse engineering |
Applications: face recognition, self-driving car, speech assistant, game AI, license plate recognition.
Social Impact: privacy risk from biometric data collection; reduce manual labour positions.
Economic Impact: cut labour cost for enterprises, extra expense on AI hardware & maintenance.
| Form | Rule |
|---|---|
| 1NF | All fields atomic, no repeated group in one record. |
| 2NF | Eliminate partial dependency on composite primary key. |
| 3NF | Eliminate transitive dependency between non-key fields. |
-- DDL
CREATE TABLE Student (
StudentID INTEGER PRIMARY KEY,
Name VARCHAR(50) NOT NULL,
ClassID INTEGER,
FOREIGN KEY (ClassID) REFERENCES Class(ClassID)
);
ALTER TABLE Student ADD Email VARCHAR(100);
-- DML Query
SELECT Name FROM Student WHERE ClassID = 1 ORDER BY Name;
SELECT ClassID, COUNT(*) AS NumStudents FROM Student GROUP BY ClassID;
SELECT S.Name, C.ClassName FROM Student S INNER JOIN Class C ON S.ClassID = C.ClassID;
-- DML Modify
INSERT INTO Student VALUES (42, 'Lin', 1);
UPDATE Student SET ClassID = 2 WHERE StudentID = 42;
DELETE FROM Student WHERE StudentID = 42;