Professional Documents
Culture Documents
Note:
Your assignment should be hand written. In case of any difficulty, please visit me on Monday.
Zero marks for copied Assignments (both copied from and copied).
A viva will be conducted after the submission and marks will be given based on the viva .
2. Define DBMS?
ANS: - A database management system (DBMS) is a software package designed to define,
manipulate, retrieve and manage data in a database. A DBMS generally manipulates the data
itself, the data format, field names, record structure and file structure. It also defines rules to
validate and manipulate this data.
Database management systems are set up on specific data handling concepts, as the practice
of administrating a database evolves.
A database management system (DBMS) is system software for creating and managing
databases. A DBMS makes it possible for end users to create, protect, read, update and delete
data in a database. The most prevalent type of data management platform, the DBMS
essentially serves as an interface between databases and end users or application programs,
ensuring that data is consistently organized and remains easily accessible.
3. Enlist the advantages of DBMS?
o 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.
o 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.
o 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.
o 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.
o 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.
o 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
In the above
table, we can clearly see that the Phone Number column has two values. Thus it violated the
1st NF. Now if we apply the 1st NF to the above table we get the below table as the result.
By this, we
have achieved atomicity and also each and every column has unique values.
As you can see we have removed the partial functional dependency that we initially had.
Now, in the table, the column Office Location is fully dependent on the primary key of that
table, which is Department ID.
Third Normal Form (3NF)
The same rule applies as before i.e., the table has to be in 2NF before proceeding to 3NF. The
other condition is there should be no transitive dependency for non-prime attributes. That
means non-prime attributes (which doesn’t form a candidate key) should not be dependent on
other non-prime attributes in a given table. So a transitive dependency is a functional
dependency in which X → Z (X determines Z) indirectly, by virtue of X → Y and Y → Z
(where it is not the case that Y → X)
Let’s understand this more clearly with the help of an example:
The same rule applies as before i.e., the table has to be in 2NF before proceeding to 3NF. The
other condition is there should be no transitive dependency for non-prime attributes. That
means non-prime attributes (which doesn’t form a candidate key) should not be dependent on
other non-prime attributes in a given table.
Let’s understand this more clearly with the help of an example:
As you can see from the above tables all the non-key attributes are now fully functional
dependent only on the primary key. In the first table, columns Student Name, Subject ID
and Address are only dependent on Student ID. In the second table, Subject is only
dependent on Subject ID.
DML
The SQL commands that deals with the manipulation of data present in the database belong
to DML or Data Manipulation Language and this includes most of the SQL statements.
INSERT
INSERT statement is used to insert a set of values into a database table. Insert statement it
used with Values.
Example- Insert into Student (Rank, “Student Name”, Mark) Values (1,’Kumar’, 450)
UPDATE
The UPDATE statement is used to update existing values in a table, which is based on some
condition.
Example
update student set “Student Name”=’MANOJ’ where “Student Name”=’KUMAR’
The query given above will update the “student Name” from MANOJ to Kumar
where student Name Kumar.
DELETE
Delete statement is used to delete the existing record in the table, which is based on some
condition.
Example
Delete from Student where “Student Name”=’MANOJ’
The query given above will delete records which have “Student Name” as MANOJ.
DDL
DDL or Data Definition Language actually consists of the SQL commands that can be used
to define the database schema. It simply deals with descriptions of the database schema and
is used to create and modify the structure of database objects in the database.
CREATE
CREATE statement is used to create a new table in an existing database. CREATE
statement is also used to create other database object such as a stored procedure,
function, etc.
Example
Create Table Student (Rank Int, “Student Name” varchar (50), Mark Float)
ALTER
Alter statement can add a column, modify a column, drop a column, rename a
column or rename a table.
Example
Alter Table Student Add (“Student Address” varchar (100))
DROP
SQL DROP TABLE statement is used to remove a table definition and all the data,
indexes, triggers, constraints and permission specifications for the table.
Example
Drop Student
TRUNCATE
TRUNCATE SQL query removes all rows from a table, without logging the
individual row deletions.
Example
Truncate Table Table_Name
DQL
DQL stand for Data Query Language statements are used for performing queries on the
data within schema objects. The purpose of the DQL Command is to get some schema
relation based on the query passed to it.
SELECT Statement
The SELECT statement is used to select records from the table, with or without a condition.
Example
Select * from student- Gets all records of student table.
Select * from student where rank>5- Gets records with the condition where students' rank
is greater than 5
DCL
DCL includes commands such as GRANT and REVOKE which mainly deal with the
rights, permissions and other controls of the database system.
GRANT
Grant is allowed to do the specified user to the specified tasks.
Syntax
GRANT privilege_name
ON object_name
TO {user_name |PUBLIC |role_name}
[WITH GRANT OPTION];
REVOKE
It is used to cancel previously granted or denied permissions.
Syntax
REVOKE privilege_name
ON object_name
FROM {user_name |PUBLIC |role_name}
TCL
In Transaction Control Language (TCL), the commands are used to manage the
transactions in the database. These are used to manage the changes made by DML
statements. It also allows the statements to be grouped together into logical
transactions.
COMMIT
Commit command is used to permanently save any transaction into the database.
Syntax
Commit;
ROLLBACK
Rollback command is used to restore the database for the last committed state. It’s
also used with a save point to jump to the save point.
Syntax
Rollback to savepoint name
SAVEPOINT
SAVEPOINT command is used to temporarily save a transaction so that you can roll
back to that point whenever necessary.
Syntax
Save point (save point-name ;)
These are the different types of statements in the SQL language. I hope, this will be
helpful for the readers. Thanks for reading.
DDL
In Data Definition Language (DDL), we have three different SQL statements.
CREATE
CREATE statement is used to create a new table in an existing database. CREATE
statement is also used to create other database object such as a stored procedure,
function, etc.
Example
Create Table Student (Rank Int, “Student Name” varchar (50), Mark Float)
ALTER
Alter statement can add a column, modify a column, drop a column, rename a
column or rename a table.
Example
Alter Table Student Add (“Student Address” varchar (100))
DROP
SQL DROP TABLE statement is used to remove a table definition and all the data,
indexes, triggers, constraints and permission specifications for the table.
Example
Drop Student
TRUNCATE
TRUNCATE SQL query removes all rows from a table, without logging the
individual row deletions.
Example
Truncate Table Table_Name
DCL
In Data Control Language (DCL), it defines the control over the data in the
database. We have two different commands, which are
GRANT
Grant is allowed to do the specified user to the specified tasks.
Syntax
GRANT privilege_name
ON object_name
TO {user_name |PUBLIC |role_name}
[WITH GRANT OPTION];
REVOKE
It is used to cancel previously granted or denied permissions.
Syntax
REVOKE privilege_name
ON object_name
FROM {user_name |PUBLIC |role_name}
17. Explain the terms ‘Record’, ‘Field’ and ‘Table’ in terms of database?
Record
A record is a database entry that may contain one or more values. Groups of records are
stored in a table, which defines what types of data each record may contain. Databases may
contain multiple tables which may each contain multiple records. In terms of a database,
records are rows of a table.
For example
All of your Clients, Images, Invoices, etc., are considered records (identified by an ID).
Field
A field is a single unit of data that is unique within each entry/row, or Fields are the
individual parts that contain information about the record, but the overall data category is
common to all entries. A database record is, basically, a row that contains unique data in each
of the fields. A database will usually contain a large number of records but only a small
number of fields. In terms of a database, fields are columns.
For example
For example, if you only want to list your Japanese Clients, you would use the Query Wizard
to select only the Client records which contain the word Japan in the "Country" field.
Some examples of fields are:
{Images.Id}: The Image ID number
{Clients.City}: The city where the Client is from
{Invoices.Date}: The date of the Invoice
{Payables.Amount}: Commission amounts
Table
In database, a table is a data
structure where data can be
organized in fields (columns) &
records (rows).
For example
Information of the employees of an organization needs to be stored. Employee information
can be broken into several smaller entities like employee name, id, date of joining, current
location, designation etc. these are called fields or columns.
Data is stored in records. A record represents set of related data. Complete set of values for
all column/field is called record or row.
18. What do you understand by Data Independence? What are its two types?
ANS: -Data Independence helps administrators separate information from the applications
and programs that use it. As such, programmers don’t need to modify their source codes
every time changes to the data characteristics are made. This property helps save time and
other resources, and most importantly, minimizes errors.
Physical Data Independence
Physical Data Independence refers to the characteristic of changing the physical level
without affecting the logical level or conceptual level. Using this property we can easily
change the storage device of the database without affecting the logical schema.
Example:
Suppose you want to replace the storage device form hard disk to SSD or magnetic tape
then it should not affect the data stored at the logical level or using a new data structure for
storage.
20. What are the advantages and disadvantages of views in the database?
ADVANTAGES DISADVANTAGES
Security Performance Degradation
Each user can be given permission to access Because views only create the appearance of a
the database only through a small set of views table, not a real table, the query processor must
that contain the specific data the user is translate queries against the view into queries
authorized to see, thus restricting the user's against the underlying source tables
access to stored data
Structural simplicity
Views can give a user a "personalized" view
of the database structure, presenting the
database as a set of virtual tables that make
sense for that use
Data Integrity
If data is accessed and entered through a view,
the DBMS can automatically check the data to
ensure that it meets the specified integrity
constraints
Query Simplicity
A view can draw data from several different
tables and present it as a single table, turning
multi-table queries into single-table queries
against the view.
geometric shapes and their meaning in an E-R Diagram. We will discuss these terms in detail
in the next section(Components of a ER Diagram) of this guide so don’t worry too much
about these terms now, just go through them once.
Entity set:
An entity set is a group of similar kind of entities. It may contain entities with attributes
sharing similar values. Entities are represents by their properties which also called attributes.
Type of entity: -
Weak entity
A weak entity is a type of entity which doesn’t have its key attribute. It can be identified
uniquely by considering by consisting primary key of another entity. It represented by double
rectangular box. Weak relation represent by double diamond box.
FOR EXAMPLE
Suppose if we have two tables of Customer (Customer_id, Name, Mobile_no, Age, and
Gender) and Address (Locality, Town, State, Customer_id). Here we cannot identify the
address
uniquely as
there can be
many
customers
from the same
locality. So,
for this, we need
an attribute of
Strong Entity
Type i.e. ‘Customer’ here to uniquely identify entities of 'Address' Entity Type.
Strong entity
Strong entity is those entity types which has a key attribute. The primary key helps in
identifying each entity uniquely. It is represented by a rectangle. In the above example,
Roll_no identifies each element of the table uniquely and hence, we can say that
STUDENT is a strong entity type.
25. Define a Weak Entity set?
Weak entity
A weak entity is a type of entity which doesn’t have its key attribute. It can be identified
uniquely by considering by consisting primary key of another entity. It represented by double
rectangular box. Weak relation represent by double diamond box.
FOR EXAMPLE
Suppose if we have two tables of Customer (Customer_id, Name, Mobile_no, Age, and
Gender) and Address (Locality, Town, State, Customer_id). Here we cannot identify the
address uniquely as there can be many customers from the same locality. So, for this, we
need an attribute of Strong Entity Type i.e. ‘Customer’ here to uniquely identify entities of
'Address' Entity Type.
These two tables have only one thing in common: the ID column (the key). But because of
that common column, the relational database can create a relationship between the two
tables. Then, when the company’s order processing application submits an order to the
database, the database can go to the customer order table, pull the correct information about
the product order, and use the customer ID from that table to look up the customer’s billing
and shipping information in the customer info table. The warehouse can then pull the correct
product, the customer can receive timely delivery of the order, and the company can get paid