0% found this document useful (0 votes)
15 views

Untitled Document-2 2

The document provides an overview of data representation, including number systems like denary, binary, and hexadecimal, along with their applications and conversions. It discusses multimedia concepts such as bitmap and vector graphics, sound encoding, and compression methods. Additionally, it covers networking fundamentals, including LAN and WAN distinctions, client-server and peer-to-peer models, and various network topologies and transmission mediums.

Uploaded by

Laraib Fatima
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

Untitled Document-2 2

The document provides an overview of data representation, including number systems like denary, binary, and hexadecimal, along with their applications and conversions. It discusses multimedia concepts such as bitmap and vector graphics, sound encoding, and compression methods. Additionally, it covers networking fundamentals, including LAN and WAN distinctions, client-server and peer-to-peer models, and various network topologies and transmission mediums.

Uploaded by

Laraib Fatima
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 81

Representation

Data Representation
● The two fundamental characteristics of any number system are:
○ A base: The number of different digits that a system can use to
represent numbers
○ Place value: The specific-value of a digit based on its position within
a number
● Denary - Base 10
● Binary Systems - Base 2
○ Possible bits (binary digits): 0 and 1
○ All data and characters are represented in binary

128 64 32 16 8 4 2 1

0 0 0 0 0 0 0 0

● For example, 65 in binary is 01000001

● Denary vs. Binary prefixes:

Denary Prefix Factor Value Binary Prefix Factor Value

kilo- (k) ×103 kibi- (Ki) ×210

mega- (M) ×106 mebi- (Mi) ×220


giga- (G) ×109 gibi- (Gi) ×230

tera- (T) ×1012 tebi- (Ti) ×240

● Binary Coded Decimal (BCD)


○ Binary representation where each positive denary digit is
represented by a sequence of 4 bits (nibble).
○ Only certain digits are converted to BCD because particular digits
represent a digit greater than 9.
■ For example, to represent 429 in BCD:
■ Convert each individual digit of the number to its binary
equivalents -
1. 4 = 0100
2. 2 = 0010
3. 9 = 1001
■ Concatenate the 3 nibbles (4-bit group) in order to produce
BCD: 0100 0010 1001
● Practical applications
○ A string of digits on any electronic device displaying numbers (like
in calculators)
○ Accurately measuring decimal fractions
○ Electronically coding denary numbers
● Two’s Complement
○ We can represent a negative number in binary by making the most
significant bit (MSB) a sign bit, which indicates whether the number
is positive or negative.
○ Converting from negative denary to binary two’s complement
(example -42):
■ Find the binary equivalent of the denary number (ignoring the
negative sign) | 42 = 101010
■ Add extra 0 bits before the MSB, to format the binary number
to 8 bits | 00101010
■ Convert binary number to one’s complement (flip the bits) |
11010101
■ Convert binary number to two’s complement (add 1) |1010101 + 1 =
11010110
○ Converting binary two’s complement into denary (example
11010110):
■ Flip all the bits | 00101001
■ Add 1 | 00101010
■ Convert binary to denary and put a negative sign) | -42
● Maximum positive number in 8 bits: 127
● Maximum negative number in 8 bits: -128
● Hexadecimal Systems - Base 16:
○ Possible digits: 0 to 9 and A to F, where A to F represent denary digits 10
to 15
○ Practical applications:
■ Defining colours in HTML
■ Defining Media Access Control (MAC) addresses
■ Assembly languages and machine code
■ Debugging via memory dumps
○ Example - A5 in Denary = (16×10) + (1×5) = 165
○ Example - 65 in Hexadecimal = 65÷16 = 4 | Remainder 1 | ∴ = 41
● Character Sets:
○ A character set generally includes upper & lower case letters, number
digits, punctuation marks, and other characters.
○ Character sets use different binary representations for each character via
character encoding
● Character Encoding Standards:

ASCII Extended ASCII Unicode

Only the English alphabet ASCII’s extension - Also Superset for ASCII &
can be represented includes most European extended ASCII - recognized
languages’ alphabets by various global languages
Each character encoding ASCII extended to 8 bits, It has an excellent range of
takes up 7 bits, hence 128 hence 256 possible characters, using 2 or 4
possible characters characters bytes per character

Smaller storage space 2 or 4 times more storage


space per character

Multimedia - Graphics, Sound


● Bitmap Images
○ Definition: Bitmap images are created by assigning a solid color to each
pixel using bit patterns.
○ Encoding:
■ Bit patterns are generated by considering each grid row as a series
of binary color codes corresponding to each pixel’s color.
■ These bit patterns are ‘mapped’ onto the main memory.
○ Pixels: The smallest picture element whose color can be accurately
represented by binary code.
○ File Header: Bitmap images contain a file header with metadata, including
image size, number of colors, etc.
● Image Resolution
○ Definition: the number of pixels that make up an image. Example:-
4096x3192 pixels.
○ Effect: Higher resolution results in sharper, more detailed images.
● Screen Resolution
○ Definition: The number of pixels that can be viewed horizontally and
vertically on a device’s screen.
○ Calculation:
○ Number of pixels=width×height
○ Number of pixels=width×height (e.g., 1680 × 1080 pixels).
● Colour depth
○ Definition: The number of bits used to represent the colour of a single
pixel.
○ Calculation: An image with
○ n
○ n bits has 2
n

n
○ colours per pixel (e.g., a 16-color bitmap has 4 bits per pixel because 2

4

4
○ = 16)
○ Effect: Increasing color depth improves color quality but also increases file
size.
○ File Size Calculation:
■ File Size = Number of Pixels × Color Depth
■ Convert bits to bytes by dividing by eight if necessary.
○ Applications: Scanned images and general computer usage, where small
file sizes and easy manipulation are beneficial.
● Vector Graphics
○ Definition: Made up of drawing objects.
○ Drawing Objects: Mathematically defined constructs (e.g., rectangles,
lines, circles).
○ Drawing List: A set of commands defining the vector.
○ Properties: Basic geometric data that determine the shape and
appearance of each object.
○ Encoding: Data is encoded using mathematical formulas to generate
properties for drawing lines and curves to create the image.
○ Scalability: Objects can be resized without losing quality, unlike bitmaps.
○ Applications: Company logos and other graphics that require scaling.
● Sound
○ Analogue vs Digital:
■ Analogue data consists of continuous electrical signals.
■ Digital data consists of discrete electrical signals.
○ Sound Signals: Vibrations through a medium, inherently analogue due to
infinite detail.
○ Conversion:
■ Analogue signals are converted to digital signals by sampling.
■ The sound wave’s amplitude is sampled at set time intervals.
■ These samples are encoded as a binary number sequence,
providing a digital representation of the sound wave
● Sampling Rate
○ Definition: Number of samples taken per unit of time.
○ Effect: Increasing the sampling rate improves the accuracy of the digitized
sound wave representation but increases file size.
● Sampling Resolution
○ Definition: Number of bits used to encode each sample.
○ Effect: Increasing sampling resolution improves the accuracy of digitized
sound waves but increases file size.
● Bit Rate
○ Definition: Number of bits used to store 1 second of sound.
○ Calculation:
○ Bit Rate=Sampling Rate∗Sampling Resolution
○ Bit Rate=Sampling Rate∗Sampling Resolution
○ Length of Sound: Measured in seconds.

Compression
● Definition: Compression is the process of reducing file size without significant
loss in quality, resulting in:
○ Reduced time needed to search for data.
○ Faster transfer of compressed files, using less bandwidth than
uncompressed files.
● Lossless Compression
○ Definition: A type of compression that allows original data to be perfectly
reconstructed from a compressed file by utilizing some form of
replacement.
○ Examples: Bitmap (.bmp), vector graphic (.svg), .png images, text file
compression, database records.
○ Run-Length Encoding (RLE):
■ Definition: A form of lossless compression used for compressing text
files and bitmap images.
■ Mechanism: Reduces file size by encoding sequences of adjacent,
identical elements (characters in text files and pixels in bitmap
images) into two values: run count and run value.
■ Example: RLE of a bitmap image.
● Lossy Compression
○ Definition: A type of compression that irreversibly eliminates unnecessary
data.
○ Effect: File accuracy/quality is lower than with lossless compression, but
file size is significantly reduced (often to about 10% of the lossless size).
○ Examples: Sound files (.mp3), .jpeg images.
○ Mechanism in Sound Files:
■ Perceptual Coding: Removes parts of the sound that are less audible
or discernible to human hearing, as used in .mp3 compression.
Networks, including the Internet

LAN WAN

A network that connects devices A network that connects devices within


within a small geographical area, a larger geographical area, such as a
often within the same building. city, country, or globally.

