0% found this document useful (0 votes)
44 views4 pages

Dbms Unit2

The document discusses the basics of relational database management systems (RDBMS). It defines key terms like relation, tuple, cardinality, attributes and describes relational algebra operations like select, project, cartesian product, union, set difference and intersection. It also discusses keys, entity relationship modeling and integrity constraints.

Uploaded by

Andriya Biju
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views4 pages

Dbms Unit2

The document discusses the basics of relational database management systems (RDBMS). It defines key terms like relation, tuple, cardinality, attributes and describes relational algebra operations like select, project, cartesian product, union, set difference and intersection. It also discusses keys, entity relationship modeling and integrity constraints.

Uploaded by

Andriya Biju
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

RELATIONAL DATABASE MANAGEMENT SYSTEM(RDBMS)

RDBMS is a database management system that is based on the relational model. Data is stored
in the form of tables and relationship among the data is also stored in the form of tables.
Elementary Terminologies of RDBMS.
1) Relation :
A relation is represented in a table as rows and columns. All the rows will contain individual
data. The data in the rows are of distinct data type ,where as data in a particular column are of the
same data type.
2) Domain :Each attribute is associated with a set of values called domain of the attribute
3) Tuple :The rows of a relation are referred to as Tuples.
4) Cardinality :The number of rows or Tuples in a relation is called cardinality.
5)Attributes :The columns of a relation are called attributes.
6) Degree :The number of attributes in each row is called degree of relation.
Relational Algebra and Operations:

I) The SELECT operations(σ )


Consider a table STUDENT
RollNo Name Address Age
100 Neenu Trivandrum 14
101 Anju Kottayam 15
102 Raju Trissur 14
103 Anil Kannur 15

Eg: σ Age=15(STUDENT) ,The operation will give the following relation as output
whose age=15
RollNo Name Address Age
101 Anju Kottayam 15
103 Anil Kannur 15
II) Project Operation ( π )
This operation removes certain columns of a given relation.
Eg: π Name,Age (STUDENT) , output is
Name Age
Neenu 14
Anju 15
Raju 14
Anil 15
III) Cartesian product ( X )
This operator combines information from two tables. Consider two tables
STUDENT TEACHER
RollNo Studname Teachname Subject
100 Anju Madhu English
101 Neenu Raju Malayalam

STUDENT X TEACHER

RollNo Studname Teachname Subject


100 Anju Madhu English
100 Anju Raju Malayalam
101 Neenu Madhu English
101 Neenu Raju Malayalam
IV) The Union operation ( U )
This operation can be performed on two relation with same degree.
STUDENT 1 STUDENT 2
RollNo Name Address Age RollNo Name Address Age
100 Neenu Trivandrum 14 102 Raju Thrissur 14
101 Anju Kottayam 15 103 Anil Kannur 15

STUDENT1 U STUDENT2
RollNo Name Address Age
100 Neenu Trivandrum 14
101 Anju Kottayam 15
102 Raju Trissur 14
103 Anil Kannur 15
V)The Set Difference operation (-)
The operation allows the user to find the rows in one table but not in the other.
R S R--S
Name Name Name
Jos Rajan Anil
Anil Usha Jos
Tuttu Tuttu

VI)Intersection operation (∩)


It returns a relation consisting of all rows appearing in both of the two specified
relations.
R S
R∩S
Name Name
Name
Jos Rajan
Anil Usha Tuttu
Tuttu Tuttu
Relational Calculus
Relational Calculus is a non-procedural query language, that is, it tells what to do but never
explains how to do it.Two types are

Domain relational Calculus and Tuple relational calculus:


