8 DBMS Throry
8 DBMS Throry
: 9810301034
EDUCATION
FOR
EVERYONE
D.B.M.S
(DATA BASE MANAGEMENT SYSTEM)
1. What does DBMS stand for?
A. Data Backup Management System B. Database Management System
C. Data Business Management System D. Digital Base Management Software
Answer: B. Database Management System
2. DBMS stands for __________.
Answer: Database Management System
3. DBMS stands for Database Management __________.
A. Solution B. Software C. System D. Service
Answer: C. System
4. A database is an organized collection of related data.
Answer: True
DATABASE CONCEPTS
INTRODUCTION TO DATABASE CONCEPTS AND ITS NEED
o LIST DIFFERENT TYPE OF DATABASE EXAMPLES:
o ADVANTAGES OF DATABASE
o VARIOUS LEVELS OF DATABASE
o DIFFERENT DATA MODEL
o KEY FUNCTIONS OF A DBMS:
o EXAMPLES OF DBMS SOFTWARE:
o ADVABTAGE OF DBMS SOFTWARE:
o TYPES OF KEYS IN DBMS
o KEY CONCEPTS IN RELATIONSHIPS
o BASIC TERMINOLOGIES RELATED TO A RELATIONAL
DATABASE AND TABLES (RELATION)
o RELATIONAL DATABASE MODEL
o DATABASE KEYS
CARDINALITY OR ROW IN A TABLE IS CALLED TUPLES
RELATIONAL DATA MODEL:
o RELATION
o ATTRIBUTE
o TUPLE
o DOMAIN
o DEGREE
o CARDINALITY
KEYS (CANDIDATE KEY, PRIMARY KEY, ALTERNATE
KEY, FOREIGN KEY)
ADVANTAGES OF DATABASE
1. Data Security: Data Security is vital concept in a database. Only authorized users should be allowed to access the
database and their identity should be authenticated using a username and password. Unauthorized users should
not be allowed to access the database under any circumstances as it violates the integrity constraints.
2. Privacy: The privacy rule in a database means only the authorized users can access a database according to its
privacy constraints. There are levels of database access and a user can only view the data he is allowed to. For
example - In social networking sites, access constraints are different for different accounts a user may want to access.
3. Backup and Recovery : Database Management System automatically takes care of backup and recovery. The users
don't need to backup data periodically because this is taken care of by the DBMS. Moreover, it also restores the
database after a crash or system failure to its previous condition.
4. Data Consistency: Data consistency is ensured in a database because there is no data redundancy. All data appears
consistently across the database and the data is same for all the users viewing the database. Moreover, any changes
made to the database are immediately reflected to all the users and there is no data inconsistency.
5. Reducing Data Redundancy: The file based data management systems contained multiple files that were stored in
many different locations in a system or even across multiple systems. Because of this, there were sometimes multiple
copies of the same file which lead to data redundancy. This is prevented in a database as there is a single database
and any change in it is reflected immediately. Because of this, there is no chance of encountering duplicate data.
6. Sharing of Data: In a database, the users of the database can share the data among themselves. There are various
levels of authorization to access the data, and consequently the data can only be shared based on the correct
authorization protocols being followed. Many remote users can also access the database simultaneously and share
the data between themselves.
7. Data Integrity: Data integrity means that the data is accurate and consistent in the database. Data Integrity is very
important as there are multiple databases in a DBMS. All of these databases contain data that is visible to multiple
users. So it is necessary to ensure that the data is correct and consistent in all the databases and for all the users.
VARIOUS LEVELS OF DATABASE
Page 3 of 14 EDUCATION FOR EVERYONE
Mr. Gajendra Sharma CS/IP Mo.NO.: 9810301034
Physical Level (Internal Level ) : This is the lowest level in the three level architecture. It is also known as the internal level. The
physical level describes how data is actually stored in the database. In the lowest level, this data is stored in the external hard
drives in the form of bits and at a little high level, it can be said that the data is stored in files and folders. The physical level
also discusses compression and encryption techniques.
Conceptual Level : The conceptual level is at a higher level than the physical level. It is also known as the logical level. It
describes how the database appears to the users conceptually and the relationships between various data tables. The
conceptual level does not care for how the data in the database is actually stored.
External Level (View Level ): This is the highest level in the three level architecture and closest to the user. It is also known as
the view level. The external level only shows the relevant database content to the users in the form of views and hides the
rest of the data. So different users can see the database as a different view as per their individual requirements.
DIFFERENT DATA MODEL
HIERARCHICAL MODEL : Hierarchical Model was the first DBMS model. This
model organizes the data in the hierarchical tree structure. The hierarchy starts
from the root which has root data and then it expands in the form of a tree
adding child node to the parent node. This model easily represents some of the
real-world relationships like food recipes, sitemap of a website etc.
Example: We can represent the relationship between the shoes present on a
shopping website in the following way:
NETWORK MODEL : This model is an extension of the hierarchical model. It was
the most popular model before the relational model. This model is the same as
the hierarchical model, the only difference is that a record can have more than
one parent. It replaces the hierarchical tree with a graph.
Example: In the example below we can see that node student has two parents
i.e. CSE Department and Library. This was earlier not possible in the hierarchical
model.
RELATIONAL MODEL : Relational Model is the most widely used
model. In this model, the data is maintained in the form of a
two-dimensional table. All the information is stored in the form
of row and columns. The basic structure of a relational model
is tables. So, the tables are also called relations in the relational
model. Example: In this example, we have an Employee table.
Primary Key (PK): ProductID Candidate Keys: ProductID, Barcode, SKU Alternate Keys: Barcode, SKU
Key Type Definition Example
RollNo in a Students table uniquely
Primary Key A unique identifier for each row in the table.
identifies each student.
All potential keys that can uniquely identify In a Students table, RollNo and Email
Candidate Key rows. Primary Key is one of the Candidate are Candidate Keys because they can
Keys. uniquely identify students.
Any Candidate Key that is not chosen as the If RollNo is the Primary Key, then
Alternate Key
Primary Key. Email is an Alternate Key.
A key in one table that references the Primary
RollNo in a Grades table refers to
Foreign Key Key in another table to establish a
RollNo in the Students table.
relationship.
Example Table: Students
RollNo (PK) Email (AK) Name
101 [email protected] Alice
102 [email protected] Bob
103 [email protected] Charlie
Primary Key: RollNo Candidate Keys: RollNo, Email Alternate Key: Email (since RollNo is chosen as the
Primary Key) Foreign Key: Not applicable here (requires another table).
Example Table: Grades
GradeID (PK) RollNo (FK) Grade
1 101 A
2 102 B
3 103 A
Primary Key: GradeID Foreign Key: RollNo (references RollNo in the Students table).
Key Relationships:
o Primary Key vs. Candidate Key:Every Primary Key is a Candidate Key, but not every Candidate Key becomes a
Primary Key.
o Alternate Key:The Candidate Keys that are not chosen as the Primary Key.
o Foreign Key:Establishes relationships between tables by referencing the Primary Key of another table.
DATABASE KEYS
Keys are a very important part of Relational database. They allow us to identify an attribute or a set of
attributes on the basis of which a table is identified. They are used to establish and identify relation between
two or more tables. They also ensure that each record within a table can be uniquely identified by a
combination of one or more fields within a table.
The different types of keys in an RDBMS are as follows:
KEY DISCRIPTION
Primary Key A primary key is an attribute or a group of attributes that can uniquely identify tuples within the
relation
Candidate Key A candidate key is one that is capable of becoming the primary key (i.e., candidate for the
primary key position).
Alternate Key A candidate key that is not the primary key is called an alternate key.
Primary Key: A primary key is a set of one or more attributes/fields which uniquely identifies a tuple/row in a table.
The salient features of a primary key are as follows:
(a) It is always unique in nature, i.e., non-redundant. It does not have duplicate values in a relation.
(b) It arranges the table in its own order.
(c) It cannot be re-declared or left null.
ALTERNATE KEY: A candidate key that is not the primary key is called an alternate key. In other words, any
attribute that is a candidate for the primary key, i.e., which is capable of becoming a primary key but is not a
primary key, is an alternate key. For example, in a customer table, cust_name is the alternate key. Similarly, in
the given table Item, Item_name becomes the alternate key. Candidate key = Primary Key + Alternate Key
Primary Key : An attribute or a group of attribute which can distinguish a row uniquely in a table is Called
Primary key/Key Field/Key attribute.
Candidate key : The attributes which are capable to act as a primary key is known as candidate key.
Alternate key : An attribute which can act as a primary key in place of primary key as called alternate key.
Foreign Key : An attribute in it’s present table whose values are derived from some other table, is called
foreign key in the present table.
Answer:
Degree is the number of attributes or columns present in a table. Cardinality is the number of tuples or
rows present in a table.
Patients Degree = 4 Cardinality = 5
Q2. Observe the following table and SQL> the parts (i) and (ii):
SQL> :
CARTESIAN PRODUCT
Degree : 4 (PARTICIPANTS ATTRIBUTE + EVENTS * ATTRIBUTE)
2+2 (COMMAN ONLY FOR ONCE)
Cardinality : 6 (PARTICIPANTS TUPLES *EVENTS *TUPLES) 3*2=6
DBMS MULTIPLE-CHOICE QUESTIONS (MCQS)
Page 11 of 14 EDUCATION FOR EVERYONE
Mr. Gajendra Sharma CS/IP Mo.NO.: 9810301034
1. What is a database? 15. What is the domain of an attribute?
a) A collection of tables a) The total number of rows in a table
b) A collection of related data b) The set of all possible values an attribute can take
c) A collection of files c) The set of all primary keys in a table
d) A single file storing all records d) The total number of attributes in a table
2. What is the need for a database? 16. Which of the following is NOT a characteristic of
a) To store data permanently a primary key?
b) To reduce redundancy a) It must be unique
c) To allow data sharing d) All of the above b) It can have NULL values
3. Which of the following is an example of a Database c) It must uniquely identify a record
Management System (DBMS)? d) It is selected from candidate keys
a) MS Word b) MS Excel 17. Which of the following is a valid example of a
c) MySQL d) Google Chrome primary key?
4. What does RDBMS stand for? a) A student's roll number b) A student's age
a) Rational Database Management System c) A student's height d) A student's weight
b) Relational Database Management System 18. In a relational database, a relation is a:
c) Relevant Data-Based Management Software a) Table b) Column c) Row d) Data type
d) Remote Database Management System 19. Which key is used to establish a connection
5. In a relational database, a table is also called a: between two tables?
a) Relation b) Tuple c) Attribute d) Domain a) Primary key b) Candidate key
6. A row in a relational table is called: c) Foreign key d) Composite key
a) Relation b) Attribute c) Tuple d) Domain 20. The process of dividing a large table into multiple
7. A column in a relational table is called: smaller tables to reduce redundancy is called:
a) Relation b) Attribute c) Tuple d) Domain a) Normalization b) Indexing
8. The total number of rows in a table is called: c) Aggregation d) Query Processing
a) Degree b) Cardinality c) Domain d) Relation 21. Which of the following keys can contain NULL
9. The total number of columns in a table is called: values?
a) Degree b) Cardinality c) Domain d) Attribute a) Primary key b) Candidate key
10. A candidate key is: c) Foreign key d) Alternate key
a) A key that can uniquely identify each record in a table 22. A composite key is a key that:
b) A key that is selected as the primary key a) Consists of multiple attributes
c) A key that cannot be used as a primary key b) Is a candidate key c) Contains only numeric values
d) A key that contains duplicate values d) Is used in indexing
11. A primary key: 23. What is the main purpose of a database?
a) Can have NULL values a) To store large amounts of data in a structured manner
b) Can have duplicate values b) To process data faster than a spreadsheet
c) Is a candidate key selected to uniquely identify c) To create graphical reports
records d) To execute programming languages
d) Is a combination of all attributes 24. What is the difference between a relational
12. An alternate key is: database and a non-relational database?
a) Another name for a primary key a) Relational databases use structured tables, non-
b) A candidate key that is not selected as the primary relational databases use flexible data models
key b) Relational databases are faster than non-relational
c) A key that contains duplicate values databases
d) A key used for foreign key reference c) Relational databases do not use keys, non-relational
13. A foreign key is used to: databases do
a) Identify records uniquely in the same table d) Non-relational databases are always preferred over
b) Establish a relationship between two tables relational databases
c) Perform calculations on data 25. Which SQL statement is used to define a primary
d) Sort data key?
14. A foreign key references: a) ALTER TABLE ADD PRIMARY KEY
a) A primary key in the same table b) DEFINE PRIMARY KEY
b) A primary key in another table c) SET PRIMARY KEY
c) A unique key in the same table d) CREATE PRIMARY KEY
d) A candidate key in another table
DBMS True/False statements
Page 12 of 14 EDUCATION FOR EVERYONE
Mr. Gajendra Sharma CS/IP Mo.NO.: 9810301034
1. A database is a structured collection of related data.
2. A database is required only for large-scale applications.
3. A relational database organizes data in the form of tables.
4. In a relational model, a table is also called a relation.
5. A tuple in a relational database refers to a column in a table.
6. An attribute in a relational database is a column in a table.
7. The domain of an attribute defines the set of all possible values it can take.
8. The total number of rows in a table is called the degree of the table.
9. The total number of columns in a table is called its cardinality.
10. A primary key can have duplicate values.
11. A candidate key is a set of one or more attributes that can uniquely identify a record.
12. A table can have multiple candidate keys.
13. A primary key is a candidate key that is selected to uniquely identify records in a table.
14. An alternate key is a candidate key that has been chosen as the primary key.
15. A foreign key is used to establish relationships between two tables.
16. A foreign key must always refer to a primary key in another table.
17. A foreign key can contain NULL values.
18. A primary key can have NULL values.
19. The domain of an attribute is the total number of attributes in a table.
20. The relational data model is based on the concept of records and pointers.
21. A table can have only one primary key.
22. A database management system (DBMS) is software used to create and manage databases.
23. A relational database does not support relationships between tables.
24. The process of organizing data to reduce redundancy is called normalization.
25. A single attribute can be part of multiple candidate keys in a table.
MCQ Answers:
Page 13 of 14 EDUCATION FOR EVERYONE
Mr. Gajendra Sharma CS/IP Mo.NO.: 9810301034
1. b) A collection of related data , a) A collection 13. b) Establish a relationship between two tables
of tables 14. b) A primary key in another table
2. d) All of the above 15. b) The set of all possible values an attribute can
3. c) MySQL take
4. b) Relational Database Management System 16. b) It can have NULL values
5. a) Relation 17. a) A student's roll number
6. c) Tuple 18. a) Table
7. b) Attribute 19. c) Foreign key
8. b) Cardinality 20. a) Normalization
9. a) Degree 21. c) Foreign key
10. a) A key that can uniquely identify each record 22. a) Consists of multiple attributes
in a table 23. a) To store large amounts of data in a
11. c) Is a candidate key selected to uniquely structured manner
identify records 24. a) Relational databases use structured tables,
12. b) A candidate key that is not selected as the non-relational databases use flexible data models
primary key 25. a) ALTER TABLE ADD PRIMARY KEY
1. Database
2. Relation 10. Alternate Key 18. Composite Key
3. Tuple 11. Foreign Key 19. Redundancy
4. Attribute 12. Foreign Key 20. Schema
5. Domain 13. Normalization 21. Indexing
6. Degree 14. Data Integrity 22. Tuple
7. Cardinality 15. Not Null 23. SQL
8. Primary Key 16. Referential Integrity 24. Constraints
9. Candidate Key 17. Candidate Key 25. Relational Database