0% found this document useful (0 votes)
11 views6 pages

RDBMS Keys and Operations Guide

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

RDBMS Keys and Operations Guide

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

Database Concepts

1. Differentiate between Candidate key and Primary key in context of RDBMS.


Ans:
Candidate Key: All attribute combinations inside a relation that can serve as primary key are Candidate Keys as they
are Candidates for the primary key position.
Primary Key: A primary key is a set of one or more attributes that can uniquely identify tuples within the relations.

2. Differentiate between Candidate Key and alternate Key in context of RDBMS.


Ans:
Candidate Key: All attribute combinations inside a relation that can serve as primary key are Candidate Keys as they
are candidates for the primary key position.
Alternate Key: A candidate key that is not the primary key is called an Alternate Key.

3. Differentiate between primary key and alternate key.


Ans:
Primary Key: A primary key is a set of one or more attributes that can uniquely identify tuples within the relations.
Alternate Key: A candidate key that is not the primary key is called an Alternate Key.

4. What is the importance of a primary key in a table? Explain with suitable example.
Ans:
Primary Key: A primary key is a set of one or more attributes that can uniquely identify tuples within the relations. A
primary key comprises a single column or set of columns. No two distinct rows in a table can have the same value (or
combination of values) in those columns. Depending on its designing, a table may have arbitrarily many candidate
keys but at most one primary key. The primary key is non redundant. ie .it does not have duplicate values in the
same relation.
Eg: Consider a table that consists the following attributes:
AdmnNo,FirstName,LastName,M1,M2,M3,Total. Here we can uniquely identify the rows in the relation with following
key combinations:

a) AdmnNo
b) FirstName,LastName
We can set any one of the above candidate keys as primary key, others are called as alternate keys.

5. What is an alternate key?

Ans:
Alternate Key: A candidate key that is not the primary key is called an Alternate Key. (Where Candidate Key: All
attribute combinations inside a relation that can serve primary key(uniquely identifies a row in a relation) are
Candidate Keys as they are candidates for the primary key position.)

6. What are DDL and DML?

Ans:
DDL means Data Definition Language. DDL provides statements for the creation and deletion of tables and indexes.
DML Means Data Manipulation Language. The DML provides statements to enter, update, delete data and perform
complex queries on these tables. The SQL DDL(Data Definition Language) provides commands for defining relation
schemas, deleting relations, creating indexes and modifying relation schemas.
The SQL DML (Data Manipulation Language) includes a query language to insert, delete and modify tuples in the
database. DML is used to put values and manipulate them in tables and other database objects and DDL is used to
create tables and other database objects.

Ex:- Create Table, Alter Table, Drop Table are DDL commands
Insert, Select, Update, delete are DML Commands.

7. What do you understand by the terms primary key and degree of a relation in a Relational data base?

Ans:
Primary Key: A primary key is a set of one or more attributes that can uniquely identify tuples within the relations.
The number of attributes in a relation is called Degree of a relation in relational data base.

Eg: Consider a table with the following attributes:


AdmnNo,Rno, FirstName,LastName,Class,Total.
The Primary key is AdmnNo and the degree is 6.

8. What do you understand by the candidate key and cardinality of a relation in relational data base?

Ans:
Candidate Key: All attribute combinations inside a relation that can serve as primary key(uniquely identifies a row in
a relation) are Candidate Keys as they are Candidates for the primary key position.
The number of rows in a relation is known as cardinality of a relation.
Ex.
Table: Student
Admno Rno Fname Lname Class
A101 1 Akhil Gupta 6
A102 2 Raghav Sareen 7
A103 3 Salim Warshid 8
The Cardinality is 3.

9.What is primary key in a table?

Ans:
Primary Key: A primary key is a set of one or more attributes that can uniquely identify tuples within the relations.
Ex.
Table: Student
Admno Rno Fname Lname Class
A101 1 Akhil Gupta 6
A102 2 Raghav Sareen 7
A103 3 Salim Warshid 8
The Primary key is Admno as it uniquely identifies rows in the table.

10. Differentiate between Degree and Cardinality of a relation.

Ans:
The number of attributes in a relation is called Degree of a relation in relational data base.
The number of rows in a relation is known as cardinality of a relation.
Ex.
Table: Student
Admno Rno Fname Lname Class
A101 1 Akhil Gupta 6
A102 2 Raghav Sareen 7
A103 3 Salim Warshid 8
The Degree of the Student relation is 5 and Cardinality is 3.

11. Explain Cartesian product of two relations.

Ans:
The Cartesian product is a binary operation and is denoted by a cross(x). The Cartesian product of two relations A
and B is written as AXB. The Cartesian product yields a new relation which has a degree (number of attributes) equal
to the sum of the degrees of the two relations operated upon. The number of tuples (cardinality) of the new relation is
the product of the number of tuples of the two relations operated upon. The Cartesian product of two relations yields
a relation with all possible combinations of the tuples of the two relations operated upon. All tuples of first relation are
concatenated with all the tuples of second relation to form the tuples of the new relation.

Eg: There are two relations as follows:

