0% found this document useful (0 votes)
15 views

dbms material

Uploaded by

nadeem shaik
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

dbms material

Uploaded by

nadeem shaik
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 40

DBMS

4 MARKS:

1) EXPLAIN ABOUT THE CLASSIFICATION OF DBMS.

Database Management Systems (DBMS) can be classified based on several criteria, including the data
model they use, the number of users they support, the types of databases they manage, and the architecture
they follow. Here's a breakdown of the primary classifications:

Based on Data Model

o Hierarchical DBMS:
o Data is organized in a tree-like structure.
o Each record has a single parent, but may have multiple children.
o Example: IBM's Information Management System (IMS).
o Network DBMS:
o Similar to hierarchical DBMS, but allows many-to-many relationships.
o Data is represented as a graph, where entities are nodes and relationships are edges.
o Example: Integrated Data Store (IDS).
o Relational DBMS (RDBMS):
o Data is organized in tables (relations) with rows and columns.
o Uses SQL for querying and maintaining the database.
o Example: MySQL, PostgreSQL, Oracle, SQL Server.
o Object-oriented DBMS (OODBMS):
o Data is represented in the form of objects, similar to object-oriented programming.
o Supports complex data types and object identity.
o Example: ObjectDB, db4o.
o Object-relational DBMS (ORDBMS):
o Combines features of both RDBMS and OODBMS.
o Extends the relational model to support complex data types.
o Example: PostgreSQL, Oracle.

Based on Number of Users

o Single-user DBMS:
o Supports one user at a time.
o Typically used on personal computers.
o Example: Microsoft Access.
o Multi-user DBMS:
o Supports multiple users simultaneously.
o Used in larger systems like enterprise environments.
o Example: MySQL, Oracle, SQL Server.

Based on Database Distribution

o Centralized DBMS:
o All data is stored and managed on a single central server.
o Accessed via network by multiple users.
o Example: IBM DB2.
o Distributed DBMS (DDBMS):
o Data is distributed across multiple physical locations.
o Appears as a single database to users.
o Example: Apache Cassandra, Google Cloud Spanner.
o Federated DBMS:
o Integrates multiple autonomous databases into a single federated database.
o Each constituent database remains independent.
o Example: Microsoft Access with linked tables from SQL Server.

Based on Architecture

o Single-tier Architecture:
o Also known as monolithic architecture.
o The database is directly accessible to the end user.
o Two-tier Architecture:
o Client-server architecture.
o Client application interacts with the server DBMS.
o Three-tier Architecture:
o Adds a middle layer between client and server.
o Middle tier includes application or web server.
o Example: Web applications using a web server, an application server, and a database server.

Based on Use Cases

o Transaction Processing DBMS:


o Optimized for transaction processing.
o Ensures ACID properties (Atomicity, Consistency, Isolation, Durability).
o Example: SQL Server, Oracle.
o Analytical DBMS:
o Optimized for analytical processing and reporting.
o Typically used in data warehousing.
o Example: Amazon Redshift, Google BigQuery.

2) WHAT IS THE DIFFERENCE BETWEEN DATA AND INFORMATION.

Difference between Information and Data


S.NO DATA INFORMATION

Definition Data is defined as unstructured Information refers to


information such as text, processed, organized, and
observations, images, symbols, structured data. It gives
S.NO DATA INFORMATION

context for the facts and


and descriptions. In other words,
facilitates decision making. In
data provides no specific
other words, information is
function and has no meaning on
processed data that makes
its own.
sense to us.

Purpose Data are the variables that help


Information is meaningful data.
to develop ideas/conclusions.

Nature Data are text and numerical Information is refined form of


values. actual data.

Dependence While Information relies on


Data doesn’t rely on Information.
Data.

Measuremen Information is measured in


Bits and Bytes are the measuring
t meaningful units like time,
unit of data.
quantity, etc.

Structure Information can also be


As tabular data, graphs, and data
structured as language, ideas,
trees can be easily structured.
and thoughts.

Purposefuln Information carries a meaning


Data does not have any specific
ess that has been assigned by
purpose
interpreting data.

Knowledge It is the second level of


It is low-level knowledge.
Level knowledge.

