Professional Documents
Culture Documents
Introduction To Database Management
Introduction To Database Management
Introduction To Database Management
Database management is the process of storing data in a computer in an organized manner and can
be retrieved electronically.
Sex CHAR,
Bdate DATE,
Relationship VARCHAR(8),
Primary key(Essn,Department_name),
Primary key(Essn,Pno),
Plocation VARCHAR(15),
UNIQUE(Pname),
EXAMPLE
EMPLOYEES
DELETE COMMAND
EXAMPLE
WHERE Lname=’Brown’
UPDATE COMMAND
EXAMPLE
UPDATE PROJECT,
SET Plocation=”Ballairre”,Dname=5,
WHERE Pnumber=10
SELECT Fname,Lname,
FROM EMPLOYEE,
WHERE Super_Ssn is NULL
Aggregate of functions to the SQL
SELECT SUM(SALARY), MAX(SALARY), MIN(SALARY), AVG(SALARY)
FROM EMPLOYEES
SUM finds or compute the sum of all the values of a given attribute in a given relation.
MAX the maximum values or the largest of a given attribute.
MIN finds the minimum values of a given attribute.
AVG finds the average of all the values of a given attribute.
COUNT
EXAMPLE
SELECT COUNT(*)
FROM EMPLOYEE
GROUP BY clause
SELECT SALARY,COUNT(SALARY)
FROM EMPLOYEE
SELECT Dno,COUNT(Dno)
FROM EMPLOYEE GROUP BY Dno
SELECT SALARY,Dno,COUNT(Dno)
FROM EMPLOYEE GROUP BY Dno
ATTRIBUTE
Are the properties that defines a relation
RELATION SCHEMA the design of one table containing the name of the table(relation) and the name of
the column.
Properties of the attributes
Tuples in a relation are not ordered and do not change the table.
Once the schema is defined,Vi,in each tuple,t,must be ordered.
Properties of the relations
Relation is distinct from any other relation.
Each cell in a relation contains exactly one value of atomic.
Each attribute has distinct name.
Values of an attribute are all from the same domain.
Order of the attributes have no significance.
Each tuple is distinct ,there are no duplicate tuples.
Order of tuples has no significance.
Relational keys
A candidate keys
Super key
Primary key
A super key
A super key is a key that uniquely identifies a tuple within a relation.
A relation may have more than one super key but is always has at least one.
Candidate key
It is a super key that is minimal that is, there is no proper subset that is itself a super key.
Properties of a super key
In each tuple of a relation the values of a relation schema uniquely identify that tuple(unique).
No proper subset of a relation schema has the uniqueness properties(irreducibility).
Primary key
The primary key of a relation is a candidate key especially selected to be the key for the relation.
Relational language
Relational language is an abstract language which provides the database users with an interface
through which they can specify data to be retrieved.
Foreign key
Is the attribute within one relation that matches candidate key of another relation.
Relational algebra
Is a procedural language consisting of a set of operators
Each operator rakes one or more relations as its inputs and produces relation as its output.
Characteristics of a relation
Ordering of a tiple in a relation-element of a set have no order among them therefore tuples
in a relation are not ordered.
Ordering of values within a tuple-a tuple is a list of n values.so the ordering of values in a
tuple is important.
Values and NULL in a tuple-each value in a tuple is an atomic value i.e.it is not divisible into
components within the framework of basic relation model.
NULL values are used to represent the values that may be unknown or may not apply to a tuple.
Interpretation of a relation-a relation schema can be represented as a declaration or type of
assertion. Each tuple in a relation can be interpreted as a fact.
Categories of databases constraints
Constraints that are inherent to the model-inherent model-based constraint
Constraints that can be directly expressed in the scheme of the data model. Typically
defined in the data definition language.
Constraints that cannot directly expressed in the schemas of the data model and hence
must be expressed and enforced by a data program.
Example
Application based
Semantic based
Business rules
Domain constraints
Domain constraints specify within each tuple, the value of each attribute must be atomic value
from the domain
Key constraints and constraints on NULL values
All tuple in a relation must be distinct or unique.
This means that no two tuples can have the same combination of values of all their attributes
Usually there are other subset of the attribute of a relation schema with the property that no two
tuple an have the same combination of all values for all their attributes