Tuple Relational Calculus is used to select tuples (rows) from a relation (table), whereas
Domain Relational Calculus is used to select individual values from a relation. Tuple Relational
Calculus uses tuple variables to represent tuples, while Domain Relational Calculus uses individual
value variables.
Keys:
Keys are the attribute by which rows can be identified from one another.
1. Candidate Key:
It is a set of attributes that uniquely identifies a row. In the STUDENT table ,RollNo is a
candidate key. RollNo+Name is also a candidate key.
2. Primary Key:
Primary key is a set of one or more columns of a table that uniquely identify a record in
database table. It does not have duplicate values in the same relation.Primary keys must contain
UNIQUE values, and cannot contain NULL values. That is no two students in the STUDENT relation
can have the same RollNo.
3. Alternate Key:
The candidate key that is not the primary key is called the alternate key.
4. Super Key:
A combination of a primary key with any other attribute or group of attributes is called a
super key. In the STUDENT relation, RollNo+Name or RollNo+Address can be considered as super
key.
5. Foreign Key:
Foreign Key is a column in database table that is Primary key in another table. It can accept
multiple null, duplicate values. Example : We can have a Emp_ID column in the Department table
which is pointing to Emp_ID column in a employee table where it a primary key.

6. Composite/Compound Key
Composite Key is a combination of more than one fields/columns of a table. It can be a Candidate key,
Primary key.

Extended Entity-Relationship (EER) Model


EER is a high-level data model that incorporates the extensions to the original ER model. In
addition to ER model concepts EER includes −
1. Subclasses and Super classes: Super class is an entity that can be divided into further subtype. Super
class shape has sub groups: Triangle, Square and Circle.Sub classes are the group of entities with
some unique attributes.Sub class inherits the properties and attributes from super class.
2. Specialization and Generalization: Generalization is a process of generalizing an entity which
contains generalized attributes or properties of generalized entities. Consider we have 3 sub entities
Car, Truck and Motorcycle. Now these three entities can be generalized into one super class named as
Vehicle. Specialization is a process of identifying subsets of an entity that share some different
characteristic. In the above example Vehicle entity can be a Car, Truck or Motorcycle.
3. Category or union type: Relationship of one super or sub class with more than one super class.
Owner is the subset of two super class: Vehicle and House
4. Aggregation: In aggregation, the relation between two entities is treated as a single entity. In
aggregation, relationship with its corresponding entities is aggregated into a higher level entity.

Integrity Rule:
There are four types of integrity constraints in DBMS:
 Domain Constraint
 Entity Constraint
 Referential Integrity Constraint
 Key Constraint
1. Domain integrity constraint contains a certain set of rules or conditions to restrict the kind of
attributes or values a column can hold in the database table.
Roll No Name Age Class
101 Adam 14 6
102 Steve 16 8
103 Tim 6 A
In the above student's table, the value A in the last row last column violates the domain integrity
constraint because the Class attribute contains only integer values while A is a character.
2. Entity Integrity Constraint is used to ensure that the primary key cannot be null. A primary key is
used to identify individual records in a table and if the primary key has a null value, then we can't
identify those records. Consider Employees table having Id, Name, and salary of employees
ID Name Salary
1101 Jackson 40000
1102 Ash 180000
James 36000

In the above employee's table, we can see that the ID column is the primary key and contains a null value
in the last row which violates the entity integrity constraint.
3. Referential Integrity Constraint ensures that there must always exist a valid relationship between
two relational database tables. This valid relationship between the two tables confirms that a foreign
key exists in a table. It should always reference a corresponding value or attribute in the other table
or be null.
Consider an Employee and a Department table where Dept_ID acts as a foreign key between the two
tables
Employees Table Department Table
ID Name Salary Dept_ID
1101 Jackson 40000 3
Dept_ID Dept_Name
1102 Harry 60000 2
1 Sales
1103 Steve 80000 4
2 HR
1104 Ash 180000 3
3 Technical
1105 James 36000 1
In the above example, Dept_ID acts as a foreign key in the Employees table and a primary key in the
Department table. Row having DeptID=4 violates the referential integrity constraint since DeptID 4 is
not defined as a primary key column in the Departments table.
4. Key constraint
Keys are the set of entities that are used to identify an entity within its entity set uniquely. There could
be multiple keys in a single entity set, but out of these multiple keys, only one key will be the primary
key. A primary key can only contain unique and not null values in the relational database table.
Example:
Consider a student's table
Roll No Name Age Class
101 Adam 14 6
102 Steve 16 8
103 David 8 4
104 Bruce 18 12
102 Tim 6 2
The last row of the student's table violates the key integrity constraint since Roll No 102 is repeated
twice in the primary key column. A primary key must be unique and not null therefore duplicate
values are not allowed in the Roll No column of the above student's table.

You might also like