Decision Data does not directly help in Information directly helps in


Making decision making. decision making.

Meaning Data is a collection of facts, Information puts those facts


which itself has no meaning. into context.

Example Example of information is


Example of data is student test
average score of class that is
scores.
derived from given data.
Examples of Data vs. Information
Data Example
 Temperature Readings: Numbers representing temperature throughout
the day, such as “72°F”, “68°F”, “75°F”.
 Student Grades: A list of numerical scores obtained by students on a test, like
“85”, “92”, “78”.
 Stock Prices: Daily closing prices of a company’s stock, such as “$50.25”,
“$48.90”, “$52.10”.
Information Example
 Weather Report: Based on the temperature reading a weather report can be
generated.
 Grade Average: Based on the student grades, the average grade of class can be
derived.
 Market Analysis: The stock market showed a slight increase today derived from
stock prices.

3) WRITE ABOUT BUILDING BLOCKS OF ENTITY RELATIONSHIP


DIAGRAM.

ER (Entity Relationship) Diagram in DBMS


o ER model stands for an Entity-Relationship model. It is a high-level data model.
This model is used to define the data elements and relationship for a specified
system.
o It develops a conceptual design for the database. It also develops a very simple
and easy to design view of data.
o In ER modeling, the database structure is portrayed as a diagram called an
entity-relationship diagram.
For example, Suppose we design a school database. In this database, the student will be an
entity with attributes like address, name, id, age, etc. The address can be another entity with
attributes like city, street name, pin code, etc and there will be a relationship between them.
Component of ER Diagram
1. Entity:
An entity may be any object, class, person or place. In the ER diagram, an entity can be
represented as rectangles.

Consider an organization as an example- manager, product, employee, department etc. can


be taken as an entity.

a. Weak Entity
An entity that depends on another entity called a weak entity. The weak entity doesn't
contain any key attribute of its own. The weak entity is represented by a double rectangle.

2. Attribute
The attribute is used to describe the property of an entity. Eclipse is used to represent an
attribute.

For example, id, age, contact number, name, etc. can be attributes of a student.

a. Key Attribute

The key attribute is used to represent the main characteristics of an entity. It represents a
primary key. The key attribute is represented by an ellipse with the text underlined.
b. Composite Attribute

An attribute that composed of many other attributes is known as a composite attribute. The
composite attribute is represented by an ellipse, and those ellipses are connected with an
ellipse.

c. Multivalued Attribute

An attribute can have more than one value. These attributes are known as a multivalued
attribute. The double oval is used to represent multivalued attribute.

For example, a student can have more than one phone number.
d. Derived Attribute

An attribute that can be derived from other attribute is known as a derived attribute. It can
be represented by a dashed ellipse.

For example, A person's age changes over time and can be derived from another attribute
like Date of birth.

3. Relationship
A relationship is used to describe the relation between entities. Diamond or rhombus is used
to represent the relationship.

Types of relationship are as follows:


a. One-to-One Relationship

When only one instance of an entity is associated with the relationship, then it is known as
one to one relationship.

For example, A female can marry to one male, and a male can marry to one female.

Advertisement
b. One-to-many relationship

When only one instance of the entity on the left, and more than one instance of an entity on
the right associates with the relationship then this is known as a one-to-many relationship.

For example, Scientist can invent many inventions, but the invention is done by the only
specific scientist.

c. Many-to-one relationship

When more than one instance of the entity on the left, and only one instance of an entity on
the right associates with the relationship then it is known as a many-to-one relationship.

For example, Student enrolls for only one course, but a course can have many students.

d. Many-to-many relationship
When more than one instance of the entity on the left, and more than one instance of an
entity on the right associates with the relationship then it is known as a many-to-many
relationship.

For example, Employee can assign by many projects and project can have many
employees.

ER (Entity Relationship) Diagram in DBMS


o ER model stands for an Entity-Relationship model. It is a high-level data model.
This model is used to define the data elements and relationship for a specified
system.
o It develops a conceptual design for the database. It also develops a very simple
and easy to design view of data.
o In ER modeling, the database structure is portrayed as a diagram called an
entity-relationship diagram.
For example, Suppose we design a school database. In this database, the student will be an
entity with attributes like address, name, id, age, etc. The address can be another entity with
attributes like city, street name, pin code, etc and there will be a relationship between them.