Only private ownership. Private or public ownership.

Transmission medium: Twisted Pair Transmission medium: PSTN or


Cables , Coaxial Cables or Wi-Fi. Satlink.

Higher data transfer rate. Lower data transfer rate.

Less congestion. Higher congestion.

● Networking devices: Interconnected devices that enable fast data


transmission within a network.
● Networking benefits:
○ File sharing: Easily share data between different interconnected
devices.
○ Resource sharing: Use network-connected output devices like
printers or share software within the network.
○ Higher storage: Files can be stored in network-connected storage
mediums.
● Client-Server Model
○ Server-based network: A dedicated server provides applications
(administration of users, security, and resources) for the client
computer to utilize.
○ Client-server Applications:
■ Printer: Manages print jobs from client computers.
■ File Sharing: Clients access software and user data files
stored on the server.
■ Proxy server.
■ Email server: For sending, receiving, and storing emails.
■ Database server: Manages DBMS.
■ Domain controller server:
■ Manages user accounts (IDs & passwords).
■ The client sends a login request to the server, which
processes and grants the request if the user ID &
password are recognized.

Thin Clients Thick Clients

A client that solely runs on the resources An independent client that


provided by the server and has no local does not require the server to
storage. run.

Only provides input and receives output; Thick client processes most of
processing is done by the server. the application locally.

Smaller purchase cost: inexpensive, Can function even if no server


demanding hardware is not required. is connected (works offline).

Improved security: Cannot run unauthorized, No lag related to network


harmful software. problems.

● Thin Clients vs. Thick Clients


● Peer-to-Peer network model (P2P)
○ Definition: A decentralized network where each connected computer
stores data and operates independently as a ‘peer’, acting as both a
client and a server.
○ Applications: Internet and Ad hoc networks.

Client-Server Peer-to-Peer

Centralized backup. Lesser initial setup cost.

Files & resources centralized in Lesser network traffic: Each peer can
server: Prevents illegal resource simultaneously receive data from
usage. different sources.

Improved security: Files are stored on It can work even if a device goes
a central server, which would be down, but the client-server model
regularly scanned for malware. can’t work if the server goes down.

● Client-Server vs. Peer-to-Peer models


● Network Topologies
○ Bus
■ A single line (bus) connects all devices with terminators at
each end.
■ Other computers can read data being sent between any two
computers.
■ Unsuitable for heavy traffic due to frequent collisions.
○ Star
■ Consists of a central server (switch) with all other computers
connected via dedicated connections.
■ The server can send packets to different devices
simultaneously and bidirectionally.
■ No collisions are possible.
○ Mesh
■ Every device (node) is directly interconnected with each of the
other devices (nodes).
■ Commonly used for wireless networks, such as the Internet,
through the mesh connection of routers.
○ Hybrid
■ A combination of two or more topologies.
■ Example: A connection between two or more LANs of different
topologies.

Benefits Drawbacks

Copp Less expensive and easier to install. Flexible. Doesn’t perform well
er Easier to make terminations. with small charges.
Cable Affected by
electromagnetism.

Fiber Greater bandwidth, improved security, Needs expensive


-Opti lightweight, easy to install, and less signal optical transmitters
c boosting are required; used in long-distance and receivers.
Cable communications.
s

● Wired Networks
○ Use copper (twisted-pair cable or coaxial cable) or fiber-optic cables.
○ Cables are connected to an Ethernet port on the network router.

Benefits Drawbacks

Radio Can travel over large distances Low frequency means less
waves with a wide range of wavelengths. data can be transmitted at one
Relatively inexpensive. Used for time. Affected by interference
TV signals and mobile phone from radio stations with similar
communications. frequencies.
Microwa Larger bandwidth allows more Expensive to build emitting
ves data transfer. towers. Physical obstacles can
interfere with signals.

Satellites Cost-effective for long-distance Susceptible to interference.


communication, used in satellite Expensive setup.
phones and radio broadcasts.

● Wireless Networks
○ Use radio waves (including WiFi), microwaves, and satellites to
connect devices to networks without cables.

Real-time On-demand

The event is captured live via a video Existing digital files are converted to
camera that is connected to a encoded bit-streaming format for
computer. broadcasting on the internet by
uploading to a dedicated server.

Video signal converted to an encoded A link for encoded video is placed on


streaming video signal. the website, and the user clicks on the
link to view encoded streaming video.

Encoded video signal uploaded from The data is streamed to a buffer in the
computer to a dedicated streaming user’s computer, and the buffer stops
server via cables or high-speed the video from being paused as the
wireless internet connection. bits are streamed.

The server then sends live images to As the buffer is emptied, it’s filled
all users requesting them as a again, thus providing continuous
real-time video. viewing.
It cannot be paused, fast-forwarded, Can be paused, fast-forwarded, etc.
etc.

● Ethernet
○ The most common wired medium for data transmission in LANs or
WANs.
○ Typically used in bus topology; data collisions are managed by the
CSMA/CD (Carrier Sense Multiple Access with Collision Detection)
method.
○ CSMA/CD Process:
■ Device checks if the channel is busy before transmitting.
■ If busy, the device waits a random time before retrying.
■ During transmission, the device listens for other
transmissions.
■ If a collision occurs, transmission is aborted, and both devices
wait random times before retrying.
● Bit Streaming
○ Sequence of digital signals (bits) transferred over a communication
path at high speeds, requiring a fast broadband connection and
buffers.
○ Bit Streaming Types:
■ Real-time: Live events captured and transmitted directly.
■ On-demand: Pre-existing files are converted and streamed as
requested.
○ Importance of High Broadband Speed/Bit-Rate
■ The user has to download and display bits at the same time.
■ Higher quality media requires faster speeds due to larger data
frames as well.
■ Real-time streaming needs higher speeds due to simultaneous
data requests coming from multiple different users.

● Cloud Computing
○ On-demand provision of computing services over the internet,
including infrastructure, and platforms.
■ Infrastructure: Storage capacity and higher processing power.
■ Platform: Software, testing & debugging resources.
Public cloud vs. Private cloud

Public cloud Private Cloud

Access provided by third-party service Owned and maintained by a single


providers, shared among multiple organization, providing exclusive
users. access.

Managed by cloud service providers Can be managed internally by the


using large server farms. organization itself, or outsourced.

Benefits Drawback

Less technical knowledge Cannot access the resources/data stored on the


required, easy to cloud if there are bandwidth issues.
implement.

Flexibility to scale with Poor data privacy, since there may be data
organization’s growth leakage in the multi-tenant architecture (public
mindset. clouds).

● World Wide Web (WWW):


○ Description: Collection of web pages stored on websites.
○ Function: Protocols are used to transmit data across the WWW.
● Internet (Interconnected Network):
○ Description: Massive, open network of networks.
○ Protocol: Uses TCP/IP protocol, which uses IP addresses to identify
devices connected to the internet.
○ Access: Provided by Internet Service Provider.
○ Communication Methods: Wired, radio, and satellite.
● Router in a Network:
○ Function: Connects two networks together which operate under the
same protocols (for example, IP).
○ Connections: Allows internal connections between LANs or external
connection from the main LAN to a WAN.
○ Additional Roles: Acts as a gateway and firewall.
○ Setup: Usually attached to a server or switch in a LAN.
○ IP Address Translation: Translates private IP addresses to public IP
addresses and vice versa.

● LAN-Supporting Hardware:
○ Switch:
■ Connected to all devices in a LAN.
■ Can simultaneously broadcast information to all devices.
○ Server:
■ Device/software that provides specific functions for computers
in the network.
○ Network Interface Card (NIC):
■ Provides each device (end-system) in the wired LAN with a
unique MAC address to uniquely identify it on the network.
■ Allows each device to connect to the network.
○ Wireless Network Interface Card (WNIC):
■ Provides each end-system of a wireless (WiFi) LAN a unique
network address to identify it.
○ Wireless Access Points (WAP):
■ Allows devices to connect to the LAN via WiFi instead of using
a cable.
■ Usually built into the router.
○ Cables:
■ A wired transmission medium that allows communication in
wired networks.
○ Bridge:
■ Connects two LANs which work using the same protocol,
which can be two segments of the same network.
■ Stores network addresses for all devices (end-systems)
between the two networks.
■ Looks for the receiving device before it sends the message.
○ Repeater:
■ Connects two cables.
■ Regenerates the sent data signal over the same network
before the signal weakens (attenuation) to prevent it from
being corrupted.

