COSC265 Flashcards
Parametric end user
uses existing queries - don’t create their own
Casual end user
not particularly knowledgeable, will use query builders and UI tools
sophisticated end user
is able to make complex SQL queries
stand-alone end user
Uses their own database for their own means
structural component
the relations, the cardinality, the degree, the keys
integrity component
applying correct use of primary and foreign keys, as well as the implementation of constraints in order to ensure that data can only be entered if it is valid and correct given the context of the database
operational component
CRUD operations, SQL queries, implementing transactions
DDL
Data definition language
Defines and manages objects
CREATE, ALTER, DROP
VDL
View definition language
not a formal language
Is just used to create views
uses both DDL and DML components
DML
Data manipulation language
manages the data itself
SELECT, INSERT, UPDATE, DELETE
phases of database design
requirements collection and analysis
conceptual design
logical design
physical design
phases of ER modelling
Identify entities and attributes
identify relationships and attributes thereof
examine for problems and repeat
degree
the number of attributes in a relation
cardinality
the number of tuples in a relation
domain constraint
part of integrity component of RDM
Defining the valid data for an attribute. Type and size. eg: varchar(20)
key constraint
part of integrity component of RDM
applies uniqueness rules to keys, preventing integrity errors. Also requires keys be irreducible
entity integrity constraint
part of integrity component of RDM
ensures each table has exactly one primary key, of which meets key constraints whilst also being not null
referential integrity constraint
part of integrity component of RDM
ensures there are no foreign key values that do not match a value in the referenced table
business constraints
part of integrity component of RDM
business logic such as salary rules for managers and employees
Division
smaller table must be proper subset
attribute names must be the same.
get all tuples (excluding the attributes from the subset) of which the ID has instances for each item in the subset.
union compatible operations
UNION is where you combine the values of two relations to make a single big relation, so therefore union compatibility requires both relations to have the same degree, data types, and order
When can updating a view update the underlying database
When the view is based on a simple
select X,Y,Z from table where condition;
You can also update attributes in the underlying table that aren’t in the view, so long as the selection is made based on the attribute in the view
EER -> RM
ER:
make tables for all,
weak entities = 1:m,
Binary - total participation,
1:m - m
m:n - new
multivalue = 1:m
Nary - new
EER:
one table with flags,
TP + D can be multiple tables
multiple inheritance - choose one, flag other
union: 1:m
DOMAIN
CREATE DOMAIN AgeType AS INTEGER CHECK (VALUE >= 0 AND VALUE <= 120);
CONSTRAINT
CREATE TABLE Employees (
EmployeeID INT PRIMARY KEY,
Age INT,
CONSTRAINT chk_age CHECK (Age >= 18)
);
ALTER
ALTER TABLE Employees
ADD COLUMN PhoneNumber VARCHAR(15); - uses all DDL
MODIFY PhoneNumber char(15); - changes types
DEFAULT
CREATE TABLE Orders (
OrderID INT PRIMARY KEY,
OrderDate DATE DEFAULT CURRENT_DATE
);
scalar functions
Operate on a single value and return a single value
LIKE
_ single
% any number including 0
correlated/non-correlated nested queries
non-correlated means the query can be executed stand-alone as it does not rely on values from the outside query
Correlated utilises aliases to allow operations within the nested query that involve relations of the outer query
INSERT
INSERT INTO Employees (EmployeeID, FirstName, LastName, Age, Email)
VALUES (1, ‘John’, ‘Doe’, 25, ‘john.doe@example.com’);
UPDATE
UPDATE Employees
SET Age = 26
WHERE EmployeeID = 1;