Component of ER Diagram
1. Entity:
An entity may be any object, class, person or place. In the ER diagram, an entity can be
represented as rectangles.

Consider an organization as an example- manager, product, employee, department etc. can


be taken as an entity.

a. Weak Entity
An entity that depends on another entity called a weak entity. The weak entity doesn't
contain any key attribute of its own. The weak entity is represented by a double rectangle.

2. Attribute
The attribute is used to describe the property of an entity. Eclipse is used to represent an
attribute.

For example, id, age, contact number, name, etc. can be attributes of a student.

a. Key Attribute

The key attribute is used to represent the main characteristics of an entity. It represents a
primary key. The key attribute is represented by an ellipse with the text underlined.
b. Composite Attribute

An attribute that composed of many other attributes is known as a composite attribute. The
composite attribute is represented by an ellipse, and those ellipses are connected with an
ellipse.

c. Multivalued Attribute

An attribute can have more than one value. These attributes are known as a multivalued
attribute. The double oval is used to represent multivalued attribute.

For example, a student can have more than one phone number.
d. Derived Attribute

An attribute that can be derived from other attribute is known as a derived attribute. It can
be represented by a dashed ellipse.

For example, A person's age changes over time and can be derived from another attribute
like Date of birth.

3. Relationship
A relationship is used to describe the relation between entities. Diamond or rhombus is used
to represent the relationship.

Types of relationship are as follows:


a. One-to-One Relationship

When only one instance of an entity is associated with the relationship, then it is known as
one to one relationship.

For example, A female can marry to one male, and a male can marry to one female.

Advertisement
b. One-to-many relationship

When only one instance of the entity on the left, and more than one instance of an entity on
the right associates with the relationship then this is known as a one-to-many relationship.

For example, Scientist can invent many inventions, but the invention is done by the only
specific scientist.

c. Many-to-one relationship

When more than one instance of the entity on the left, and only one instance of an entity on
the right associates with the relationship then it is known as a many-to-one relationship.

For example, Student enrolls for only one course, but a course can have many students.

d. Many-to-many relationship
When more than one instance of the entity on the left, and more than one instance of an
entity on the right associates with the relationship then it is known as a many-to-many
relationship.

For example, Employee can assign by many projects and project can have many
employees.

4) WHAT IS KEY ? EXPLAIN ABOUT VARIOUS TYPES OF KEYS.

Concept of keys:
 A key in DBMS is an attribute or a set of attributes that help to uniquely identify a tuple (or row) in
a relation (or table).
 Keys are also used to establish relationships between the different tables and columns of a relational
database.
 Individual values in a key are called key values.
 A key could either be a combination of more than one attribute (or columns) or just a single
attribute.
 The main motive of this is to give each record a unique identity.
Different Types Of Keys in DBMS-
There are following 10 important keys in DBMS-
1. Super key
2. Candidate key
3. Primary key
4. Alternate key
5. Foreign key
6. Partial key
7. Composite key
8. Unique key
9. Surrogate key
10. Secondary key
1. Super Key-
 A super key is a set of attributes that can identify each tuple uniquely in the given relation.
 A super key is not restricted to have any specific number of attributes.
 Thus, a super key may consist of any number of attributes.

Example-
Consider the following Student schema-
Student ( roll , name , sex , age , address , class , section )

Given below are the examples of super keys since each set can uniquely identify each student in the
Student table-
 ( roll , name , sex , age , address , class , section )
 ( class , section , roll )
 (class , section , roll , sex )
 ( name , address )

NOTE-
All the attributes in a super key are definitely sufficient to identify each tuple uniquely in the given
relation but all of them may not be necessary.

2. Candidate Key-
A set of minimal attribute(s) that can identify each tuple uniquely in the given relation is called as a
candidate key.

Example-
Consider the following Student schema-
Student ( roll , name , sex , age , address , class , section )

Given below are the examples of candidate keys since each set consists of minimal attributes
required to identify each student uniquely in the Student table-
 ( class , section , roll )
 ( name , address )