● Internet-Supporting Hardware:
○ Modems:
■ Allows a device to connect to the Internet via a telephone line.
■ Function: A transmitter uses a modem to convert digital
signals (from the transmitting device) to analogue signals sent
down the telephone line. A receiver uses a modem on the
other end to convert the analogue signals to digital signals so
the receiving device can understand the data.
○ PSTN (Public Switched Telephone Network):
■ Refers to all telephone networks.
■ Channel: Used between two endpoints for the call duration via
circuit switching.
■ Resilience: Lines are active even during a power outage.
■ Communication: Bi-directional.
○ Dedicated Lines:
■ Telecommunication path between endpoints.
■ Not shared with multiple users; it’s bought/leased.
■ Function: Able to host websites as well as carry phone calls.
Allows continuous, uninterrupted access to the Web.
○ Cell Phone Network:
■ Wireless networks spread over land areas divided into
(hexagonal) cells.
■ Base Stations: Each cell is served by at least one base station
(transceiver), which uses a different frequency range
compared to adjacent cells to transmit data.
■ Capacity: Larger capacity is possible since the same
frequencies can be used in non-adjacent cells.
■ Transmission: Radio waves are usually used for transmission.
Can be broadcast in all directions over a wide area.
■ Portable Transceivers: Devices like mobile phones can
communicate and access the internet via base stations.

IPv4 IPv6

32-bit address, The 128-bit address is divided into eight 16-bit blocks by
split into 4 blocks “:”
by “.”

Each block could Each block can have 4 hex values ranging from 0000 to
have a value FFFF.
between 0 and 255
(00 to FF in hex).

For example, IPv6 can be shortened by removing at least (≥) 2 blocks


255.0.1.255. containing only zeroes. For example:
“2001:0db8:85a3:0000:0000:8a2e:0070:7334” can be
shortened to “2001:0db8:85a3::8a2e:0070:7334"

● IPv4 vs. IPv6


● IPv4 Functionality:
○ IP Address Structure:
■ Network Identifier (netID): Identifies the network to which the
host (device) is connected.
■ Host Identifier (hostID): Identifies the host within the network.
■ Classful Addressing: Used for IPv4, where different bit lengths
for identification impose restrictions on available addresses.
○ Subnetting:
■ Definition: The practice of dividing a network into two or more
networks.
■ Structure: IP addresses are broken down into three parts by
not changing the netID but partitioning the host ID into a
subnet ID and host ID.
■ Subnet ID: These bits are used to identify each subnet
within the network.
■ Subnet Masks: Numbers that hide (mask) the netID of a
system's IP address and leave only the host part as the
machine identifier, allowing data to be routed within the
subnet to the appropriate host.

● Public and Private IP Addresses:


○ Public IP:
■ Provided by the ISP.
■ Unique and can be accessed across the internet.
○ Private IP:
■ Issued by the LAN’s router.
■ Unique within the LAN and can only be accessed within the
LAN.
■ NAT (Network Address Translation): Required for private IP
addresses to access the internet directly.
■ Security: Private IPs are more secure than public IPs since
they are not directly accessible on the Internet and are hidden
by NAT.
■ Address Range: The range of IP addresses used for private IP
addressing can never be assigned to public IP addresses.

Static Dynamic

IP address never changes. The IP address will change at


regular periods.
Static IP addresses are valid when Dynamic IP address is relatively
websites need to remember a device for more secure, hence used where
a long time, e.g VPNs whitelisting. data privacy is quite important.

Faster upload/download speeds. Maintaining the cost of the dynamic


IP address is a lesser.

● Static vs. Dynamic IP addresses

● URL (Uniform Resource Locator)


● Unique reference address for the exact location of an internet resource on
the WWW
● Protocol: Enables the browser to know what protocol is used to access
information in the domain.
● Host-name: The domain name.
● Location of Server: The path indicating the server location.
● Domain Name Service (DNS)
○ Definition: A naming system used for computers or resources having
an internet connection.
○ Structure: Consists of a hierarchy of DNS servers which have a URL
database and their corresponding IP addresses.
Computers and Their
Components
● A general-purpose computer system comprises a processor, memory, and I/O
functionality.
● The following essential features are needed in a computer -
○ Input: Takes in data from the outside world.
○ Output: Displays data for human understanding.
○ Primary Storage: Main memory storing critical program instructions and
data.
○ Secondary Storage: Non-volatile storage for noncritical data.
○ Removable secondary storage:
■ File backup and archives
■ Portable transfer of files to a second device
● Embedded systems:
○ Miniature computer systems such as microprocessors that are often a part
of a more extensive system.
○ Each embedded system performs a few specific functions, unlike
general-purpose computers.

Benefits Drawbacks

Reliable since there are no moving Difficult to program functions since there is no
parts interface

Require less power Expensive expert help is needed for the repair

Cheap to mass-produce
Principle Operations of Hardware Devices

Laser printer:

● A laser beam and rotating mirrors are used to draw an image of the page on a
photosensitive drum
○ The image is converted into an electric charge, which attracts charged
toner such that it sticks to the image
● Electrostatic-charged paper rolled against the drum
● Charge pulls toner away from drum and onto paper
● Heat applied in the fuser to fuse toner to the paper
● The electrical charge was removed from the drum, and excess toner was
collected
3D Printer:

● The process starts with a saved digital file that holds the blueprint of the object to
be printed
● The object is then built by sequentially adding layers of a material (e.g. polymer
resin) until the object created
● The object is then cured (e.g. resin-made objects are hardened by UV light)
Microphone:

● Incoming sound waves enter the screen and cause vibrations in the diaphragm
● Vibrations cause the coil to move past a magnetic core
● Electrical current is generated, which is then digitized
Speaker:

● Takes electrical signals and translates them into physical vibrations to create
sound waves
● The electric current in the voice coil generates an electromagnetic field
● Change in digital audio signal causes current direction to change, which changes
field polarity
● Electromagnet is either attracted or repelled to a permanent magnet, causing a
diaphragm that is attached to the coil to vibrate
● Vibration transmitted to air in front of the speaker
● The degree of vibration determines the amplitude and frequency of the sound
wave produced
Magnetic Hard Disk:

● Hard disks have platters whose surfaces are covered with a magnetisable
material.
● Platters are mounted on a central spindle and rotated at high speed
● The surface of platters is divided into concentric tracks & sectors, where data is
encoded as magnetic patterns
● Each surface is accessed by read/write heads
● When writing, current variation in the head causes magnetic field variation on the
disk
● When reading, magnetic field variation from the disk produces current variation in
the read head
Solid State (Flash) Memory:

● Most use NAND-based flash memory


● Consist of a grid of columns & rows that has 2 transistors at each intersection
● Two transistors:
● Floating Gate: stores electrons, and the presence or absence of charge
(electrons) represents either 1 or 0
● Control Gate: controls charge (electrons) flow for read/write
Optical Disc Reader/Writer:

● The disc surface has a reflective metal layer and is spun


● The tracking mechanism moves the laser assembly
● The lens focuses laser onto the disc
● A laser beam shone onto a disc to read/write
● Tracks have sequences of amorphous and crystalline states on the metallic layer
● When reading, the reflected light from the different states on the track is encoded
as bit patterns
● When writing, the laser changes surface to crystalline and amorphous states
along the track, corresponding to 1s or 0s.
Touchscreen:

● Considered as both an input & output device


● There are two main-types:
Resistive Capacitive

Consists of two charged plates Made from materials that store


electric charge

Pressure causes plates to touch, completing the When touched, the charge is
circuit transferred to the finger

Point of contact registered with coordinates


used to calculate the position

● Virtual (Reality) Headset:


○ Virtual headsets consist of 2 lenses, (an LCD) display, a circuit board with
sensors, a cover and foam padding
○ The display provides a simulation of a 3D environment generated by a 3D
graphics package
○ The user can ‘move’ in the virtual environment by moving their head or
using controllers
● Buffers:
○ A queue that temporarily stores data to balance input/output speed of
data, while the cache is the short-term memory storage that stores
frequently used data.
● Random Access Memory vs. Read-Only Memory

RAM ROM

Volatile memory: loses content when Non-volatile memory: does not lose content
power is turned off when power is turned off

It can be read and altered It can only be read


Used to store currently executing Used for storing OS kernel and boot-up
program instructions

● Types of RAM - Static RAM vs. Dynamic RAM

SRAM DRAM

Doesn’t need to refresh; hence, it uses Has to be refreshed; it has slower access
less power and faster access time times and needs higher power

More complex circuitry, hence more Only a single transistor & capacitor,
expensive hence less expensive to purchase

Each bit is stored in a flip-flop Each bit is stored as a charge

Has lower data density Has higher data density

Used in cache memory Used in main memory

● Types of ROM – PROM vs. EPROM vs. EEPROM

PROM EPROM EEPROM

Programmable ROM Erasable Programmable Electrically Erasable


