Exchanging data Flashcards
Why is compression important for sharing files?
Compression is the process of reducing the amount of storage required by a file.
The bigger the file = the more time it takes to get transferred
So compressing files increases the number of files that you can transfer in a given time
Downloading the full version of a file is faster than downloading the compressed file over the internet
TRUE OR FALSE
FALSE
Downloading the compressed file over the Internet is faster than downloading the full version of a file
Give categories of compression
Lossy and Lossless
Lossy compression
Reduces file size while REMOVING SOME INFORMATION
So compressed image is more pixelated/sound is less clearer
Compressed file cant be turned back into original
Lossless compression
Reduces file size WITHOUT REMOVING INFORMATION
So compressed file can be turned back to the original without loss of quality
How would you compress audio files? Which compression category would you use?
Using LOSSY
Removing very high or very low frequences which are less noticeable to the ear
However, there is no way to go back to the original as there is no record of these high or low frequences and how high and low they were
Run Length Encoding is a type of….
Lossless compression
Run Length Encoding
LOSSLESS COMPRESSION
Repeated values are rempved and replaced with one occurence of the data followed by the number of times its repeated
When would Run Length Encoding not be suitable?
When there is not much redundant data so it wouldnt offer a large reduction in file size
What is Dictionary encoding?
LOSSLESS COMPRESSION
Frequently occuring pieces of data are replaced with an index
Compressed data is stored alongside a dictionary which matches the frequently occuring data to an index
Dictionary encoding is an example of….
Lossless compression
Give a disadvantage of Dictionary encoding
The compressed data has to be stored alongside the dictionary which will increase the file size of the compressed data.
Without the dictionary the original data cant be restored.
What is meant by encryption?
The process of scrambling data do that it can only be understood by the sender and intended recipient
What is symmetric encryption?
Both the sender and receiver share the same private key
So SAME KEY IS USED FOR ENCRYPTING AND DECRYPTING DATA
This private key is distributed in a process called key exchange
In Symmetric encryption both the sender and receiver share the same private key
This private key is distributed in a process called…
Key exchange
What is Asymmetric encryption?
2 keys are used
The 2 public keys can be published anywhere but the 2 private keys are to be kept secret
Message is encrypted with senders private key and recipients public key and decrypted using receivers private key and senders public key
Explain the process of hashing (simple)
An input called a key is turned into a fixed size value called a hash using a hashing function (algorithm)
The output of a hash function can be reversed to form the key
TRUE OR FALSE
FALSE
The output of a hash function CAN’T be reversed to form the key
The output of a hash function CAN’T be reversed to form the key
What would this fact make hashing useful for?
Storing passwords:
1.Instead of storing the password directly, the system generates a hash of the password using a hashing algorithm
2.The system stores the hash in the database, not the password itself.
3.When a user enters their password, the system hashes the input and compares it to the stored hash. If they match, the password is correct.
A hacker would only get accessed to the hashes which can’t be reversed to gain passwords (keys)
What would be the time complexity for looking up data in an array?
O(1) Constant
What is meant by a collision in hash tables?
Give methods to deal with these?
When 2 pieces of data produce the same hash
-Making a new/bigger hash table
-Storing items with same hash in a list under same hash value
-Use a second hash function to generate a new hash
A good hash function should…..
-Have a low chance of collisions
-Produces a fixed length output regardless of input size
What is a hash table?
A data structure which holds key-value pairs
A relational database is a database that….
database that recognises the differences between entities by creating different tables for each entity
What is an attribute in databases?
A characteristic of an entity
What is meant by a primary key?
A unique identifier for each record in the table
(shown by underlining)
What is meant by a foreign key?
An attribute which links two tables together
-It will be the primary key in a table and then the foreign in another
(denoted using asterisk *)
What is meant by a secondary key?
A key which allows a database to be searched quicker
eg. patientID is primary key but a patient may not know this. So a secondary key could be their surname
-So you can search and order by surname to find specific patients
Give examples of entity relationship modelling
ONE TO ONE
ONE TO MANY
MANY TO MANY
ONE TO ONE
MANY TO ONE
MANY TO MANY
Are examples of entity relationship modelling?
FALSE
ONE TO ONE
ONE TO MANY (NOT MANY TO ONE)
MANY TO MANY
MANY TO ONE DOESNT EXIST
What does database normalisation try to accomplish?
-No redundancy (unnecessary duplicates)
-Complex queries can be carried out
-Records can be added and removed without issues
-Consistent data throughout linked tables
What happens in first normal form?
No attribute contains more than a single value
(No repeated attributes)
(all fields should be atomic)
What happens in second normal form?
No partial dependencies meaning that no attributes can depend on part of a composite key
What happens in third normal form?
Nonkey dependencies which means the attribute only depends on the value of the primary key and nothing else
What is meant by indexing in databases?
A method used to store the position of each record ordered by a certain attribute (called secondary key).(eg.surname instead of patientID)
Even though the primary key is automatically indexed it is almost never used as its hard to remember
-So we use secondary keys instead
How would you capture the data when people pay cheques?
Pay cheque = ordering bank to get money from your account and give it to the person that is on the cheque.
Person writes details down.
Bank scans cheque and prints it in magnetic ink which allows the use of MICR Magnetic Ink Character Recognition so details can be recognised by a computer
How would you capture data from multiple choice questions?
Using Optical Mark Recognition (OMR)
Exchanging data
The process of transferring collected data.
Can use Electronic Data Interchange (EDI) which doesnt require human interaction and enables data transfer from one computer to another
eg. automated exchange of invoices between businesses,
automatically exchange purchase orders between buyers and suppliers. Instead of a person manually creating an order and sending it by email
Structured query language (SQL) is an example of a…
Declarative language used to manipulate databases
SQL SELECT statement structure
SELECT attribute
FROM table
WHERE conditions
ORDER BY
ASC = ascending
DESC= descending
If you say:
ORDER BY DatePublished
it wil automatically order in ascending
Also can do:
ORDER BY DatePublished ASC
so ORDER BY DatePublished ASC = ORDER BY DatePublished
JOIN in databases
Returns records from multiple tables based on a common field between them
What is the difference between VARCHAR and CHAR in databases?
VARCHAR(n) is a string of variable length with upper limit n (max length is n)
CHAR(n) is a string of fixed length n
ALTER in databases
Used to add, delete or modify the columns/ ATTRIBUTES in a table
E.g
ADDING ATTRIBUTE:
ALTER TABLE Students
ADD Birthday DATE
DELETING ATTRIBUTE:
ALTER TABLE STUDENT
DROP COLUMN Birthday
MODIFYING DATA TYPE
ALTER TABLE STUDENT
MODIFY COLUMN Birthday INTEGER
Using ALTER write an SQL query deleting the Birthday attribute from the students table
ALTER TABLE STUDENT
DROP COLUMN Birthday
Using ALTER write an SQL query modifying the Birthday attribute from the students table so that its data type is integer
ALTER TABLE STUDENT
MODIFY COLUMN Birthday INTEGER
Using ALTER write an SQL query adding the Birthday attribute to the students table
ADDING ATTRIBUTE:
ALTER TABLE Students
ADD Birthday DATE
INSERT SQL query format
INSERT INTO Students (birthday, surname)
VALUES (11/02/2004, “Smith”)
Updating a record in a database table format
E.G In the students table change the birthday from 11/02/2004 to 11/04/2004 for the student with surname Smith
UPDATE Students
SET Birthday= 11/04/2004
WHERE Surname = “Smith”
What is meant by referential integrity?
A process which ensures consistency.
Ensures that info is not removed if it is required elsewhere in a linked table
-This means that when 2 databases are linked one cant be deleted as the other needs its contents
(e.g pet and owner) without an owner the animal isnt a pet the pet needs its owner
What is meant by transaction?
A single operation being executed on data
-Sometimes a collection of operations can also be called a transaction
WHAT IS THIS?
A process which ensures consistency.
Ensures that info is not removed if it is required elsewhere in a linked table
-This means that when 2 databases are linked one cant be deleted as the other needs its contents
(e.g pet and owner) without an owner the animal isnt a pet the pet needs its owner
Referential integrity
Explain the term deadlock
A situation in which two or more transactions are waiting for one another to give up locks.
eg user1 (transaction) finishes with record1 and user2(transaction) finishes with record2 but now user1 wants record2 and user2 wants record1
Explain ACID in transactions
ACID = ATOMICITY, CONSISTENCY, ISOLATION, DURABILITY
Atomicity= A transaction must be processed in its entirety or not at all (fully or then no)
Consistency= A transaction must maintain the referential integrity rules between linked tables (one table cant be deleted as the other table requires its contents)
Isolation= Simultaneous transactions should lead to the same result as if they were carried out one after the other
At the same time=one after the other
Durability=When a transaction has been executed it will remain just in case (e.g in the event of a power cut)
TRANSACTIONS
Explain what the A in ACID stands for
ATOMICITY
A transaction must be processed in its entirety or not at all (fully or then no)
TRANSACTIONS
Explain what the C in ACID stands for
CONSISTENCY
A transaction must maintain the referential integrity rules between linked tables (one table cant be deleted as the other table requires its contents)