NOTES-
 All the attributes in a candidate key are sufficient as well as necessary to identify each tuple
uniquely.
 Removing any attribute from the candidate key fails in identifying each tuple uniquely.
 The value of candidate key must always be unique.
 The value of candidate key can never be NULL.
 It is possible to have multiple candidate keys in a relation.
 Those attributes which appears in some candidate key are called as prime attributes.

3. Primary Key-
A primary key is a candidate key that the database designer selects while designing the database.
OR
Candidate key that the database designer implements is called as a primary key.

NOTES-
 The value of primary key can never be NULL.
 The value of primary key must always be unique.
 The values of primary key can never be changed i.e. no updation is possible.
 The value of primary key must be assigned when inserting a record.
 A relation is allowed to have only one primary key.

Remember-
4. Alternate Key-
Candidate keys that are left unimplemented or unused after implementing the primary key are called
as alternate keys.
OR
Unimplemented candidate keys are called as alternate keys.

5. Foreign Key-
 An attribute ‘X’ is called as a foreign key to some other attribute ‘Y’ when its values are dependent
on the values of attribute ‘Y’.
 The attribute ‘X’ can assume only those values which are assumed by the attribute ‘Y’.
 Here, the relation in which attribute ‘Y’ is present is called as the referenced relation.
 The relation in which attribute ‘X’ is present is called as the referencing relation.
 The attribute ‘Y’ might be present in the same table or in some other table.

Example-
Consider the following two schemas-
Here, t_dept can take only those values which are present in dept_no in Department table since only
those departments actually exist.

NOTES-
 Foreign key references the primary key of the table.
 Foreign key can take only those values which are present in the primary key of the referenced
relation.
 Foreign key may have a name other than that of a primary key.
 Foreign key can take the NULL value.
 There is no restriction on a foreign key to be unique.
 In fact, foreign key is not unique most of the time.
 Referenced relation may also be called as the master table or primary table.
 Referencing relation may also be called as the foreign table.

6. Partial Key-
 Partial key is a key using which all the records of the table can not be identified uniquely.
 However, a bunch of related tuples can be selected from the table using the partial key.

Example-
Consider the following schema-
Department ( Emp_no , Dependent_name , Relation )

Emp_no Dependent_name Relation

E1 Suman Mother

E1 Ajay Father

E2 Vijay Father

E2 Ankush Son

Here, using partial key Emp_no, we can not identify a tuple uniquely but we can select a bunch of
tuples from the table.

7. Composite Key-
A primary key comprising of multiple attributes and not just a single attribute is called as a composite
key.

8. Unique Key-
Unique key is a key with the following properties-
 It is unique for all the records of the table.
 Once assigned, its value can not be changed i.e. it is non-updatable.
 It may have a NULL value.

Example-
The best example of unique key is Adhaar Card Numbers.
 The Adhaar Card Number is unique for all the citizens (tuples) of India (table).
 If it gets lost and another duplicate copy is issued, then the duplicate copy always has the same
number as before.
 Thus, it is non-updatable.
 Few citizens may not have got their Adhaar cards, so for them its value is NULL.

9. Surrogate Key-
Surrogate key is a key with the following properties-
 It is unique for all the records of the table.
 It is updatable.
 It can not be NULL i.e. it must have some value.

Example-
Mobile Number of students in a class where every student owns a mobile phone.

10. Secondary Key-


Secondary key is required for the indexing purpose for better and faster searching.

5) EXPLAIN ABOUT SUB QUERIES IN SQL.

SQL Subqueries
An SQL Subquery, is a SELECT query within another query. It is also known as Inner
query or Nested query and the query containing it is the outer query.

The outer query can contain the SELECT, INSERT, UPDATE, and DELETE statements. We can
use the subquery as a column expression, as a condition in SQL clauses, and with operators
like =, >, <, >=, <=, IN, BETWEEN, etc.

Rules to be followed
Following are the rules to be followed while writing subqueries −
 Subqueries must be enclosed within parentheses.

 Subqueries can be nested within another subquery.

 A subquery must contain the SELECT query and the FROM clause always.

 A subquery consists of all the clauses an ordinary SELECT clause can contain: GROUP BY,
