Describe The Relationship Between Data Security and Data Integrity, With The Help of A Diagram?
Describe The Relationship Between Data Security and Data Integrity, With The Help of A Diagram?
MCS-023 🔥
Database management system✔
✔@Bca studies
👍100% guranteed👍
● 🔥Most Important question🔥
1. Describe the relationship between Data Security and Data Integrity, with the help of a
diagram?
Sol. Relationship between Security and Integrity:Database security usually refers to access, while
database integrity refers to avoidance of accidental loss of consistency. But usually, the turning
point or the dividing line among security and integrity is not always clear. Figure shows the
relationship among data security and integrity.
2. What are integrity constraints ? What for they are required in databases ? Briefly discuss
the different types of integrity constraints?
Sol. Integrity Constraints
● Integrity constraints are a set of rules. It is used to maintain the quality of information.
● Integrity constraints ensure that the data insertion, updating, and other processes have to
be performed in such a way that data integrity is not affected.
● Thus, integrity constraint is used to guard against accidental damage to the database.
Types of Integrity Constraint :-
1. Domain constraints:-
● Domain constraints can be defined as the definition of a valid set of values for an
attribute.
● 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.
2. Entity integrity Constraints:-
● The entity integrity constraint states that primary key value can't be null.
● This is because the primary key value is used to identify individual rows in
relation and if the primary key has a null value, then we can't identify those rows.
● A table can contain a null value other than the primary key field.
3. Referential Integrity Constraints
● A referential integrity constraint is specified between two tables.
● In the Referential integrity constraints, if a foreign key in Table 1 refers to the Primary Key
of Table 2, then every value of the Foreign Key in Table 1 must be null or be available in
Table 2.
4. Key constraints
● Keys are the entity set that is used to identify an entity within its entity set uniquely.
● 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.
3. What are Indexes in DBMS ? What is the utility of Indexes in DBMS ? Under what
situations B-tree Indexes are preferable over Binary Search Tree Indexes ?
Sol. Indexing in DBMS:-
● Indexing is used to optimize the performance of a database by minimizing the number of
disk accesses required when a query is processed.
● The index is a type of data structure. It is used to locate and access the data in a
database table quickly.
●
4. What is the difference between strong and weak entities ? Specify strong and weak
entities in the above E-R diagram?
Sol.
● At time t1, transaction TX reads the value of account A, i.e., $300 (only read).
● At time t2, transaction TX deducts $50 from account A that becomes $250 (only deducted
and not updated/write).
● Alternately, at time t3, transaction TY reads the value of account A that will be $300 only
because TX didn't update the value yet.
● At time t4, transaction TY adds $100 to account A that becomes $400 (only added but
not updated/write).
● At time t6, transaction TX writes the value of account A that will be updated as $250 only,
as TY didn't update the value yet.
● Similarly, at time t7, transaction TY writes the values of account A, so it will write as done
at time t4 that will be $400. It means the value written by TX is lost, i.e., $250 is lost.
Hence data becomes incorrect, and database sets to inconsistent.
7. Consider two transactions TX and TY in the below diagram performing read/write
operations on account A where the available balance in account A is $300:
(Dirty Read Problems (W-R Conflict))
● Sol. At time t1, transaction TX reads the value from account A, i.e., $300.
● At time t2, transaction TY reads the value from account A, i.e., $300.
● At time t3, transaction TY updates the value of account A by adding $100 to the available
balance, and then it becomes $400.
● At time t4, transaction TY writes the updated value, i.e., $400.
● After that, at time t5, transaction TX reads the available value of account A, and that will
be read as $400.
● It means that within the same transaction TX, it reads two different values of account A,
i.e., $ 300 initially, and after updation made by transaction TY, it reads $400. It is an
unrepeatable read and is therefore known as the Unrepeatable read problem.
9. What is the role of Database Manager ?
Sol. A database manager is responsible for developing and maintaining an organizations'
systems that store and organize data for companies. By implementing several security programs,
they ensure the safety of stored data.
10. Explain the important components of database manager with the help of a diagram??
Sol. Components of a database management system
All DBMS comes with various integrated components and tools necessary to carry out almost all
database management tasks. Some DBMS software even provides the ability to extend beyond
the core functionality by integrating with third-party tools and services, directly or via plugins.
In this section, we will look at the common components that are universal across all DBMS
software, including:
● Storage engine
● Query language
● Query processor
● Optimization engine
● Metadata catalog
● Log manager
● Reporting and monitoring tools
● Data utilities
11. Write short notes on the following :
(i) 2-Phase locking protocol
Sol.
● The two-phase locking protocol divides the execution phase of the transaction into three
parts.
● In the first part, when the execution of the transaction starts, it seeks permission for the
lock it requires.
● In the second part, the transaction acquires all the locks. The third phase is started as
soon as the transaction releases its first lock.
● In the third phase, the transaction cannot demand any new locks. It only releases the
acquired locks.
● Growing phase: In the growing phase, a new lock on the data item may be acquired by
the transaction, but none can be released.
● Shrinking phase: In the shrinking phase, existing lock held by the transaction may be
released, but no new locks can be acquired.
(ii) 2-Phase commit protocol
Sol. Two-Phase Commit Protocol: This protocol is designed with the core intent to resolve the
above problems, Consider we have multiple distributed databases which are operated from
different servers(sites) let’s say S1, S2, S3, ….Sn. Where every Si made to maintains a separate
log record of all corresponding activities and the transition T has also been divided into the
subtransactions T1, T2, T3, …., Tn and each Tiare assigned to Si. This all maintains by a
separate transaction manager at each Si. We assigned anyone site as a Coordinator.
a) In a two-phase commit, we assume that each site logs actions at that site, but there is no
global log.
b) The coordinator(Ci), plays a vital role in doing confirmation whether the distributed transaction
would abort or commit.
c) In this protocol messages are made to send between the coordinator(Ci) and the other sites.
As each message is sent, its logs are noted at each sending site, to aid in recovery should it be
necessary.
(iii) Time-stamping protocol
Sol. Time stamping protocol:-
● The Timestamp Ordering Protocol is used to order the transactions based on their
Timestamps. The order of transaction is nothing but the ascending order of the
transaction creation.
● The priority of the older transaction is higher that's why it executes first. To determine the
timestamp of the transaction, this protocol uses system time or logical counter.
● The lock-based protocol is used to manage the order between conflicting pairs among
transactions at the execution time. But Timestamp based protocols start working as soon
as a transaction is created.
● Let's assume there are two transactions T1 and T2. Suppose the transaction T1 has
entered the system at 007 times and transaction T2 has entered the system at 009 times.
T1 has the higher priority, so it executes first as it is entered the system first.
● The timestamp ordering protocol also maintains the timestamp of last 'read' and 'write'
operation on a data.
(iv) Checkpoints
Sol. Checkpoint:-
● The checkpoint is a type of mechanism where all the previous logs are removed from the
system and permanently stored in the storage disk.
● The checkpoint is like a bookmark. While the execution of the transaction, such
checkpoints are marked, and the transaction is executed then using the steps of the
transaction, the log files will be created.
● When it reaches to the checkpoint, then the transaction will be updated into the database,
and till that point, the entire log file will be removed from the file. Then the log file is
updated with the new step of transaction till next checkpoint and so on.
● The checkpoint is used to declare a point before which the DBMS was in the consistent
state, and all transactions were committed.
(v)Full functional dependency
Sol. A full functional dependency is a state of database normalization that equates to the
normalization standard of Second Normal Form (2NF). In brief, this means that it meets the
requirements of First Normal Form (1NF), and all non-key attributes are fully functionally
dependent on the primary key.
(vi) Partial functional dependency
Sol.Partial Dependency occurs when a non-prime attribute is functionally dependent on part of a
candidate key.
Now, the main problem arises. Now Transaction T1 is waiting for T2 to release its lock and
similarly, transaction T2 is waiting for T1 to release its lock. All activities come to a halt state and
remain at a standstill. It will remain in a standstill until the DBMS detects the deadlock and aborts
one of the transactions.
(xiii) Distributed DBMS
Sol. A distributed database (DDB) is a collection of multiple, logically interrelated databases
distributed over a computer network. A distributed database management system (D–DBMS) is
the software that manages the DDB and provides an access mechanism that makes this
distribution transparent to the users.
(xiv) Clustering Indexes and their Implementation
Sol. Cluster index is a type of index which sorts the data rows in the table on their key values. In
the Database, there is only one clustered index per table.
A clustered index defines the order in which data is stored in the table which can be sorted in only
one way. So, there can be an only a single clustered index for every table. In an RDBMS, usually,
the primary key allows you to create a clustered index based on that specific column.
(xv) Shadow Paging
Sol. Shadow paging is one of the techniques that is used to recover from failure. We all know that
recovery means to get back the information, which is lost. It helps to maintain database
consistency in case of failure.
● Step 1 − Page is a segment of memory. Page table is an index of pages. Each table entry
points to a page on the disk.
● Step 2 − Two page tables are used during the life of a transaction: the current page table
and the shadow page table. Shadow page table is a copy of the current page table.
● Step 3 − When a transaction starts, both the tables look identical, the current table is
updated for each write operation.
● Step 4 − The shadow page is never changed during the life of the transaction.
● Step 5 − When the current transaction is committed, the shadow page entry becomes a
copy of the current page table entry and the disk block with the old data is released.
● Step 6 − The shadow page table is stored in non-volatile memory. If the system crash
occurs, then the shadow page table is copied to the current page table.
Advantages
The advantages of shadow paging are as follows −
● Garbage collection problem. Database pages containing old versions of modified data
need to be garbage collected after every transaction.