Notes
Notes
UNIT 1
DATA IN FORMATION AND INFORMATION PROCESSING
INTRODUCTION:
Data processing means to process the data i.e. to convert its format. As we all know data is
the very useful and when it is well presented and it becomes informative + useful. Data
processing system is also referred as information system. It is also right to say that data
processing becomes the process of converting information into data and also vice-versa.
DEFINITION OF INFORMATION
What is information?
Information is stimuli that has meaning in some context for its receiver. When information is
entered into and stored in a computer, it is generally referred to as data. After processing --
such as formatting and printing -- output data can again be perceived as information. When
information is compiled or used to better understand something or to do something, it
becomes knowledge.
The discrete, raw facts about a given situation with no analysis or interpretation applied.
Applying description and meaning to data to make it useful.
Information that has insight, context and a frame of reference applied so it can be
interpreted.
Knowledge is converted into wisdom by applying judgment and action to the information.
QUALITY OF INFORMATION
Information Processing :
Business software
Computers
Operating systems
Mainframes
Networks
Whenever the information and data need to be managed or transferred, the method is then
known as information processing. The processor first processes the information and later
provides understandable results.
1. Accurate
If the information is accurate, it will have a direct impact on the decision-making process.
Hence it is essential to remove any possibility of errors
2. Timely
The information must be available as per the need of the hour because a delay in obtaining it
can make the information useless
3. Complete
The information has no meaning until and unless it is finished because incomplete data and
information can lead to incorrect results
4. Comprehensive
Only comprehensive information is useful, and if it is not so then it is considered useless for
the receiver and thus has no real meaning and worth The concept of information processing
has been in existence for a very long time. Governments and business entities used to process
a large amount of information from the gathered data.
In the current scenario, the capability to process information has reached new heights and
gigantic proportions. It is possible to process trillions of bytes every minute by an equal
number of devices, satellites and software applications.
DBMS Tutorial provides basic and advanced concepts of Database. Our DBMS Tutorial is
designed for beginners and professionals both.
What is Database
The database is a collection of inter-related data which is used to retrieve, insert and delete the
data efficiently. It is also used to organize the data in the form of a table, schema, views, and
reports, etc.
For example: The college Database organizes the data about the admin, staff, students and
faculty etc.
Using the database, you can easily retrieve, insert, and delete the information.
o Data Definition: It is used for creation, modification, and removal of definition that
defines the organization of data in the database.
o Data Updation: It is used for the insertion, modification, and deletion of the actual
data in the database.
o Data Retrieval: It is used to retrieve the data from the database which can be used by
applications for various purposes.
o User Administration: It is used for registering and monitoring users, maintain data
integrity, enforcing data security, dealing with concurrency control, monitoring
performance and recovering information corrupted by unexpected failure.
Characteristics of DBMS
o It uses a digital repository established on a server to store and manage the information.
o It can provide a clear and logical view of the process that manipulates data.
o DBMS contains automatic backup and recovery procedures.
o It contains ACID properties which maintain data in a healthy state in case of failure.
o It can reduce the complex relationship between data.
o It is used to support manipulation and processing of data.
o It is used to provide security of data.
o It can view the database from different viewpoints according to the requirements of the
user.
Advantages of DBMS
o Controls database redundancy: It can control data redundancy because it stores all
the data in one single database file and that recorded data is placed in the database.
o Data sharing: In DBMS, the authorized users of an organization can share the data
among multiple users.
o Easily Maintenance: It can be easily maintainable due to the centralized nature of the
database system.
o Reduce time: It reduces development time and maintenance need.
o Backup: It provides backup and recovery subsystems which create automatic backup
of data from hardware and software failures and restores the data if required.
o multiple user interface: It provides different types of user interfaces like graphical
user interfaces, application program interfaces
Disadvantages of DBMS
o Cost of Hardware and Software: It requires a high speed of data processor and large
memory size to run DBMS software.
o Size: It occupies a large space of disks and large memory to run them efficiently.
o Complexity: Database system creates additional complexity and requirements.
o Higher impact of failure: Failure is highly impacted the database because in most of
the organization, all the data stored in a single database and if the database is damaged
due to electric failure or database corruption then the data may be lost forever.
A relational database management system is one of four common types of systems you can
use to manage your business data. The other three include:
The Hierarchical Model was the first database management system model. This concept uses
a hierarchical tree structure to organise the data. The hierarchy begins at the root, which
contains root data, and then grows into a tree as child nodes are added to the parent node.
Network database models also have a hierarchical structure. However, instead of using a
single-parent tree hierarchy, this model supports many to many relationships, as child tables
can have more than one parent.
Relational database models A relational database is a type of database that stores and
provides access to data points that are related to one another. Relational databases are based
on the relational model, an intuitive, straightforward way of representing data in tables.
Unit -2
1. Data definition:
A database is an organized collection of structured information, or
data, typically stored electronically in a computer system.
A database is usually controlled by a database management system
(DBMS).
A DBMS serves as an interface between the database and its end users
or programs, allowing users to retrieve, update, and manage information
is organized and optimized.
Database languages can be used to read, store and update the data in the
database.
Data definition or data description language (DDL) is a syntax for
creating and modifying database
DDL is used for specifying the database schema.
It is used for creating tables, schema, indexes, constraints etc. in database
DDL commands CREATE, DROP,,ALTER,RENAME,TRUNCATE
DML name of Data Manipulation Language which deals with data
manipulation and includes most common SQL statements such SELECT,
INSERT, UPDATE, DELETE, etc.,
DML used to store, modify, retrieve, delete and update data in a database.
SQL
SQL stands for Structured Query Language. It is used for storing and
managing data in relational database management system (RDMS).
It is a standard language for Relational Database System. It enables a user to
create, read, update and delete relational databases and tables.
All the RDBMS like MySQL, Informix, Oracle, MS Access and SQL Server
use SQL as their standard database language.
Characteristics of SQL
There are five types of SQL commands: DDL, DML, DCL, TCL, and DQL.
1. Data Definition Language (DDL)
o DDL changes the structure of the table like creating a table, deleting a table,
altering a table, etc.
o All the command of DDL are auto-committed that means it permanently
save all the changes in the database.
o CREATE
o ALTER
o DROP
o RENAME
o TRUNCATE
Syntax:
Example:
b. DROP: It is used to delete both the structure and record stored in the table.
Syntax
Example
Syntax:
EXAMPLE
RENAME COMMAND
Example:
RENAME TABLE emp TO employee;
TRUNCATE: It is used to delete all the rows from the table and free the space
containing the table.
Syntax:
o INSERT
o UPDATE
o DELETE
a. INSERT: The INSERT statement is a SQL query. It is used to insert data into
the row of a table.
Syntax:
For example:
Syntax:
1. UPDATE students
2. SET User_Name = 'Sonoo'
3. WHERE Student_Id = '3'
Syntax:
For example:
DCL commands are used to grant and take back authority from any database user.
o Grant
o Revoke
Example
Example
TCL commands can only use with DML commands like INSERT, DELETE and
UPDATE only.
These operations are automatically committed in the database that's why they
cannot be used while creating tables or dropping them.
o COMMIT
o ROLLBACK
o SAVEPOINT
a. Commit: Commit command is used to save all the transactions to the database.
Syntax:
1. COMMIT;
Example:
b. Rollback: Rollback command is used to undo transactions that have not already
been saved to the database.
Syntax:
1. ROLLBACK;
Example:
Syntax:
1. SAVEPOINT SAVEPOINT_NAME;
5. Data Query Language
o SELECT
Syntax:
1. SELECT expressions
2. FROM TABLES
3. WHERE conditions;
For example:
1. SELECT emp_name
2. FROM employee
3. WHERE age > 20;
Basic Structure of SQL Queries
The fundamental structure of SQL queries includes three clauses that are select,
from, and where clause.
where P;
Consider that we have a relation ‘instructor’ with the attributes instr_id, name,
dept_name, and salary.
The SQL query we would structure to get a result relation with instructor’s names
along with their department name.
select name,
from instructor;
dept_name in the above query by default it would have listed names of all the
departments retaining the duplicates. To eliminate the duplicates you can make use
of the distinct keyword.
from instructor;
from instructor;
where clause we can make use of logical connectives and, or & not. Along with
these, we can include expressions where we can use comparison operators to
compare operands in the expression
The SQL queries often need to access multiple relations from the data set in
order to get the required result. Let us take an example we have two relations
instructor and department.
Retrieve the names of all the instructors along with their department names and the
corresponding department building. We will get the instructor’s name and
department name in the instructor relation but building name in the department
relation. So the query would be:
o SQL Datatype is used to define the values that a column can contain.
o Every column is required to have a name and data type in the database
table.
Datatype of SQL:
SQL Numeric Data Types
Datatyp Fro To
e m
bit 0 1
tinyint 0 255
Datatype Descriptio
n
DATE Stores date in the format YYYY-MM-DD
Datatype Descriptio
n
CHAR Fixed length with a maximum length of 8,000 characters
Datatype Descriptio
n
NCHAR Fixed length with maximum length of 4,000 characters
Datatype Descriptio
n
BINARY Fixed length with a maximum length of 8,000 bytes
Datatyp Descriptio
e n
CLOB Character large objects that can hold up to
2GB
BLOB For binary large objects
A database schema is a structure that represents the logical storage of the data in a
database. It represents the organization of data and provides information about the
relationships between the tables in a given database
2. Char
This data type accepts character values from the user. These characters include
single letter, digit, symbol, special characters, etc. Char data type occupies 2
bytes/16 bits of memory space.
4. Boolean
This data type consists of only 2 values: True or False. It is a logical type of built-in
data type. The default value of Boolean data type is False.
5. Double
It is a variant of the Floating-point data type which is also used to represent
fractional and decimal numbers. Generally, 8 bytes/64 bits of memory space is
allocated to it.
6. Void
This data type is widely used in C and C++ languages. It indicates that it has no
value/empty. This data type is mainly used as a return type for functions that do not
return a value to the caller function.
USERDEFINED DATATYPE:
User-defined data types are data types based on intrinsic system types given
a name by the user, which may then be used in future DDL statements within
the database where they were created.
Name.
Nullability—
1. Expand the console tree to the database in which you want the new type.
1. Expand the console tree to the database and User Defined Types.
2. Right click on the user-defined data type and select the operation desired.
sp_help <typename>: Displays the definition of the user-defined data type (or
system data type).
Integrity Constraints
1. Domain constraints
o Domain constraints can be defined as the definition of a valid set of values
for an attribute.
o 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:
Example:
3. Referential Integrity Constraints
Example:
4. Key constraints
o Keys are the entity set that is used to identify an entity within its entity set
uniquely.
o 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:
1. Entity:
An entity may be any object, class, person or place. In the ER diagram, an entity
can be represented as rectangles.
774.4K
67
Java Try Catch
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
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
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
For example, A person's age changes over time and can be derived from
another attribute like Date of birth.
3. Relationship
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.
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.
Degree:
Cardinality:
Cardinality in DBMS is a vital piece of information about a
relation between two entities. Cardinality of a relationship can be
defined as the number of times an entity of an entity set participates
in a relationship set. Cardinality shows how the entities are
connected to each other.
Dependency:
A dependency is a constraint that governs or defines the
relationship between two or more attributes. In a database, it
happens when information recorded in the same table uniquely
determines other information stored in the same table.