WHERE, HAVING, DISTINCT, TOP/LIMIT, etc. However, an ORDER BY clause is only used
when a TOP clause is specified. It can't include COMPUTE or FOR BROWSE clause.

 A subquery can return a single value, a single row, a single column, or a whole table.
They are called scalar subqueries.

Learn SQL in-depth with real-world projects through our SQL certification course. Enroll
and become a certified expert to boost your career.

Subqueries with the SELECT Statement


Subqueries are most frequently used with the SELECT statement. The basic syntax is as
follows −

SELECT column_name [, column_name ] FROM table1 [, table2 ] WHERE column_name


OPERATOR (SELECT column_name [,column_name ] FROM table1 [, table2 ] [WHERE]);

Example
In the following query, we are creating a table named CUSTOMERS −

Open Compiler

CREATE TABLE CUSTOMERS (


ID INT NOT NULL,
NAME VARCHAR(20) NOT NULL,
AGE INT NOT NULL,
ADDRESS CHAR (25),
SALARY DECIMAL (18, 2),
PRIMARY KEY (ID));
Here, we are inserting records into the above-created table using INSERT INTO statement −

Open Compiler

INSERT INTO CUSTOMERS VALUES (1, 'Ramesh', 32, 'Ahmedabad', 2000.00),(2,


'Khilan', 25, 'Delhi', 1500.00),(3, 'Kaushik', 23, 'Kota', 2000.00),(4,
'Chaitali', 25, 'Mumbai', 6500.00),(5, 'Hardik', 27, 'Bhopal', 8500.00),(6,
'Komal', 22, 'Hyderabad', 4500.00),(7, 'Muffy', 24, 'Indore', 10000.00);

The table is displayed as −

ID NAME AGE ADDRESS SALARY

1 Ramesh 32 Ahmedabad 2000.00

2 Khilan 25 Delhi 1500.00

3 kaushik 23 Kota 2000.00

4 Chaitali 25 Mumbai 6500.00

5 Hardik 27 Bhopal 8500.00

6 Komal 22 Hyderabad 4500.00

7 Muffy 24 Indore 10000.00

Now, let us check the following subquery with a SELECT statement.

Open Compiler

SELECT * FROM CUSTOMERS WHERE ID IN (SELECT ID FROM CUSTOMERS WHERE SALARY >
4500);

This would produce the following result −

ID NAME AGE ADDRESS SALARY

4 Chaitali 25 Mumbai 6500.00

5 Hardik 27 Bhopal 8500.00

7 Muffy 24 Indore 10000.00


Subqueries with the INSERT Statement
We can also use the subqueries along with the INSERT statements. The data returned by the
subquery is inserted into another table.

The basic syntax is as follows −

INSERT INTO table_name [ (column1 [, column2 ]) ]