Relation 1: Student

Student Number Student Name Hosteler


1 Ravi Y
2 Robert N
Y
3 Raheem

Relation 2: Instructor

InstructorName Subject
K.Suman Computer Science
P.Pavan Electronics
The Cartesian product of these two relations, Student X Instructor, will yield a relation that have a degree of
5(3+2:sum of degrees of Student and Instructor) and a cardinality 6 (3 X 2: Product of cardinalities of two relations).

The resulting relation is as follows: Student X Instructor

Student Number Student Name Hosteler Instructor Name Subject


1 Ravi Y K.Suman Computer Science
1 Ravi Y P.Pavan Electronics
2 Robert N K.Suman Computer Science
2 Robert N P.Pavan Electronics
3 Raheem Y K.Suman Computer Science
3 Raheem Y P.Pavan Electronics
The resulting relation contains all possible combinations of tuples of the two relations.

12. What is a relation? What is the difference between a tuple and an attribute?
Ans:
In relational data model, the data is organized into table (rows and columns). These tables are called relations. A row
in a table represents a relationship among a set of values. Rows of the relations are called as tuples and columns of
the relations are called as attributes.
Ex.
Relation: Student Attributes
`Admno Rno Fname Lname Class
A101 1 Akhil Gupta 6
Tuples A102 2 Raghav Sareen 7
A103 3 Salim Warshid 8
13. What is a View?
Ans:
A view is a virtual table that does not exist in its own right but is instead derived from one or more underlying base
tables. There is no stored file created for storing the contents of a view. The definition of the view is only stored and
its contents are always derived from the base table.
Ex:
Create view sup_delhi as select * from supplier where city=”delhi”;
Base table is supplier and the view is sup_delhi.

14. What is Referential Integrity Constraint?


Ans:
Referential Integrity Constraint states that the foreign key attribute of a table must refer to the legal values of the
primary key attribute of another table that it refers to.
Table :Student
Admno Rno Name Class
A1 1 Babita 3
A2 2 Harry 4
A3 3 Tina 5
Table :Transport

Stu_Adno Bus no Fees


A2 J4 1000
A3 J6 1200
Admno is the Primary key of Student Table and Stu_Adno is the Foreign key of Transport table as it refers to the
Admno field.

15. What is the Foreign Key of a relation?


Ans:
A non-key attribute , whose values are derived from the primary key of some other table, is known as foreign key in
its current table.
Table :Student
Admno Rno Name Class
A1 1 Babita 3
A2 2 Harry 4
A3 3 Tina 5

Table :Transport

Stu_Adno Bus no Fees


A2 J4 1000
A3 J6 1200
Admno is the Primary key of Student Table and Stu_Adno is the Foreign key of Transport table as it refers to the
Admno field.

16. Explain the Union of two relations.


Ans:
The Union is a binary operation and is denoted by a (U). The Union of two relations A and B is written as AUB. The
new relation contains tuples from both the operand relations.
The two relations should be union- compatible:-
1. The relations Aand B must be of same degree.
2.The domins of the ith attribute of A and ith attribute of B must be same.
Union eliminates duplicate rowsautomatically.
Ex: There are two relations as follows:

Relation 1: Drama

Rno Name Age


1 Ravi 20
2 Robert 22
25
3 Raheem

Relation 2: Song
Rno Name Age
1 Ravi 20
12 Suman 12
13 Raj 18

The resulting relation is as follows: Drama U Song


Rno Name Age
1 Ravi 20
2 Robert 22
25
3 Raheem

12 Suman 12
13 Raj 18

17. Explain the Select operation in Relational Algebra?


The Select operation in Relational Algebra selects horizontal subset of a relation that satisfies a given predicate.It is
denoted by lowercase greek letter sigma().

Ex: Table :Student


Admno Rno Name Class
A1 1 Babita 3
A2 2 Harry 4
A3 3 Tina 5
A4 4 Simple 3
A5 5 Yashika 4

 class=3(Student)
Admno Rno Name Class
A1 1 Babita 3
A4 4 Simple 3

18. Explain the Project operation in Relational Algebra?


The Project operation in Relational Algebra selects vertical subset of a relation.It is denoted by (π).
Ex:
Table :Student
Admno Rno Name Class
A1 1 Babita 3
A2 2 Harry 4
A3 3 Tina 5
A4 4 Simple 3
A5 5 Yashika 4

π Admno(Student)
Admno
A1
A4

19. Define a Constraint. Explain the Default constraint.


Ans:
A constraint is a condition or check applicable on a field or set of fields.
A default value can be specified for a column at the time of creation of a table using the default constraint. When the
user does not enter a value for that column , then automatically the default value is inserted.
Ex:
Create table student (admno int(4), name varchar(15), grade char (2) default = ‘A+’);

20. What is a Database? How is it different from a DBMS?


Ans:
Database is a collection of interrelated data and a database system is a computer based record keeping system.

DBMS
Database System
Database

Application Program 1

Application Program 2 User 1

Application Program 3 User 2

Application Program 4 User 3

You might also like