Documente Academic
Documente Profesional
Documente Cultură
BLESSING GWANYANYA
C18132501F
DATABASE SYSTEMS (CUIT201)
Assignment 2
1.
ii) Candidate Key – Candidate key is a column or set of columns in a table that can
uniquely identify any database record without referring to any other data. Cuttuckshop
database has productid and CategoryID as uniquely defined tables.
iii) Foreign Key – Foreign keys are the columns of a table that show the primary key of
other tables. CategoryID shows the primary key in the tcategory table.
iv) Alternate Key – ) An alternate keys contain one or more columns whose combined
values uniquely identify every row in a table. For example in the category table
(tcategory), our alternate key is category_name because it can be use to uniquely
identify a record in the table.
d) Domain integrity specifies that all columns in a relational database must be declared
upon a defined domain. The primary unit of data in the relational data model is the data
item. This type of data integrity warrants the following: the identity and purpose of a field is
clear and all of the tables in which it appears are properly identified; field definitions are
consistent throughout the database; the values of a field are consistent and valid; and the
types of modifications, comparisons and operators that can be applied to the values in the
field are clearly identified.
g) SELECT product_name,CURDATE(),expiry_date,
TIMESTAMPDIFF(YEAR,expiry_date,CURDATE()) AS age
FROM tproduct WHERE expiry_date is NOT NULL ORDER BY age;
i) SELECT product_name,CURDATE(),expiry_date,
TIMESTAMPDIFF(YEAR,expiry_date,CURDATE()) AS age
FROM tproduct WHERE expiry_date is NOT NULL ORDER BY age;