1.3.2: Databases Flashcards
What is a Relational Database?
- A database that recognises the differences between entities by creating different tables for each identity
What is an Entity?
- An item of interest about which information is stored
- (A category of object, person, an event)
What is a Flat File?
- A database consisting of a single file
What will a Flat File be based around?
- Most likely be based around a single entity and its attributes
- Are typically written out as: Entity1(Attribute1, Attribute2, Attribute3…) E.g. Car(CarID, Age, Price)
What is the Primary Key?
- The unique identifier for each record in the table
- What is different for each row of the table
- The Primary Key is always underlined in a table
What does the Secondary Key allow for?
- The database to be searched quickly
What is a Foreign Key?
- A key existing as the Primary Key in one table but having travelled to another table is no longer the Primary Key
- Foreign Keys are shown using an asterisk in the table
What is a One-To-One relationship?
- Each entity can only be linked to one other entity
- [A single line used to connect two entities]
What is a One-To-Many relationship?
- One table can be associated with many other tables
- [A single line on one side, with a branch on the other]
What is a Many-To-Many relationship?
- One entity can be associated with many other entities and vice versa
- [Branches on both sides]
What is Normalisation?
- The process of coming up with the best possible layout for a relational database
What does Normalisation attempt to accomplish?
- No redundancy (Unnecessary duplicates)
- Consistent data throughout linked tables
- Records can be added and removed without issues
- Complex queries can be carried out
What is the criteria for First Normal Form?
- There must be no attribute containing more than a single value
- Field names unique
- Field values from same domain
- Values in fields atomic
- Records can’t be identical
- Must have a primary key
What is the criteria for Second Normal Form?
- A database that doesn’t have any partial dependencies and is in First Normal Form (No attributes can depend on part of a composite key)
What is the criteria for Third Normal Form?
- The database is in Second Normal Form and contains no non-key dependencies (The attribute only depends on the value of the Primary Key and nothing else)
What is Indexing?
- A method used to store the position of each record ordered by a certain attribute
What is Indexing used for?
- Looking up and accessing data quickly
Why is the Primary Key almost never queried?
- The Primary Key is automatically indexed
- It is not usually remembered therefore almost never queried
Why are Secondary Keys used for Indexing?
- To make the table easier and faster to search through
How is data Captured?
- Data needs to be input into the database, the chosen method is always dependent on the context
What is Magnetic Ink Character Recognition used for?
- To scan bank cheques: All the details excluding the amount are printed
What is Optical Mark Recognition used for?
- Multiple choice questions on a test
What is Optical Character Recognition used for?
- Other data capturing forms
What is Selecting data?
- An important part of data preprocessing
- Could involve only selecting data that fits a certain criteria to reduce the volume on input
How can collected data be Managed?
- Using SQL to sort, restructure, and select certain sections
What is Exchanging data?
- The process of transferring the collected data, commonly through Electronic Data Interchange
What are the advantages of Electronic Data Interchange?
- Doesn’t require human interaction and enables data transfer from one computer to another
What is Structured Query Language?
- A Declarative Language (From the Declarative Programming Paradigm) used to manipulate databases
What does Structured Query Language enable?
- The creating, removing, and updating of databases
What does SELECT mean SQL?
- To collect fields from a given table
What does FROM mean SQL?
- To specify from which table(s) the information will come from
What does WHERE mean SQL?
- To specify search criteria
What does ORDER BY mean SQL?
- Specifies whether the values should in ascending or descending order
- Values are automatically placed in ascending order: adding ‘Desc’ will cause the values to be displayed in descending order
What does JOIN mean SQL?
- Provides a method of combining rows from multiple tables based on a common field between them
What does CREATE mean SQL?
- Allows for the creation of new databases
What is the data type CHAR(n)?
- Character string of fixed length
- E.g. ProductCode CHAR(6)
What about each attribute needs to be specified?
- Whether it is a Primary Key
- The data type of the attribute
- Whether it must be filled in (‘NOT NULL’)
What is the data type VARCHAR(n)?
- Character string variable length, max. n
- E.g. Surname VARCHAR(25)
What is the data type BOOLEAN?
- TRUE or FALSe
- E.g. ReviewComplete BOOLEAN
What is the data type INTEGER, INT?
- Integer
- E.g. Quantity INTEGER
What is the data type FLOAT?
- Number with a floating decimal point
- E.g. Length FLOAT (10,2)
- [Maximum number of digits is 10 and maximum number after decimal point is 2]
What is the data type DATE?
- Stores Day/Month/Year values
- E.g. HireDate DATE
What is the data type TIME?
- Stores Hour/Minute/Second values
- E.g. RaceTime TIME
What is the data type CURRENCY?
- Formats numbers in the currency used in the region
- E.g. EntryFee #23.50
What does ALTER mean SQL?
- Add, delete, or modify columns in a table
How do you add a column (field) in SQL?
ALTER TABLE Employee
ADD Department VARCHAR(10)
How do you delete a column in SQL?
ALTER TABLE Employee
DROP COLUMN HireDate
How do you change the data type of a column in SQL?
ALTER TABLE Employee
MODIFY COLUMN EmpName VARCHAR(30) NOT NULL
When do you use INSERT INTO in SQL?
- To inert a new record into a database table
How do you use INSERT INTO in SQL?
INSERT INTO (column1, column2)
VALUES (value1, value2)
When do you use UPDATE in SQL?
- To update a record in a database table
How do you use UPDATE in SQL?
UPDATE TableName
SET column1 = value1, column2 = value2
WHERE columnX = value
When do you use DELETE in SQL?
- To delete a record from a database table
How do you use DELETE in SQL?
DELETE FROM TableName
WHERE columnX = value
What is a Transaction?
- A single operation executed on data
- Sometimes a collection of operations can be considered a transaction
What is Referential Integrity?
- The process of ensuring consistency (Ensuring that information is not removed if it is required elsewhere in a linked database)
What does the ‘A’ in ‘ACID’ stand for?
- Atomicity
What does ‘Atomicity’ in ‘ACID’ mean?
- Requires that the transaction must be processed in its entirety or not at all
What must ‘Atomicity’ in ‘ACID’ guarantee?
- That in any situation, including power cuts or hard disk crashes, it is not possible to process only part of the transactions
What does the ‘C’ in ‘ACID’ stand for?
- Consistency
What does ‘Consistency’ in ‘ACID’ mean?
- Ensuring that no transaction can violate any of the defined validation rules for maintaining the integrity of the database
- When a database is created, Referential Integrity rules will be specified between tables
- It would not be possible to record a mark in a RESULTS table for a student who is not in the STUDENT table in the database
What does the ‘I’ in ‘ACID’ stand for?
- Isolation
What does ‘Isolation’ in ‘ACID’ mean?
- Ensuring that simultaneous execution of transaction leads to the same results as if transactions were processed one after the other
What does the ‘D’ in ‘ACID’ stand for?
- Durability
What does ‘Durability’ in ‘ACID’ mean?
- Ensuring that once a transaction has been executed, it will remain so, even in the event of a power cut
What is Record Locking?
- The process of preventing simultaneous access to records in a database
What is Record Locking used for?
- Preventing inconsistencies or loss of updates
How does Record Locking work?
- While one person is editing a record, the record is ‘locked’, preventing others from accessing the same record
What is ‘Deadlock’?
- When different users on a database lock out records by accessing them causing no progress to be made when the different users want to access files previously accessed by other users
What is Redundancy?
- The process of having one or more copies of the data in physically different locations to ensure that should any damage occur to a copy the other copies remain unaffected