SELECT [ *|column1 [, column2 ] FROM table1 [, table2 ]
[ WHERE VALUE OPERATOR ]

Example
In the following example, we are creating another table CUSTOMERS_BKP with similar
structure as CUSTOMERS table −

Open Compiler

CREATE TABLE CUSTOMERS_BKP (


ID INT NOT NULL,
NAME VARCHAR(20) NOT NULL,
AGE INT NOT NULL,
ADDRESS CHAR (25),
SALARY DECIMAL (18, 2),
PRIMARY KEY (ID));

Now to copy the complete records of CUSTOMERS table into the CUSTOMERS_BKP table, we
can use the following query −

Open Compiler

INSERT INTO CUSTOMERS_BKP SELECT * FROM CUSTOMERS WHERE ID IN (SELECT ID FROM


CUSTOMERS);

The above query produces the following output −

Query OK, 7 rows affected (0.01 sec)


Records: 7 Duplicates: 0 Warnings: 0

Verification
Using the SELECT statement, we can verify whether the records from CUSTOMERS table
have been inserted into CUSTOMERS_BKP table or not −
Open Compiler

SELECT * FROM CUSTOMERS_BKP;

The table will be displayed as −

ID NAME AGE ADDRESS SALARY

1 Ramesh 32 Ahmedabad 2000.00

2 Khilan 25 Delhi 1500.00

3 kaushik 23 Kota 2000.00

4 Chaitali 25 Mumbai 6500.00

5 Hardik 27 Bhopal 8500.00

6 Komal 22 Hyderabad 4500.00

7 Muffy 24 Indore 10000.00

Subqueries with the UPDATE Statement


A subquery can also be used with the UPDATE statement. You can update single or multiple
columns in a table using a subquery.

The basic syntax is as follows −

UPDATE table SET column_name = new_value [WHERE OPERATOR [VALUE](SELECT


COLUMN_NAME FROM TABLE_NAME [WHERE]);

Example
We have the CUSTOMERS_BKP table available which is backup of CUSTOMERS table. The
following example updates SALARY by 0.25 times in the CUSTOMERS table for all the
customers whose AGE is greater than or equal to 27.

Open Compiler

UPDATE CUSTOMERS SET SALARY = SALARY * 0.25 WHERE AGE IN (SELECT AGE FROM
CUSTOMERS_BKP WHERE AGE >= 27 );

Following is the output of the above query −


Query OK, 2 rows affected (0.01 sec)
Rows matched: 2 Changed: 2 Warnings: 0

Verification
This would impact two rows and if you verify the contents of the CUSTOMERS using the
SELECT statement as shown below.

Open Compiler

SELECT * FROM CUSTOMERS;

The table will be displayed as −

ID NAME AGE ADDRESS SALARY

1 Ramesh 32 Ahmedabad 500.00

2 Khilan 25 Delhi 1500.00

3 kaushik 23 Kota 2000.00

4 Chaitali 25 Mumbai 6500.00

5 Hardik 27 Bhopal 2125.00

6 Komal 22 Hyderabad 4500.00

7 Muffy 24 Indore 10000.00

Subqueries with the DELETE Statement


The subquery can be used with the DELETE statement as well; like with any other
statements mentioned above.

The basic syntax is as follows −

DELETE FROM TABLE_NAME[WHERE OPERATOR [ VALUE ](SELECT COLUMN_NAME FROM


TABLE_NAME)[WHERE)];

Example
We have a CUSTOMERS_BKP table available which is a backup of the CUSTOMERS table. The
following example deletes the records from the CUSTOMERS table for all the customers
whose AGE is greater than or equal to 27.

Open Compiler

DELETE FROM CUSTOMERS WHERE AGE IN (SELECT AGE FROM CUSTOMERS_BKP WHERE AGE >= 27
);

The above query generate the following output −

OK, 2 rows affected (0.01 sec)

Verification
If you verify the contents of the CUSTOMERS table using the SELECT statement as shown
below.

Open Compiler

SELECT * FROM CUSTOMERS;

The table will be displayed as −

ID NAME AGE ADDRESS SALARY

2 Khilan 25 Delhi 1500.00

3 kaushik 23 Kota 2000.00

4 Chaitali 25 Mumbai 6500.00

6 Komal 22 Hyderabad 4500.00

7 Muffy 24 Indore 10000.00

6) EXPLAIN ABOUT AGGREGATE FUNCTIONS IN SQL.

SQL Aggregate Functions


An aggregate function is a function that performs a calculation on a set of values, and
returns a single value.
Aggregate functions are often used with the GROUP BY clause of the SELECT statement.
The GROUP BY clause splits the result-set into groups of values and the aggregate function
can be used to return a single value for each group.

The most commonly used SQL aggregate functions are:

 MIN() - returns the smallest value within the selected column


 MAX() - returns the largest value within the selected column
 COUNT() - returns the number of rows in a set
 SUM() - returns the total sum of a numerical column
 AVG() - returns the average value of a numerical column

Aggregate functions ignore null values (except for COUNT()).

7) EXPLAIN DATA TYPES IN PL/SQL.

PL/SQL NUMBER Data Type


This data type stores fixed or floating point numbers up to 38 digits of precision. This
data type is used to work with fields which will contain only number data. The
variable can be declared either with precision and decimal digit details or without
this information. Values need not enclose within quotes while assigning for this data
type.

A NUMBER(8,2);
B NUMBER(8);
C NUMBER;

PL/SQL CHARACTER Data Type


