Databases Flashcards
what is a database
An organised collection of data enabling efficient:
- Adding
-Modification
-Deleting
-Searching of data
Primary key
Field that holds unique value for each record in a database.
Foreign key
A field that links to tables together.
Secondary key
A unique identifier which is indexed to allow fast searching
Composite primary key
2 or more attributes uniquely identifying a record.
Flat file database
Contains one table. Easy to set up and maintain, but can be inefficient and have repeated data
Referential integrity
Ensures all foreign keys represent a valid and existing primary key in parent table
SQL to extract field
SELECT …
FROM …
WHERE…
ORDER BY….
ASC/DESC
WILDCARD (*) = ALL FIELDS
SQL to combine rows from different tables
JOIN table2
ON table1.attribute = table2.attribute
SQL to create a new database
CREATE TABLE table1
(
Attribute 1 [Datatype,
Null/not null, Primary key]
…
)
Data types for creating tables
CHAR(n)
VARCHAR(n)
BOOLEAN
INTEGER
FLOAT
DATE
TIME
CURRENCY
Adding a column
ALTER TABLE table1
ADD attribute and data types
Deleting a column
ALTER TABLE table1
DROP Attribute
Modifying a column
ALTER TABLE table1
MODIFY COLUMN Attribute NEW DATATYPE
Insert a new record
INSERT INTO COLUMN 1, COLUMN 2,…
VALUES(Value 1, Value2…)