Professional Documents
Culture Documents
1. Data Integrity
Data integrity means data is consistent and accurate in the database. It is essential
as there are multiple databases in DBMS. All these databases contain data which is
visible to multiple users. Therefore, it is essential to ensure that data is consistent
and correct in all databases for all users.
2. Data Security
Data security is a vital concept in a database. Only users authorized must be
allowed to access the database and their identity must be authenticated using
username and password. Unauthorized users shouldn’t be allowed to access the
database under any circumstances as it violets the integrity constraints.
A DBMS provides a better platform for data privacy thus helping companies to
offer an improved data security.
6. Simplicity
DBMS allows us to understand data better with a clear and simple logical view.
With dbms, many operations like deletion, insertion or creation of file or data, are
easy to implement.
There are many dynamic websites on the World Wide Web nowadays which are
handled through databases. For example, a model that checks the availability of
rooms in a hotel. It is an example of a dynamic website that uses a database.
There are many databases available like MySQL, Sybase, Oracle, MongoDB,
Informix, PostgreSQL, SQL Server, etc.
There are the following operations which have the authorization of Revoke:
CONNECT, INSERT, USAGE, EXECUTE, DELETE, UPDATE and SELECT.
Atomicity
This property states that the transaction should either occur completely or doesn't
occur at all. The transaction should not occur partially. Each transaction is treated
as a unit and the execution is completed else the transaction is aborted. If any
transaction is aborted all the changes made are reversed back. If the transaction
occurs completely then only it is committed.
Example: Suppose there are two accounts A and B having a balance of Rs 1000
and Rs 500 respectively. Now, if you have to transfer Rs 200 from Account A to
Account B then this transaction involves two operations. First, debiting Rs 200
from Account A and second, crediting Rs 200 to Account B.
Now, let's consider a situation where the first operation has occurred successfully
i.e. Rs 200 was debited from Account A and the balance in Account A is now Rs
800. But, the second transaction failed. So, the Rs 200 was not added to Account
B. This can lead to inconsistency in the database. So, either the transaction should
fail or both the operations should occur if the transaction has to be successful. The
atomicity thus helps in ensuring the correctness of the database.
Consistency
This property ensures that the integrity of the database is maintained before and
after the transaction. It ensures that when any transaction is executed then the
database should move from one consistent state to another consistent state.
Example: In the above example, Account A and Account B have Rs 1000 and Rs
500 respectively. So, the total amount is Rs 1000+ Rs 500 i.e. Rs 1500 before the
transaction. When any transaction is executed then the total amount should also be
Rs 1500. If the transaction occurs then Rs 200 will be deducted from Account A
and added to Account B. So, the total amount after the transaction will Rs 800 + Rs
700 i.e. Rs 1500. So, this property ensures the consistency of the database. If any
operation in the transaction fails it will produce inconsistency in the data.
Isolation
This property tells that each transaction is executed in the system such that it is the
only transaction in the system. If more than one transaction is taking place in
parallel, then the occurrence of one transaction will not affect the other transaction.
If any transaction is using a data item then it can’t be used by other transactions
until the first transaction ends.
Durability
This property ensures that once the changes are made in the database these changes
persist in the database even if any system failure occurs. These changes are saved
permanently in the non-volatile memory. It is the responsibility of the recovery
manager to ensure the durability in the database.
Primary Key
Candidate Key
Super Key
Foreign Key
Composite Key
Alternate Key
Unique Key
Primary Key:- A primary key is a column of a table or a set of columns that helps
to identify every record present in that table uniquely. There can be only one
primary Key in a table. Also, the primary Key cannot have the same values
repeating for any row. Every value of the primary key has to be different with no
repetitions.
The PRIMARY KEY (PK) constraint put on a column or set of columns will not
allow them to have any null values or any duplicates. One table can have only one
primary key constraint. Any value in the primary key cannot be changed by any
foreign keys which refer to it.
Candidate Key:-Candidate keys are those attributes that uniquely identify rows of
a table. The Primary Key of a table is selected from one of the candidate keys. So,
candidate keys have the same properties as the primary keys explained above.
There can be more than one candidate keys in a table.
Super Key:- Super Key is the set of all the keys which help to identify rows in a
table uniquely. This means that all those columns of a table that are capable of
identifying the other columns of that table uniquely will all be considered super
keys.
Super Key is the superset of a candidate key. The Primary Key of a table is picked
from the super key set to be made the table’s identity attribute.
Alternate Key:-As stated above, a table can have multiple choices for a primary
key; however, it can choose only one. So, all the keys which did not become the
primary Key are called alternate keys.
One-to-One Relationship
One-to-Many or Many-to-One Relationship
Many-to-Many Relationship
One-to-One Relationship:-
Such a relationship exists when each record of one table is related to only one
record of the other table.
For example:- If there are two entities ‘Person’ (Id, Name, Age, Address)and
‘Passport’(Passport_id, Passport_no). So, each person can have only one passport
and each passport belongs to only one person.
For example:- If there are two entity type ‘Customer’ and ‘Account’ then each
‘Customer’ can have more than one ‘Account’ but each ‘Account’ is held by only
one ‘Customer’. In this example, we can say that each Customer is associated with
many Account. So, it is a one-to-many relationship. But, if we see it the other way
i.e many Account is associated with one Customer then we can say that it is a
many-to-one relationship.
Many-to-Many Relationship:-
Such a relationship exists when each record of the first table can be related to one
or more than one record of the second table and a single record of the second table
can be related to one or more than one record of the first table. A many-to-many
relationship can be seen as a two one-to-many relationship which is linked by a
'linking table' or 'associate table'. The linking table links two tables by having
fields which are the primary key of the other two tables. We can understand this
with the following example.
Example:- If there are two entity type ‘Customer’ and ‘Product’ then each
customer can buy more than one product and a product can be bought by many
different customers.
View Level
Conceptual Level
Physical Level
Primary Index − Primary index is defined on an ordered data file. The data file is
ordered on a key field. The key field is generally the primary key of the relation.
Clustering Index − Clustering index is defined on an ordered data file. The data
file is ordered on a non-key field.
Q.12 What is Normalization? Types of them ..?
Ans:-Normalization is used to minimize the redundancy from a relation or set of
relations. It is also used to eliminate the undesirable characteristics like Insertion,
Update and Deletion Anomalies. Normalization divides the larger table into the
smaller table and links them using relationship.
If we follow second normal form, then every non-prime attribute should be fully
functionally dependent on prime key attribute. That is, if X → A holds, then there
should not be any proper subset Y of X, for which Y → A also holds true.
We see here in Student_Project relation that the prime key attributes are Stu_ID
and Proj_ID. According to the rule, non-key attributes, i.e. Stu_Name and
Proj_Name must be dependent upon both and not on any of the prime key attribute
individually. But we find that Stu_Name can be identified by Stu_ID and
Proj_Name can be identified by Proj_ID independently. This is called partial
dependency, which is not allowed in Second Normal Form.
We broke the relation in two as depicted in the above picture. So there exists no
partial dependency.
We find that in the above Student_detail relation, Stu_ID is the key and only prime
key attribute. We find that City can be identified by Stu_ID as well as Zip itself.
Neither Zip is a superkey nor is City a prime attribute. Additionally, Stu_ID → Zip
→ City, so there exists transitive dependency.
To bring this relation into third normal form, we break the relation into two
relations as follows −
and
Zip → City
Example: Suppose after normalization we have two tables first, Student table and
second, Branch table. The student has the attributes as Roll_no, Student-name,
Age, and Branch_id.
The branch table is related to the Student table with Branch_id as the foreign key
in the Student table.
If we want the name of students along with the name of the branch name then we
need to perform a join operation. The problem here is that if the table is large we
need a lot of time to perform the join operations. So, we can add the data of
Branch_name from Branch table to the Student table and this will help in reducing
the time that would have been used in join operation and thus optimize the
database.