This data type basically stores alphanumeric characters in string format.
The literal values should always be enclosed in single quotes while assigning them to
CHARACTER data type.
This character data type is further classified as follows:
 CHAR Data type (fixed string size)
 VARCHAR2 Data type (variable string size)
 VARCHAR Data type
 NCHAR (native fixed string size)
 NVARCHAR2 (native variable string size)
 LONG and LONG RAW
PL/SQL BOOLEAN Data Type
This data type stores the logical values. Oracle Boolean Data Type represents either
TRUE or FALSE and mainly used in conditional statements. Values need not enclose
within quotes while assigning for this data type.
Var1 BOOLEAN;

PL/SQL DATE Data Type


This data type stores the values in date format, as date, month, and year. Whenever
a variable is defined with DATE data type along with the date it can hold time
information and by default time information is set to 12:00:00 if not specified. Values
need to enclose within quotes while assigning for this data type.
The standard Oracle time format for input and output is ‘DD-MON-YY’ and it is again
set at NLS_PARAMETERS (NLS_DATE_FORMAT) at the session level.
newyear DATE:='01-JAN-2015';
current_date DATE:=SYSDATE;

PL/SQL LOB Data Type


This data type is mainly used to store and manipulate large blocks of unstructured
data’s like images, multimedia files, etc. Oracle prefers LOB instead of the a LONG
data type as it is more flexible than the LONG data type. The below are the few main
advantage of LOB over LONG data type.

8 MARKS:=

1) EXPLAIN ABOUT THE COMPONENTS OF DBMS.


A Database Management System (DBMS) is a software suite designed to define, manipulate, retrieve, and
manage data in databases. It has several core components, each serving specific functions to ensure
efficient data management. Let's dive into these components:
1. Database Engine
 Function: Acts as the core service for accessing and processing data.
 Responsibilities: Manages database storage, data retrieval, and processing of queries.
2. Database Schema
 Function: Defines the logical structure of the data.
 Responsibilities: Includes definitions of tables, columns, data types, relationships, and constraints.
3. Query Processor
 Function: Translates SQL commands into a series of low-level instructions.
 Responsibilities: Parses, validates, and optimizes queries for execution.
4. Transaction Management
 Function: Ensures data integrity and consistency.
 Responsibilities: Manages transactions, providing ACID properties (Atomicity, Consistency,
Isolation, Durability).
5. Storage Manager
 Function: Manages how data is stored in physical storage.
 Responsibilities: Handles data storage, indexing, and data compression.
6. Metadata Manager
 Function: Manages metadata, which is data about data.
 Responsibilities: Stores information about the database structure, such as schemas and indexes.
7. Security Manager
 Function: Provides access control to the database.
 Responsibilities: Manages user authentication, authorization, and implements security policies.
8. Concurrency Control
 Function: Manages simultaneous data access by multiple users.
 Responsibilities: Prevents data conflicts and ensures consistent transaction outcomes.
9. Backup and Recovery
 Function: Ensures data safety and integrity.
 Responsibilities: Manages data backup procedures and recovery processes in case of data loss or
corruption.
10. User Interface
 Function: Provides an interface for users to interact with the database.
 Responsibilities: Includes command-line interfaces, graphical user interfaces (GUIs), and API
endpoints for application integration.
11. Report Generation
 Function: Allows for data analysis and reporting.
 Responsibilities: Helps generate reports based on data queries and analysis.
Example of DBMS Software
 MySQL: Open-source relational database management system.
 PostgreSQL: Advanced open-source object-relational database system.
 Oracle Database: Comprehensive database management software known for scalability and
robustness.
 Microsoft SQL Server: Relational database management system developed by Microsoft.
 MongoDB: NoSQL database known for its scalability and flexibility.
2) EXPLAIN ABOUT DIFFERENT TYPES OF DATA MODELS.

Data Models in DBMS: 11 types of Data Models


with Diagram
1. Flat data model
2. Entity relationship model
3. Relation model
4. Record base model
5. Network model
6. Hierarchical model
7. Object oriented data model
8. Object relation model
9. Semi structured model
10. Associative model
11. Contex data model
Let us explain all these types of data models in DBMS with diagram.