ROM Programmable ROM
It can be It can be erased by UV light It can be erased by an
programmed only exposure and can then be electrical signal and can then
once after it is reprogrammed be reprogrammed
created

Data cannot be Chip has to be removed for Can update data without
erased or deleted reprogramming removing the chip.

● Monitoring and Control Systems


○ Monitoring System:
■ Monitors some state external to the computer system
■ No changes were made to the environment by the system, and
hence, no feedback
○ Control System:
■ Regulates the behaviour of other devices or systems
■ Event-driven system: the controller alters the system's state in
response to some event
■ Time-driven system, where the controller takes action at a specific
point in time
○ Hardware typically used in a system:
■ Sensor that measures an (analogue) property and transmits it to a
processing unit, generally as an electrical or optical signal
■ Actuators that switch on/off heavy appliances (e.g. heater to
heat/fan to cool)
■ ADC that converts analogue signals to digital signals
■ Transmission cable to transfer signals
○ Feedback Systems:
■ Output from the system affects the input of sensors
■ Ensures the system operates within the given criteria
■ Enabling the system output to affect subsequent system inputs may
cause a change in the actions taken by the system
■ This enables the system to adjust conditions in a continuous
process automatically
Logic Gates and Logic Circuits
● Logic Gates: use one or more inputs and produce a single logical output
● AND gate: If both inputs are high, the output is high (A•B)

A B Output

0 0 0

0 1 0

1 0 0

1 1 1

● OR gate: If either input is high, the output is high (A+B)

A B Output
0 0 0

0 1 1

1 0 1

1 1 1

● NOT gate: an inverter (A)

A Output

1 0

0 1
● NAND gate: (A•B)

A B Output

0 0 1

0 1 1

1 0 1

1 1 0

● NOR gate: (A+B)


A B Output

0 0 1

0 1 0

1 0 0

1 1 0

● XOR gate: (A⨁B)

A B Output

0 0 0

0 1 1

1 0 1
1 1 0
Fundamentals
Central Processing Unit (CPU)
Architecture
Von Neumann model

● Von Neumann realized data & programs are indistinguishable and can, therefore,
use the same memory.
● Von Neumann's architecture uses a single processor.
● It follows a linear sequence of fetch–decode–execute operations for the set of
instructions, i.e. the program.
● To do this, the processor uses registers.
Registers

● Registers: smallest unit of storage of microprocessor; allows fast data transfer


between other registers
● General Purpose registers
○ Used to temporarily store data values which have been read from memory
or some processed result
○ Assembly language instructions can use it
● Special Purpose Registers
○ Some are accessible by assembly language instructions
○ Only holds either data or memory location, not both
○ Particular purpose registers include:
■ Program Counter (PC): holds the address of the next instruction to
be fetched
■ Memory Data Register (MDR): holds data value fetched from
memory
■ Memory Address Register (MAR): Holds the address of the
memory cell of the program which is to be accessed
■ Accumulator (ACC): holds all values that are processed by
arithmetic & logical operations.
■ Index Register (IX): Stores a number used to change an address
value
■ Current Instruction Register (CIR): Once program instruction is
fetched, it is stored in CIR and allows the processor to decode &
execute it
■ Status Register: holds results of comparisons to decide later for
action, intermediate and erroneous results of arithmetic performed
The Processor (CPU)

● Arithmetic and Logic Unit (ALU): part of the processor that processes instructions
which require some form of arithmetic or logical operation
● Control Unit (CU): part of the CPU that fetches instructions from memory,
decodes them & synchronizes operations before sending signals to the
computer’s memory, ALU and I/O devices to direct how to respond to instructions
sent to the processor
● Immediate Access Store (IAS): memory unit that the processor can directly
access
● System Clock: a timing device connected to a processor that synchronises all
components.
Buses

● Set of parallel wires that allow the transfer of data between components in a
computer system
○ Data bus: bidirectional bus that carries data instructions between
processor, memory, and I/O devices.
○ Address bus: unidirectional bus that carries the address of the main
memory location or input/output device about to be used, from processor
to memory address register (MAR)
● Control bus
○ Bidirectional
○ used to transmit control signals from the control unit to ensure access/use
of data & address buses by components of the system does not lead to
conflict
Performance of Computer System Factors
● Clock Speed
○ Number of pulses the clock sends out in a given time interval, which
determines the number of cycles (processes) the CPU executes in a given
time interval
○ Usually measured in Gigahertz (GHz)
○ If the clock speed is increased, then the execution time for instructions
decreases. Hence, more cycles per unit time, which increases
performance.
○ However, there is a limit on clock speed since the heat generated by
higher clock speeds cannot be removed fast enough, which leads to
overheating.
● Bus Width
○ Determines the number of bits that can be simultaneously transferred
○ Refers to the number of lines in a bus
○ Increasing bus width increases the number of bits transferred
simultaneously, increasing processing speed and performance.
● Cache Memory
○ Commonly used instructions are stored in the cache memory area of the
CPU.
○ If the cache memory size is increased, more commonly executed
instructions can be stored, and the need for the CPU to wait for
instructions to be loaded reduces. Hence, the CPU executes more cycles
per unit of time, thus improving performance.
● Number of Cores
○ Most CPU chips are multi-core — have more than one core (essentially a
processor)
○ Each core simultaneously processes different instructions through
multithreading, improving computer performance.
Ports

● Hardware which provides a physical interface between a device with CPU and a
peripheral device
● Peripheral (I/O) devices cannot be directly connected to the CPU, hence
connected through ports.
● Universal Serial Bus (USB): Can connect both input and output devices to the
processor through a USB port.
● High Definition Multimedia Interface (HDMI)
○ Can only connect output devices (e.g. LCD) to the processor through a
HDMI port
○ HDMI cables transmit high-bandwidth and high-resolution video & audio
streams through HDMI ports
● Video Graphics Array (VGA)
○ Can only connect output devices (e.g. second monitor/display) to the
processor through a VGA port
○ VGA ports allow only the transmission of video streams but not audio
components
Fetch-Execute (F-E) cycle

● Fetch stage
○ PC holds the address of the next instruction to be fetched
○ The address on the PC is copied to MAR
○ PC is incremented
○ Instruction loaded to MDR from the address held in MAR
○ Instruction from MDR loaded to CIR
● Decode stage: The opcode and operand parts of instruction are identified
● Execute stage: Instructions executed by the control unit sending control signals
● Register Transfer Notation (RTN)
○ MAR ← [PC]
○ PC ← [PC] + 1
○ MDR ← [[MAR]]
○ CIR ← [MDR]
○ Decode
○ Execute
○ Return to start
○ Square brackets: value currently in that register
○ Double square brackets: CPU is getting value stored at the address in the
register
Interrupts

● A signal from a program seeking the processor’s attention


○ Handles the interrupt by controlling the processor
○ Different ISRs used for different sources of interrupt
● A typical sequence of actions when an interrupt occurs:
○ The processor checks the interrupt register for interrupt at the end of the
F-E cycle for the current instruction
○ If the interrupt flag is set in the interrupt register, the interrupt source is
detected
○ If the interrupt is low priority, then an interrupt is disabled
○ If interrupting is a high priority:
■ All contents of registers of the running process are saved on the
stack
■ PC is loaded with the ISR and is executed
■ Once ISR is completed, the processor pops the registers’ contents
from the stack, and the interrupted program continues its execution.
■ Interrupts re-enabled and
■ Return to the start of the cycle

Assembly Language
● Assembly language: low-level programming language with instructions made up
of an op code and an operand
● Machine code: code written in binary that uses the processor’s basic machine
operations
● Relationship between machine and assembly language: every assembly
language instruction (source code) translates into exactly one machine code
instruction (object code)
● Symbolic addressing
○ Symbols used to represent operation codes
○ Labels can be used for addresses
● Absolute addressing: a fixed address in memory
● Assembler
○ Software that changes assembly language into machine code for the
processor to understand
○ The assembler replaces all mnemonics and labels with their respective
binary values (that are predefined before by the assembler software)
● One pass assembler
○ Assembler converts mnemonic source code into machine code in one
sweep of program
○ Cannot handle code that involves forward referencing
● Two pass assembler: software makes 2 passes thru code
○ On the first pass:
■ Symbol table created to enter symbolic addresses and labels into
specific addresses
■ All errors are suppressed
○ On the second pass:
■ Jump instructions access memory addresses via table
■ Whole source code translates into machine code
○ Error reported if they exist
● Grouping the Processor’s Instruction Set

Op Code Operan Explanation


d

Addressing

LDM #n Immediate: Load n into ACC

LDD Direct: load contents at address into the ACC

