Overview of Databases: University Institute of Engineering (UIE)
Overview of Databases: University Institute of Engineering (UIE)
Overview of Databases: University Institute of Engineering (UIE)
DBMS
Overview of Databases
Outline
• Attribute
• Each column in a Table. Attributes are the properties which define a
relation. e.g. Student, Rollno, NAME etc.
• Tuple
• It is nothing but a single row of a table, which contains a single record.
• Degree
• The total number of attributes which in the relation is called the
degree of the relation.
• Cardinality: Total number of rows present in the Table.
Keys in DBMS
Keys in DBMS
Keys in DBMS
Keys in DBMS
• Foreign key
• A foreign key is a column which is added to create a relationship
with another table.
• Foreign keys are used to link together two or more different tables
which have some form of relationship with each other.
• Foreign keys values should always be matched by corresponding
primary key values.
• e.g. Consider the two tables(EMP,DEPT)
• In a company, every employee works in a specific department and
employee and department are two different tables. So you can't store
the information of the department in the employee table. That's why
you need to link these two tables through the primary key of one
table.
Keys in DBMS
In the EMP table, Deptno is the foreign key and both the tables are related.
Keys in DBMS
• Candidate Key
• Candidate keys are defined as the minimal set of fields which can
uniquely identify each record in a table.
• It is an attribute or a set of attributes that can act as a Primary Key
for a table to uniquely identify each record in that table. There can
be more than one candidate key.
• Properties of Candidate key:
• It must contain unique values
• Candidate key may have multiple attributes
• Must not contain null values
• It should contain minimum fields to ensure uniqueness
• Uniquely identify each record in a table
Keys in DBMS
student_id and phone both are candidate keys for table Student.
The Primary key should be selected from the candidate keys.
Keys in DBMS
Keys in DBMS
• Super Key
• Super key is a set of one or more than one keys that can be used to
uniquely identify the record in table.
• A super key has the uniqueness property but not necessarily the
irreducibility property. A candidate key is a special case of a super key.
• In the table defined,
• super key would include student_id, (student_id, name), phone etc.
• student_id is unique for every row of data, hence it can be used to
identity each row uniquely.
• (student_id, name), name of two students can be same but student_id
can't be same hence this combination can also be a key.
• phone number for every student will be unique hence again, phone can
also be a key. So they all are super keys.
Keys in DBMS
Keys in DBMS
Keys in DBMS
• Composite Key
• Composite key is a combination of more than one attributes that can be
used to uniquely identity each record. It is also known as “Compound”
key.
• A composite key may be a candidate or primary key.
Keys in DBMS
• Surrogate Key
• Surrogate key is a kind of primary key, but it is not defined by the
designer.
• It is a system generated random number.
• Surrogate key is an artificial key that is used to uniquely identify the
record in table.
• For example, in SQL Server or Sybase database system contain an
artificial key that is known as “Identity”.
• Artificial keys are permitted when no attribute has all the primary
key properties or the primary key is large and complex.
Integrity Constraints
Integrity Constraints
• Domain constraints
• Domain constraints can be defined as the definition of a valid set of
values for an attribute.
• The data type of domain includes string, character, integer, time,
date, currency, etc. The value of the attribute must be available in the
corresponding domain.
• Example:
Integrity Constraints
Integrity Constraints
Integrity Constraints
Integrity Constraints
• Key constraints
• Keys are the entity set that is used to identify an entity within its entity
set uniquely.
• An entity set can have multiple keys, but out of which one key will be the
primary key. A primary key can contain a unique and null value in the
relational table.
• Example:
• The schema will remain the same while the values filled into it
change from instant to instant.
• When the schema framework is filled in with data item values, it is
referred as an instance of the schema.
• The data in the database at a particular moment of time is called a
database state or snapshot, which is also called the current set of
occurrences or instances in the database.
• Schema is of three types: Physical schema, logical schema and view
schema.
For example, in the given figure, the database changes whenever you add a
new grade or add a student.
The data at a particular moment of time is called the instance of the database.
THANKS…..