Flat Data Model


Flat data model is the first and foremost introduced model and in this all the data used is
kept in the same plane. Since it was used earlier this model was not so scientific.

Flat Data
Model

Entity Relationship Data Model


Entity relationship model is based on the notion of the real world entities and their
relationships. While formulating the real world scenario in to the database model an entity
set is created and this model is dependent on two vital things and they are :

 Entity and their attributes


 Relationships among entities
Entity
Relationship Model

An entity has a real world property called attribute and attribute define by a set of values
called domain. For example, in a university a student is an entity, university is the database,
name and age and sex are the attributes. The relationships among entities define the logical
association between entities.

Relational Data Model


Relational model is the most popular model and the most extensively used model. In this
model the data can be stored in the tables and this storing is called as relation, the relations
can be normalized and the normalized relation values are called atomic values. Each row in a
relation contains unique value and it is called as tuple, each column contains value from
same domain and it is called as attribute.
Relational Model

Network Data Model


Network model has the entities which are organized in a graphical representation and some
entities in the graph can be accessed through several paths.

Network Model

Hierarchical Data Model


Hierarchical model has one parent entity with several children entity but at the top we
should have only one entity called root. For example, department is the parent entity called
root and it has several children entities like students, professors and many more.
Hierarchical model

Object oriented Data Model


Object oriented data model is one of the developed data model and this can hold the audio,
video and graphic files. These consist of data piece and the methods which are the DBMS
instructions.

Object Oriented Data Model

Record base Data Model


Record base model is used to specify the overall structure of the database and in this there
are many record types. Each record type has fixed no. of fields having the fixed length.

Object relation Data Model


Object relation model is a very powerful model but coming to it’s design it is quiet complex.
This complexity is not problem because it gives efficient results and widespread with huge
applications. It has a feature which allows working with other models like working with the
very known relation model.

Semi structured Data Model


Semi structured data model is a self describing data model, in this the information that is
normally associated with a scheme is contained within the data and this property is called as
the self describing property.

Associative Data Model


Associative model has a division property, this divides the real world things about which data
is to be recorded in two sorts i.e. between entities and associations. Thus, this model does
the division for dividing the real world data to the entities and associations.

Context Data Model


Context data model is a flexible model because it is a collection of many data models. It is a
collection of the data models like object oriented data model, network model, semi
structured model. So, in this different types of works can be done due to the versatility of it.

Context
Model

Therefore, this support different types of users and differ by the interaction of users in
database and also the data models in DBMS brought a revolutionary change in industries by
the handling of relevant data. The data models in DBMS are the systems that help to use and
create databases, as we have seen there are different types of data models and depending
on the kind of structure needed we can select the data model in DBMS.

3) WHAT IS ATTRIBUTE ? EXPLAIN ABOUT CLASSIFICATION OF


ATTRIBUTE.
In the context of a Database Management System (DBMS), an attribute is a
characteristic or property of an entity. It represents a piece of data or a field in a
table. For instance, in a table representing students, attributes might include
StudentID, Name, Age, and Course.
Attributes are the properties which describe an entity.

Example

The attributes of student entity are as follows −

 Roll number
 Name
 Branch
 Age

 Types of attributes
The different types of attributes are as follows −

Composite attribute

It can be divided into smaller sub parts, each sub part can form an independent attribute.

For example −

Name
FirstName MiddelName LastName

Simple or Atomic attribute

Attributes that cannot be further subdivided are called atomic attributes.

For example −

Phone number
PIN code
Single valued Attribute

Attributes having a single value for a particular item is called a single valued attribute.

For example: Room Number

Multi-valued Attribute

Attribute having a set of values for a single entity is called a multi-valued attribute.

For example −

e-mail
Tel.No
Hobbies
Derived Attributes or stored Attributes

When one attribute value is derived from the other is called a derived attribute.

For example: Age can be derived from date of birth, where,


Age is the derived attribute.


DOB is the stored attribute.

Complex Attribute

Nesting of composite and multi-valued attributes forms a complex attribute.

For example
If a person has more than one house and each house has more than one phone. Then, that
attribute phone is represented as a complex attribute.

You might also like