LDI Indirect: load contents of address at given address


into ACC

LDX Indexed: load contents of given address + IR into


ACC

Data Movement
STO Store contents of ACC into address

Arithmetic
Operations

ADD Add contents of register to ACC

INC Add 1 to contents of the register

Comparing

CMP Compare contents of ACC with that of given address

CMP #n Compare contents of ACC with n

Conditional Jumps

JPE Jump to address if compare TRUE

JPN Jump to address if compare FALSE

Unconditional
Jumps
JMP Jump to given address

I/O Data

IN Input any character and store ASCII value in ACC

OUT Output character whose ASCII value is stored in ACC

Ending

END Return Control to operating system

#denotes immediate addressing

B denotes a binary number, e.g. B01001010 & denotes a hexadecimal number, e.g.

&4A

● Modes of Addressing
○ Direct Addressing: loads contents at address into ACC
○ Indirect Addressing: The address to be used is at given address. Load
contents of this second address to ACC
○ Indexed addressing: form the address to be used as + the contents of the
IR (Index Register)
○ Relative addressing: next instruction to be carried out is an offset number
of locations away, relative to address of current instruction held in PC;
allows for relocatable code
○ Conditional jump: has a condition that will be checked (like using an IF
statements)
○ Unconditional jump: no condition to be followed, simply jump to the next
instruction as specified
Bit Manipulation
● Binary numbers can be multiplied or divided by shifting
● Left shift (LSL #n)
○ Bits are shifted to the left to multiply
○ E.g. to multiply by four, all digits shift two places to left
● Right shift (LSR #n)
○ Bits are shifted to the right to divide
○ E.g. to divide by four, all digits shift two places to right
● Logical shift: zeros replace the vacated bit position
● Arithmetic shift: Used to carry out multiplication and division of signed integers
represented by bits in the accumulator by ensuring that the sign-bit (usually the
MSB) is the same after the shift.
● Cyclic shift: the bit that is removed from one end by the shift is added to the other
end.
Bit Masking

● Each bit can represent an individual flag.


● ∴ by altering the bits, flags could be operated upon.
● Bit manipulation operations:
○ Masking: an operation that defines which bits you want to keep and which
bits you want to clear.
○ Masking to 1: The OR operation is used with a 1.
○ Masking to 0: The AND operation is used with a 0.
○ Matching: an operation that allows the accumulator to compare the value it
contains to the given value in order to change the state of the status
register.
● Practical applications of Bit Masking:
○ Setting an individual bit position:
■ Mask the content of the register with a mask pattern which has 0 in
the ‘mask out’ positions and 1 in the ‘retain’ positions.
■ Set the result with the match pattern by using the AND command
with a direct address.
○ Testing one or more bits:
■ Mask the content of the register with a mask pattern which has 0 in
the ‘mask out’ positions and 1 in the ‘retain’ positions.
■ Compare the result with the match pattern by using the CMP
command or by “Checking the pattern”.
○ Checking the pattern
■ Use AND operation to mask bits and obtain resultant.
■ Now subtract matching bit pattern from resultant. The final
‘non-zero’ result confirms the patterns are not the same else vice
versa.
Software
Operating System
● Need for OS
○ A set of programs designed to run in the background on a computer
system which
■ Controls operation of computer system
■ Provides a user interface
■ Controls how computer responds to user’s requests
■ Controls how hardware communicate
■ Provides an environment in which application software can be
executed
○ OS hardware is unusable without an OS, as the OS acts as an interface
since it controls communication between user and hardware
Key Management Tasks

● (Main) Memory Management


○ Memory protection to ensure 2 programs do not try to use same memory
space
○ Paging
○ Use of virtual memory
● File Management
○ Provides file naming conventions
○ Maintains a directory structure
○ Allocates space to particular files
● Security Management
○ Proves usernames & passwords
○ Ensures data privacy
○ Prevents unauthorized access
○ Carries out automatic backup
● Hardware (input/output/peripherals) Management
○ Installation of appropriate driver software
○ Controls access to data sent to and from peripherals
○ Receives & handles interrupts from hardware devices
● Process Management
○ Enables multiprogramming and multitasking
○ Resolution of conflicts when 2 or more processes requires the same
resource
○ E.g. via Round-robin method
Utility Software

● Disk Formatter
○ Prepares a hard disk to allow data to be stored on it
○ Deletes any existing data on disk
○ Performs formatting, process where computer ‘draws lines’ on disk
surface to split it into small areas
● Virus checker
○ Checks for and then removes any viruses found
○ Constantly checks all incoming and outgoing files
● Defragmentation Software
○ Files can be big so have to be stored in multiple sectors, which can result
in fragmentation (contents of file scattered across >2 non-contiguous
sectors)
○ Fragmentation slows down disk access and thus the performance of the
entire computer.
○ Defragmenting software works by physically reorganizing disk contents
(files) such that they are stored in contiguous sectors.
○ This defragmentation reduces number of movements of the read/write
heads require to access the disk contents, hence increasing computer
performance
○ The defragmentation also creates larger contiguous free space regions
● Disk contents analysis/disk repair software
○ Software utility for visualization of disk space usage
○ Gets size for each folder and files, and generates a graphical chart
showing disk usage distribution according to folders or other user defined
criteria.
○ Allows disk to report errors (e.g. “bad sector”)
○ Software will attempt to offer a solution
● File Compression
○ Reduces file size by removing redundant data in files
○ Causes improvements in the computer’s performance by reducing the
data that needs to be stored
● Back-up Software
○ Makes copy of files on another storage medium in the event of a hard
drive failure, user error, disaster or accident.
○ Should be a regular process
○ Can provide synchronization between devices
Program Libraries

● Pre-written code that can be linked to a software under development without any
amendments
● Can perform common or complex tasks
● Takes the form of classes
● Benefits:
○ Saves time: less code needs to be written
○ Smaller testing time: pre-tested and used by others
○ Library file is a complex algorithm which the user does not need to
understand to use it
● Dynamic Link Library (DLL) files
○ Shared library file that contains code and data
○ Code saved separately from the main .EXE file, reducing the .EXE file’s
size
○ Code only loaded to main memory when required
○ DDL file can be made available to several applications simultaneously,
thus reducing strain on memory
○ DLL files act as modules in more complex programs, making it easier to
install and run updates

Language Translators
● Assembler
○ Software that translates assembly language statements into machine code
(binary) for execution
○ The mnemonics used translates into machine opcodes
○ Process simple because assembly language has a one-to-one relationship
with machine code.
● Compiler and Interpreter

Compiler Interpreter

Translates a high-level language Translates and executes a high-level


program to machine code. language program, line-by-line.

Creates a .exe file which can be No .exe file created.


easily distributed.

Once compiled, .exe file does not Execution very slow – translated each time
need to be compiled again, resulting program run.
in faster execution.

Reports all errors at the end of Debugging easier/faster, since it stops


compilation: difficult to locate errors∴ translating when it reaches an error. This
development process long. allows real time error correction.

Only be produced when all errors are Can run program any time, even before code
fixed. finished.

Used when development is Used during development.


completed.

● Two-step translation
○ Java and some other high level language programs may require two-step
translation, i.e., they will be partially compiled and partially interpreted
○ Java code first translated to bytecode by Java compiler
○ Bytecode finally interpreted by the Java Virtual Machine to produce
machine code
● Integrated Development Environment (IDE) features
○ Coding
■ Context-sensitive prompts: Displays choice of keywords and
available identifiers appropriate at current insertion point and
provides choices in alphabetical order
■ Highlights undeclared/unassigned variable identifiers
○ Initial Error Detection
■ Dynamic syntax checks: Automatic checking and highlighting of
syntax errors, as soon as line typed
■ Type checking & parameter checking
○ Presentation
■ Prettyprint: Automatic indentation and color-coding of keywords
■ Expand and Collapse code blocks: Saves excessive scrolling if
collapsed, and easy to see global variable declarations and main
program body when collapsed
○ Debugging
■ Single stepping: Executes program line-by-line to see the effect of
each statement on variables
■ Breakpoints: Pauses program at a specific line to ensure program
operates correctly up to that line
■ Variables/expressions Report Window: Monitors variables for
comparing values.
, Privacy and Data
Integrity
Data Security
● Data Security: ensuring data is protected against loss and unauthorized access.
● Data Integrity: making sure that data is valid and does not corrupt after
transmission
● Data Privacy: ability to determine what data is shared with a third party
● Data Security and Computer System Security

Data Security System Security

Protection of data on a computer Protection of the computer system


system

To prevent corruption of data To prevent access of viruses to the system and


and prevent hackers from using prevent hackers from entering your computer
data system

E.g. encryption E.g. ID & Password

Threats to Computer & Data Security*

● Malware
○ software intentionally designed to damage a computer or computer
network
○ Includes Virus & Spyware
○ Virus: Software that replicates itself by inserting a copy of itself into
another piece of software, which may cause the computer to crash and
can lead to deletion or corruption of data
○ Spyware: software that gathers information about users' online and offline
activity, including accessed sites, applications, and downloaded files.
○ Risk restriction: Ensure anti-virus and anti-spyware software is installed,
regularly updated and run.
● Hacking
○ illegal access to a computer system
○ Hackers can obtain user’s confidential data which can cause identity theft
○ Can lead to the deletion or corruption of data
○ Risk restriction: Use strong passwords and ensure firewall
● Phishing
○ Attempt through emails to obtain user’s confidential data which can cause
identity theft
○ Risk restriction: Ignore suspicious mails and ensure firewall criteria include
SPAM filters, blacklist, etc.
● Pharming
○ Redirects user to a fake website that appears legitimate to gain
confidential data
○ Risk restriction: use a reliable ISP; check that links are genuine and
ensure https is present in the URL
Computer System Security Measures

● User Accounts and Passwords


○ Usernames & passwords to deny access to unauthorized users
○ User-assigned privilege, which accesses to only the user’s workplace,
preventing the user to have admin rights.
○ Can assign privileges to files so users with low privileges do not have
access.
● Firewalls
○ Hardware or software that filters information travelling between the
computer system and the internet
○ (software) firewall can make decisions about what to allow and block by
detecting illegal attempts by specific software to connect to the internet
● Authentication
○ Process of determining whether someone is who they claim to be.
○ Helps prevent unauthorized access
○ Log-on using digital signatures, passwords and biometric scans.
● Anti-virus software
○ Runs in the background to detect & remove viruses.
○ Checks files for known malicious patterns
● Anti-spyware software: detects & removes spyware.
● Encryption:
○ Conversion of data to code by encoding it
○ It doesn’t stop illegal access but appears meaningless
○ Necessary to use decryption software to decode data
● Data Security Measures
○ Encryption
○ Access Rights to data (authorization): different users assigned different
authorization levels which prevent them from accessing all data ∴
increases security
● Data Backup
○ An exact copy of an original piece of data in case the original is lost or
corrupted
○ Within the same computer system or at different site
● Disk-mirroring strategy
○ Real-time strategy that writes data to two or more disks at the same time.
○ If one fails, the other is still there to be read off of

Data Integrity
● Data validation and data verification help protect the integrity of data by checking
whether the data entered is sensible and accurate, respectively.
● Data Validation: checks if data entered is valid, but not its accuracy
● Data Validation Methods
○ Range check: data must be between a set of values
○ Format check: data must follow correct pattern/order
○ Length check: data must have exact no. of characters
○ Presence check: checks if some data has been entered
○ Existence check: data entered must exist
○ Limit check: checks whether a value entered is within acceptable minimum
and maximum values.
○ Check digit: A digit is used as the answer to an arithmetic operation of
other digits in data. If not matched, then data entered incorrectly
● Data Verification: checks data entered is accurate during data entry and data
transfer
● Data Entry Verification Methods
○ Visual Check: Person manually compares original data with that entered to
check if correct
○ Double Entry: Enter data into computer twice and compares.
○ If differences found, go back to raw data to fix error
Data Transfer Verification Methods

● Errors may occur when data moved in system.


● Parity Check
○ All data transmitted as bits
○ Number of 1s in a byte must always be either an odd number or an even
number
○ Parity can be set either as even or odd
○ E.g. two communicating devices decide there will always be an odd
number of 1s. A byte is received that has even number of 1s so error
occurred and receiving device would ask for it to be sent again
○ Used also when data sent between parts of the CPU
○ Not foolproof: if 2 bits are transposed, data accepted
● Checksum Check
○ Data sent from one place to another as block of bytes rather than
individual bytes
○ Computer adds together all bytes being sent
○ Any bits lost at most-significant end as carry ignored so answer is an 8-bit
number
○ Checksum calculated before and after data sent
○ If two bytes different, error occurred therefore block of bytes must be sent
again
Ethics and Ownership
● Ethics: a system of moral principles that guide behaviour based on philosophical
views
● Computer Ethics
○ Regulate how computing professionals should make decisions regarding
professional & social conduct.
○ A computing professional can be ethically guided by joining a professional,
ethical body such as the BCS and IEEE, which have codes of conduct.
● Ownership
○ Data ownership: having legal rights and complete control over a single
piece or set of data elements.
○ Copyright gives the creators of some types of media rights to control how
they're used and distributed.
○ Competitors can steal programming ideas and methods; software can
easily be copied and bootlegged (sold illegally); hence, legislation is
needed to protect the ownership, usage, and copyright of data.
Software Licencing
● Free Software Foundation:
○ A license gives users freedom to run, copy, distribute, study, change, and
improve the software.
○ Condition: any redistributed version of software must be distributed with
original terms of free use, modification, and distribution (aka copyleft)
● The Open Source Initiative:
○ The source code of open-source software is readily available to users
under copyright; it does enable users to re-distribute the software.
○ The concept of an open-source program relies on the fact that users can
review source code to eliminate bugs in it
● Shareware:
○ Demonstration software that is distributed for free but for a specific
evaluation period only
○ Distributed on a trial basis and with an understanding that sometime later,
a user may be interested in paying for it
○ Used for marketing purposes
● Commercial: Requires payment before it can be used, but includes all program's
features, with no restrictions
Artifical intelligence (AI)
● Artificial Intelligence (AI): the ability of a computer to perform tasks in such a way
that is conventionally associated with human intelligence:
○ AI can learn from past mistakes
■ they adapt to stop the same problem from occurring again
■ they learn to predict what might happen & raise alert
○ AI can learn to work more efficiently
■ when an action slows the system down, it can prevent this from
happening again
■ when an action increases the speed of the system, it can repeat
this when necessary to improve efficiency
● AI Applications
○ Developing autonomous mechanical products
○ Machine learning through data sets
● AI Impacts
○ Social
■ Replacement of manual labour with automation could lead to
massive unemployment.
■ However, it could lead to increased leisure time.
○ Economic: Due to increased innovation and efficiency with automation
provided by AI, there’d be lower manufacturing costs in general
○ Environmental: Detrimental impact on the environment due to robot
manufacture with limited resources and its waste disposal
Database and
Data Modelling
File Based System
● Data stored in discrete files, stored on computer, and can be accessed, altered or
removed by the user
Disadvantages of File Based System:

● No enforcing control on organization/structure of files


● Data repeated in different files; manually change each
● Sorting must be done manually or must write a program
● Data may be in different format; difficult to find and use
● Impossible for it to be multi-user; chaotic
● Security not sophisticated; users can access everything

Database Management Systems


(DBMS)
● Database: collection of non-redundant interrelated data
● DBMS: Software programs that allow databases to be defined, constructed and
manipulated
Features of a DBMS:

● Data management: data stored in relational databases - tables stored in


secondary storage
● Data dictionary contains:
○ List of all files in database
○ No. of records in each file
○ Names & types of each field
● Data modeling: analysis of data objects used in database, identifying
relationships among them
● Logical schema: overall view of entire database, includes: entities, attributes
and relationships
● Data integrity: entire block copied to user’s area when being changed, saved
back when done
● Data security: handles password allocation and verification, backups database
automatically, controls what certain user’s view by access rights of individuals or
groups of users
Data change clash solutions:

● Open entire database in exclusive mode – impractical with several users


● Lock all records in the table being modified – one user changing a table, others
can only read table
● Lock record currently being edited – as someone changes something, others
can only read record
● User specifies no locks – software warns user of simultaneous change, resolve
manually
● Deadlock: 2 locks at the same time, DBMS must recognize, 1 user must abort
task
Tools in a DBMS:

● Developer interface: allows creating and manipulating database in SQL rather


than graphically
● Query processor: handles high-level queries. It parses, validates, optimizes,
and compiles or interprets a query which results in the query plan.

Relational Database Modelling


● Entity: object/event which can be distinctly identified
● Table: contains a group of related entities in rows and columns called an entity
set
● Tuple: a row or a record in a relational database
● Attribute: a field or column in a relational database
● Primary key: attribute or combination of them that uniquely define each tuple in
relation
● Candidate key: attribute that can potentially be a primary key
● Foreign key: attribute or combination of them that relates 2 different tables
● Referential integrity: prevents users or applications from entering inconsistent
data
● Secondary key: candidate keys not chosen as the primary key
● Indexing: creating a secondary key on an attribute to provide fast access when
searching on that attribute; indexing data must be updated when table data
changes

Relational Design of a System

Normalization
1st Normal Form (1NF): contains no repeating attribute or groups of attributes.

Intersection of each tuple and attribute contains only 1 value. Example:


2nd Normal Form (2NF): it is in 1NF and every non-primary key attribute is fully

dependent on the primary; all the incomplete dependencies have been removed.

Example:
3rd Normal Form (3NF): it is in 1NF and 2NF and all non-key elements are fully

dependent on the primary key. No inter-dependencies between attributes.

● MANY-TO-MANY functions cannot be directly normalized to 3NF, must use a 2


step process e.g.

becomes:
Data Definition Language (DDL)
● Creation/modification of the database structure using this language
○ written in SQL
● Creating a database:
CREATE DATABASE <database-name>

● Creating a table:
CREATE TABLE <table-name> (…)

● Changing a table:
ALTER TABLE <table-name>

● Adding a primary key:


PRIMARY KEY (field)
ADD <field-name>:<data-type>

● Adding a foreign key:


FOREIGN KEY (field) REFERENCES <table>(field)

● Example:
CREATE DATABASE ‘Personnel.gdb’
CREATE TABLE Training
(EmpID INT NOT NULL,
CourseTitle VARCHAR(30) NOT NULL,
CourseDate Date NOT NULL,
PRIMARY KEY (EmpID, CourseDate),
FOREIGN KEY (EmpID) REFERENCES Employee(EmpID))

Data Manipulation Language


(DML)
● Query and maintenance of data done using this language – written in SQL
Queries:

Creating a query:
SELECT <field-name>
FROM <table-name>
WHERE <search-condition>

● SQL Operators:

= Equals to

> Greater than

< Less than

>= Greater than or equal to

<= Less than or equal to

<> Not equal to

IS NULL Check for null values

● Sort into ascending order:


ORDER BY <field-name>

● Arrange identical data into groups:


GROUP BY <field-name>

● Joining together fields of different tables:


INNER JOIN
Data Maintenance:

● Adding data to table:


INSERT INTO <table-name>(field1, field2, field3)
VALUES (value1, value2, value3)

● Deleting a record:
DELETE FROM <table-name>
WHERE <condition>

● Updating a field in a table:


UPDATE <table-name>
SET <field-name> = <value>
WHERE <condition>
Algorithm Design
&
Problem-Solving
● Abstraction: filtering out and concentrating on the relevant information in a
problem; allowing a programmer to deal with complexity
● Decomposition: breaking down problems into sub-problems in order to
understand a process more clearly; program modules, procedures and functions
all help the programmer to break down large problems
● Algorithm: a solution to a problem expressed as a sequence of steps

Identifier Table
● Identifier: name given to a variable in order to call it
● An identifier table depicts information about the variable, e.g.

● Rules for naming identifiers:


○ Must be unique
○ Spaces must not be used
○ Must begin with a letter of the alphabet
○ Consist only of a mixture of letters and digits and the underscore character
‘_’
○ Must not be a ‘reserved’ word – e.g. Print, If, etc.

Basic Program Operations


● Assignment: an instruction in a program that places a value into a specified
variable
● Sequence: programming statements are executed consequently, as they appear
in the program
● Selection: control structure in which there is a test to decide if certain
instructions are executed
○ IF selection: testing 2 possible outcomes
○ CASE selection: testing more than 2 outcomes
● Repetition/Iteration: control structure in which a group of statements is
executed repeatedly
○ FOR loop: count-controlled; executed a set no. of times
○ WHILE loop: pre-conditional; executed based on condition at start of
statements
○ REPEAT loop: post-conditional; executed based on condition at end of
statements
As for selecting what loop to use, it is best to use FOR loops when you know the

number of iterations required, and a WHILE or REPEAT loop if you do not know the

number of iterations required.

● Iterate over an array: FOR Loop


● Reading a file into a variable: WHILE Loop
● Asking for user input: WHILE/REPEAT Loop
● A loop that should execute n times: FOR Loop

Stepwise Refinement
● Process of developing a modular design by splitting a problem into smaller
sub-tasks, which themselves are repeatedly split into even smaller sub-tasks until
each is just one element of the final program.

Program Modules
● This refers to a modular program design
● Subroutines: self-contained section of code, performing a specific task; part of
the main program
● Procedures: performs a specific task, no value returned to part of code where
called
● Functions: performs a specific task, returns a value to part of code where called

Logic Statements

Operator Meaning

< Less than

<= Less than/equal

> Greater than

>= Greater/equal

= Equal to

<> Not equal to


Data
Representation
Data Types
Integer:

● Positive or negative number; no fractional part


● Held in pure binary for processing and storage
● Some languages differentiate short/long integers (more bytes used to store long
integers)
Real:

● Number that contains a decimal point


● Referred to as singles and doubles depending upon the number of bytes used to
store
Character:

● A character is any letter, number, punctuation or space


● Takes up a single unit of storage (usually a byte).
String:

● Combination of alphanumeric characters enclosed in “ ”


● Each character is stored in one byte using ASCII code
● Each character is stored in two bytes using Unicode
● The maximum length of a string is limited by available memory.
● Incorrect to store dates or numbers as strings
● Phone no. must be stored as a string; otherwise, the initial 0 is lost
Boolean:

● It can store one of only two values; “True” or “False.”


● Stored in 1 byte: True = 11111111, False = 00000000
Date:

● Dates are stored as a ‘serial’ number


● Equates to the number of seconds elapsed since 1st January 1970 00:00:00
UTC, excluding leap seconds.
● Usually takes 8 bytes of storage
● Displayed as dd/mm/yyyy or mm/dd/yyyy
Array:

● Data structure consisting of a collection of elements


● Identified by at least one array index (or key)
File:

● An object that stores data, information, settings or commands


● Can be opened, saved, deleted & moved
● Transferrable across network connections

ASCII Code
● Uses 1 byte to store a character
● 7 bits available to store data and 8th bit is a check digit
● 27 = 128, therefore 128 different values
● ASCII values can take many forms: numbers, letters (capitals and lower case are
separate), punctuation, non-printing commands (enter, escape, F1)

Unicode
● ASCII allows few number of characters; it is good for English
● Unicode allows others, too: Chinese, Greek, Arabic, etc.
● Different types of Unicode:
○ UTF-8: compatible with ASCII, variable-width encoding can expand to 16,
24, 32, 40, 48
○ UTF-16: 16-bit, variable-width encoding can expand to 32 bits
○ UTF-32: 32-bit, fixed-width encoding, each character exactly 32 bits

Arrays
● 1-Dimensional (1D) Array: declared using a single index, can be represented as
a list

● 2-Dimensional (2D) Array: declared using two indices, can be represented as a


table

● Pseudocode:
○ 1-D Array: array = []
○ 2-D Array: array = [[], [], [], …]
● Python:
○ Declaring an array: names = []
○ Adding to an array: names.append(‘ZNotes’)
○ Length of array, i.e. number of elements: len(names)
○ Printing an element in a 1D array: print(names[element position])
○ Printing element in a 2D array: print (a[row][column])
○ Printing row in a 2D array: names[row] = [new row]
○ Printing column: Use it for loop, add 1 to the row, and keep the column the
same.

Bubble Sort

● A FOR loop is set to stop the sort


● Setting a variable ‘sorted’ to be ‘true’ at the beginning
● Another FOR loop is set up next in order to search through the array
● An IF is used to see if the first number of the array is greater than the second. If
true:
○ First number stored to variable
○ Second number assigned as first number
○ Stored variable assigned to second number
○ Set ‘sorted’ to ‘false’ causing loop to start again
● The second FOR loop is count based thus will stop after a specific number of
times
● Goes through bigger FOR loop
● ∴
● ∴ ‘sorted’ remains ‘true’
● This exits the loop
● ∴
● ∴ ending the program

Linear Search

● A FOR loop goes through the array


● It compares item in question to those in list using an IF:
○ If item matches with another then search is stopped
○ Also the location where it was found is returned
○ If not found it exits the FOR loop
● Then returns fact that item in question is not in the list

File Handling
● Files are needed to import contents (from a file) saved in secondary memory into
the program, or to save the output of a program (in a file) into secondary memory,
so that it is available for future use
Pseudocode:

● Opening a file: OPENFILE <filename> FOR READ/WRITE/APPEND


● Reading a file: READFILE <filename>, <variable>
● Writing a line of text to the file: WRITEFILE <filename>, <string>
● Closing a file: CLOSEFILE <filename>
● Testing for end of the file: EOF(filename)
Python:
● Opening a file: variable = open(“filename”, “mode”)
Where the mode can be:

Mod Description
e

r Opens file for reading only. Pointer placed at the beginning of the file.

w Opens a file for writing only. Overwrites file if file exists or creates new file if it
doesn’t

a Opens a file for appending. Pointer at end of file if it exists or creates a new
file if not

● Reading a file:
○ Read all characters: variable.read()
○ Read each line and store as list: variable.readlines()
● Writing to a file:
○ Write a fixed a sequence of characters to file: variable.write(“Text”)
○ Write a list of string to file: variable.write(‘ ‘.join(‘Z’, ‘Notes’))

Abstract Data
Types (ADT)
An Abstract Data Type (ADT) is a collection of data with associated operations. There

are three types of ADTs:

● Stack: an ordered collection of items where the addition of new items and
removal of existing items always takes place at the same end.
● Queue: a linear structure which follows the First In First Out (FIFO) mechanism.
Items are added at one end (called the rear) and removed from the other end
(called the front)
● Linked List: a linear collection of data elements whose order is not given by
physical placements in memory (non-contiguous). Each element points to the
next.

PROGRAMING
● Programming is a transferable skill
● Transferable skill: skills developed in one situation which can be transferred to
another situation.

Variables
● Declaring a variable:
○ Pseudocode: ‘’’DECLARE : ‘’’
○ Python: no need to declare however must write above as a comment
(‘’’python #...‘’’)
● Assigning variables:
‘’’python ← ‘’’ or ‘’’python ‘’’

‘’’python identifier = value‘’’ or ‘’’python expression‘’’ or ‘’’python “string”‘’’

Selections
● “IF” Statement
○ Pseudocode: IF…THEN…ELSE…ENDIF
○ Python: if (expression): (statements) else: (statements)
● “CASE” Statement
○ Pseudocode: CASE OF variable: … … … OTHERWISE: … ENDCASE
○ Python: if (expression): (statement) elif (expression): statement) … else: (statement)

Iterations

Count-controlled Loop

FOR <identifier> ← <val1> TO <val2> STEP


<val3>

<statement(s)>

ENDFOR

for x in range(value1, value2):

statement(s)

Post condition Loop

REPEAT Not possible in Python

<statement(s)> Use ‘’’python WHILE‘’’ and ‘’’python


IF‘’’
UNTIL <condition>

Pre-condition Loop
WHILE <condition> while expression:

<statement(s)> statement(s)

ENDWHILE

Built-in Functions
String/character manipulation:

● Uppercase or lowercase all characters: (“string”).upper() (“string”).lower()


● Finding length of a string: len(“string”)
● Converting:
○ String to Integer - int(“string”)
○ Integer to String - str(integer)
Random number generator: random.randint(a, b)

Where a and b defines the range

Benefits of Procedures and


Functions:
● Lines of code can be re-used; don’t have to be repeated
● Can be tested/improved independently of program
● Easy to share procedures/functions with other programs
● Create routines that can be called like built-in command

Procedure
Procedure: subroutine that performs a specific task without returning a value
● Procedure without parameters:

PROCEDURE <statement(s)>ENDPROCEDURE def identifier():statement(s)

● When a procedure has a parameter, the function can either pass it by either
reference or value
● Pass by value: data copied into procedure so variable not changed outside
procedure
PROCEDURE <identifier> (BYVALUE <param>: <datatype>)

<statement(s)>

ENDPROCEDURE

def identifier(param):

statement(s)

● Pass by reference: link to variable provided so variable changed after going


through procedure (not in Python)
PROCEDURE <identifier> (BYREF <param>: <datatype>)

<statement(s)>

ENDPROCEDURE

● Calling a procedure:

CALL () Identifier()

Function
Function: subroutine that performs a specific task and returns a value

Functions are best used to avoid having repeating blocks of code in a program, as well

as increasing the reusability of code in a large program.


FUNCTION <identifier> (<parameter>: <data type>) RETURNS <datatype>

<statement(s)>

ENDFUNCTION

def identifier(param):

statement(s)

return expressioN
Development
Program Development Cycle
● Analyze problem: define problem, record program
specifications and recognize inputs, process, output & UI
● Design program: develop logic plan, write algorithm in e.g.
pseudocode or flowchart and test solution
● Code program: translate algorithm into high level language
with comments/remarks and produce user interface with
executable processes
● Test and debug program: test program using test data, find
and correct any errors and ensure results are correct
● Formalize solution: review program code, revise internal
documentation and create end-user documentation
● Maintain program: provide education and support to
end-user, correct any bugs and modify if user requests
There are three different development life cycles:

● Waterfall model: a classical model, used to create a system


with a linear approach, from one stage to another
● Iterative model: a initial representation starts with a
small subset, which becomes more complex over time until
the system is complete
● Rapid Application Development (RAD) model: a prototyping
model, with no (or less) specific planning put into it.
More emphasis on development and producing a
product-prototype.

Integrated Development
Environment
● A software application that allows the creation of a
program e.g. Python
● Consists of a source code editor, build automation tools, a
debugger
Coding:

● Reserved words are used by it as command prompts


● Listed in the end-user documentation of IDE
● A series of files consisting of preprogrammed-subroutines
may also be provided by the IDE
Initial Error Detection:

● The IDE executes the code & initial error detection carried
out by compiler/interpreter doing the following:
○ Syntax/Logic Error: before program is run, an error
message warns the user about this
○ Runtime Error: run of the program ends in an error
Debugging:

● Single stepping: traces through each line of code and steps


into procedures. Allows you to view the effect of each
statement on variables
● Breakpoints: set within code; program stops temporarily to
check that it is operating correctly up to that point
● Variable dumps (report window): at specific parts of
program, variable values shown for comparison

Structure Charts
● Purpose: used in structured programming to arrange program
modules, each module represented by a box
● Tree structure visualizes relationships between modules,
showing data transfer between modules using arrows.
● Example of a top-down design where a problem (program) is
broken into its components.
Rules:
● Process: Represents a programming module e.g. a calculation

● Data couple: Data being passed from module to module that


needs to be processed

● Flag: Check data sent to start or stop a process. E.g.


check if data sent in the correct format

● Selection: Condition will be checked and depending on the


result, different modules will be executed

● Iteration: Implies that module is executed multiple times

Example:
Types of Errors
Syntax errors:

● When source code does not obey rules of the language


● Compiler generates error messages
● Examples:
○ Misspell identifier when calling it
○ Missing punctuation – colon after if
○ Incorrectly using a built-in function
○ Argument being made does not match data type
Run-time errors:

● Source code compiles to machine code but fails upon


execution (red lines show up in Python)
● When the program keeps running and you have to kill it
manually
● Examples:
○ Division by 0
○ Infinite loop – will not produce error message,
program will just not stop until forced to
Logic errors:

● Program works but gives incorrect output


● Examples:
○ Out By One – when ‘>’ is used instead of ‘>=’
○ Misuse of logic operators

Corrective Maintenance
● Corrective Maintenance is correcting identified errors
● White-Box testing: making sample data and running it
through a trace table
● Trace table: technique used to test algorithms; make sure
that no logical errors occur e.g.
Adaptive Maintenance
● Making amendments to:
○ Parameters: due to changes in specification
○ Logic: to enhance functionality or more faster or both
○ Design: to make it more user friendly

Testing Strategies
Black box testing:

● Use test data for which results already calculated &


compare result from program with expected results
● Testing only considers input and output and the code is
viewed as being in a ‘black box’
White box testing:

● Examine each line of code for correct logic and accuracy.


● May record value of variables after each line of code
● Every possible condition must be tested
Stub testing:

● Stubs are computer programs that act as temporary


replacement for a called module and give the same output as
the actual product or software.
● Important when code is not completed however must be tested
so modules are replaced by stubs
Dry run testing:

● A process where code is manually traced, without any


software used
● The value of a variable is manually followed to check
whether it is used and updated as expected
● Used to identify logic errors, but not execution errors
Walkthrough testing:
● A test where the code is reviewed carefully by the
developer’s peers, managers, team members, etc.
● It is used to gather useful feedback to further develop the
code.
Integration testing:

● Taking modules that have been tested on individually and


testing on them combined together
● This method allows all the code snippets to integrate with
each other, making the program work.
Alpha testing:

● This is the testing done on software ‘in-house’, meaning it


is done by the developers
● Basically another term for ‘first round of testing’
Beta testing:

● This is the testing done on the software by beta users, who


use the program and report any problems back to the
developer.
● Basically another term for ‘second round of testing’
Acceptance testing:

● A test carried out by the intended users of the system: the


people who requested the software.
● The purpose is to check that the software performs exactly
as required.
● The acceptance criteria should completely be satisfied for
the program to be released.

You might also like