Lecture 2 Flashcards
Relational DBMS
Most DBMS are networked and multi-user, therefore:
- Concurrent writes to files
- Network interruptions
- Database downtime while users are connected
- Requesting changing data
- Managing computational resources
- Authentication and authorisation
ACID
An important property of a multi-user DBMS.
- Atomic: Transactions are all or nothing.
- Consistent: Only valid data is saved
- Isolated: Simultaneous transactions are independently performed
- Durable: Transactions are never lost
A transaction
A unit of work that is executed as a single entity.
Relational approach to a database (Reminder)
Organises data into rows and columns, which collectively from a table. Data is structured across multiple tables, which can be joined with the use of primary and foreign keys.
Entity
Something of interest to the use of the database. e.g Customer, Student, Geolocation
Cell
An individual piece of data stored in a table.
Field
A property of an entity. (column of a table)
Row / Record
An instance of an entity, a collection of cells representing an individual entity.
Result-set
A non-persistent table, the result of a query (What you’ll be working with in code)
Primary Key
One or more columns that together can be used as a unique identifier for each row in a table.
Foreign Key
One or more columns that together are used to identify a record in another table.
Relation integrity constraints (3 constraints)
- Domain constraints
- Key constraints
- Referential Integrity Constraints
Domain constraints for Relational Models
Domain constraints can be violated if an attribute value is not appearing in the corresponding domain or it is not of the appropriate data type.
- Constraints on whether a cell can be NULL
- Constraints on the data type records
Key constraints for Relational Models
Primary key attributes must be unique for different records in the relation.
Primary Key
- Highly stable, unique identifier.
- Cannot have null attributes.
Altering a table:
ALTER TABLE us_states ADD PRIMARY KEY (state_code);
Creating a table:
CREATE TABLE us_states (
InvoiceNo int NOT NULL,
CustomerID int NOT NULL,
Amount int,
PRIMARY KEY (InvoiceNO)
);