3.10 Fundamentals of Databases Flashcards
entity definition
category of object about which data is to be recorded, Entity1 (Attribute1, Attribute2…)
attribute definition
characteristics about entities
entity identifier
each identity has a unique identifier, an attribute that is unique within that table, underlined
relationships between entities
one-to-one, one-to-many, many-to-many
foreign key
attribute that creates join between two tables, attribute that is common in the tables, called primary key in one and foreign in other
first normal form
contains no repeating attributes or groups of attributes, split repeating attributes so it becomes 1nf
second normal form
database must satisfy first normal form, partial key dependencies are removed
partial key dependency meaning
one or more attributes depends on only part of a primary key
third normal form
conforms to second normal form, database must have no non-key dependencies, all attributes depend on the key, the whole key and nothing but the key
importance of normalisation
easier to maintain and change, no unnecessary duplication of data, faster sorting and searching, saves storage space as data is only held once
normalisation
no data is unnecessarily duplicated, data is consistent throughout database automatically, structure of table is flexible
SQL as declarative language
programmer describes the result that’s required
SELECT command SQL
used for retrieving, SELECT <attribute> FROM <table> WHERE <condition> (ORDER BY <ASC/DESC>)</condition></attribute>
UPDATE command SQL
modifies attributes of already existing entity, UPDATE <table> SET <attribute> = <value> WHERE <attribute> = <value></value></attribute></value></attribute>
DELETE command SQL
removes entities from database, DELETE FROM <table> WHERE <condition></condition>
INSERT command SQL
adds new records to existing table, INSERT INTO <table> VALUES (<value1> <value2>)</value2></value1>
wildcards
any possible value, can return all values
defining table with SQL
CREATE TABLE tablename (attribute datatype, …)
client server database
provides simultaneous access to database for multiple clients, concurrent access occurs when same field is being accessed at same time by different users
how is concurrent access managed
record locks, serialisation, timestamp ordering, commitment ordering
record locks
when a record is accessed by one user, it is immediately locked to others until user is finished, blocked from accessing or modifying
serialisation
requests from other users are placed in a queue
timestamp ordering
each command is assigned a timestamp and commands are carried out in order of timestamps
commitment ordering
algorithm is used to work out optimum order in which to execute commands