1.3.2 Databases Flashcards
(27 cards)
What is an entity
An item of interest in which data is stored
Flat File
() Single file about single entity and its attributes
Primary key
() A unique identifier
() Field that does not repeat
Foreign key
Attribute that links two tables
Secondary Key
() Enables data base to search quickly through indexing
What does normalisation aim to do
() No redundancy
() Consistent data through linked tables
() Records changed without issue (add and delete)
() Complex queries can be done
1NF:
Contains atomic values (no more than a single value)
Unique column names
Primary key present
2NF:
No partial dependancies (Compostite key)
in 1NF
3NF:
() In 2NF
() No non-key dependencies
Indexing
() Method use to store the position of each record when ordered by a certain attribute
() Used to look up data quickly
() Primary key is automaticlly indexed
Capturing data methods:
Forms
OMR
OCR
Sensors
Barcodes
Data Mining
All sensors
OCR
OMR
Temperature
Pressure
Proximity
Light
Motion
Humidity
Gas
Force
Acoustic
Magnetic
Exchanging Data:
CSV: Plain text, commas to seperate
EDI: Doesn’t require human interaction
Memory sticks
Email
Selecting and managing data:
SQL
Select data SQL
SELECT Attributes
FROM Tablename
WHERE Attribute BETWEEN/LIKE Something
ORDERBY Attribute
Combine rows from databases based on common field
SELECT Attributes
FROM Tablename
JOIN Othertablename
ON Tablename.attribute = Othertablename.attribute
SQL Create
CREATE TABLE Tablename
(
Attribute 1 INTEGER NOT NULL, PRIMARY KEY,
Attribute 2 VARCHAR(20) NOT NULL
)
Is it primary key
Its data type
Does it need to be filled in?
ALTER
Adding column:
ALTER TABLE Tablename
ADD Attribute and their data types
Deleting a column:
ALTER TABLE Tablename
DROP COLUMN Attribute
Modify column:
ALTER TABLE Tablename
MODFIY COLUMN Attribute Newdatatype
Data types:
CHAR(n): Fixed length
VARCHAR(n): Upper limit
DATE
TIME
CURRENCY
Insert record
INSERT INTO (column1, column2)
VALUES (value1, value2)
DELETE
DELETE FROM Tablename
WHERE Attribute = value
Nested Select Example
SELECT*
FROM Employees
WHERE Salary > (SELECT AVG(salary) FROM Employees)
Referential integrity
() Process of ensuring consistency
() Makes sure information isnt removed if it is needed elsewhere in a linked database
Transaction
A single operation executed on data
Must be in line with ACID