You are on page 1of 31

Data Analysis and Design

Task 1

1) Critically compare different data models such as hierarchical model,


network model, relational model and different schemas such as
conceptual schema, physical schema. (Main Factors) (Model achin chin
similarities , differences, advantages, disadvantages)
1(a) physical and logical view of data

Physical view of data


The physical view with the actual, physical arrangement and location of data
in the direct access storage devices. Database specialists use the physical
view to make efficient use of storage and processing resources.

Logical view of data

The logical view of a database program represents data in a format that is


meaningful to a user and to the software programs that process those data
and identify the application program's logical views of data within an overall
logical data structure.

(b) About the database and advantages of using database

A database is a collection of information that is organized so that it can


easily be accessed, managed, and updated. A collection of related data

specially organized to be retrieved quickly and normally structured and


indexed for user access and review. Databases may exist in the form of
physical files (folders, documents, etc.) or formatted automated data
processing system data files.
Basically, the advantages of databases are ..
Concurrent Use
Structured and Described Data
Separation of Data and Applications
Data Integrity
Transactions
Data Persistence
Data Views
The database can reduce the data redundancy, updating errors and
increased consistency and data entry, storage, and retrieval costs.
Improved data access to users through use of hosts , query languages and
data security.

(c)

In which situations we need database system for applications?

A database is a computer program whose primary purpose is entering and


retrieving information from a computerized database.
Database most useful in many large hotels .They used for their customer
name and how much stay in their hotel .These data stored in database.
Most companies are use database .Why they use database? .They used
database for their customers bank accounts .Their names ,IP address , how
much deposited money and how much transferred money are stored in
databases.
Libraries are used database . They used their students data and new
another customers. Student names , IP address , book names .These data
are stored in database. Why they are used database ?. They used database
salve their times , money , life . So, they are used database .

(d) the role of database administrator.


A database administrator (DBA) is responsible for the performance, integrity
and security of a database.
data remains consistent across the database
data is clearly defined
users access data concurrently, in a form that suits their needs
there is provision for data security and recovery control

(e) the key organizational issues of integrity , recovery, security and


concurrency
Integrity
CentralizedcontrolcanalsoensurethatadequatechecksareincorporatedintheDB
MStoprovidedataintegrity
.Dataintegritymeansthatthedatacontainedinthedatabaseisbothaccurateandco
nsistent.
Security
Dataisofvitalimportancetoanorganizationandmaybeconfidential.Such
confidentialmustnotbeaccessedbyunauthorizedpersons.Differentlevelsofsecur
itycouldbeimplementedforvarioustypesofdata and operations.

Conflict Resolution
A database chooses thebestfilestructureandaccessmethodtoget
optimalperformancefortheresponse
criticalapplications,whilepermittinglesscriticalapplicationstocontinuetousethe
database,albeitwitharelativelyslowerresponse.
Data Independence

Dataindependenceisusuallyconsideredfromtwopointsofview:physicaldatainde
pendenceandlogicaldataindependence..
Physical data
independenceallowschangesinthephysicalstoragedevicesororganizationofthe
filestobemadewithoutrequiringchangesintheconceptualvieworanyoftheextern
alviewsandhenceintheapplicationprogramsusingthedatabase.
Logical data
independenceimpliesthatapplicationprogramsneednotbechangedif
Fieldsareaddedtoanexistingrecord;nordotheyhavetobechangediffieldsnotused
byapplicationsprogramsaredeleted. You may have experienced something
like the following example:
Imagine there are two people in your team or office, both of whom are great
at managing budgets. They are both accurate, detail-oriented and deliver the
results needed. However, one of them is a real people person. Their
interpersonal and communication skills are fantastic and, as a result of this,
they have no problem getting the information they require quickly from
colleagues at any level. The other person does not have this skill and often
encounters conflict from colleagues, perhaps for many different reasons.
Which of these people do you think needs personal development training?
As you can see from the example, both can do their jobs. Both have the skills
required on a professional level to deliver results, however, with the added
benefit of excellent relationship building skills one of the employees will
always be one step ahead.

Integrity
Data integrity is mandatory for the regulated healthcare industry, as
processing and disposition decisions regarding product quality, safety,
efficacy, purity, and compliance with the applicable regulatory requirements
are made based on data that is recorded and reported. Drug, medical device
manufacturers, service providers, health authorities, end users and
administrators of the product (patients and healthcare professionals) rely on
robust traceable data.

Recovery

In databases using the simple recovery model, you may restore full or
differential backups only. It is not possible to restore such a database to a
given point in time, you may only restore it to the exact time when a full or
differential backup occurred. Therefore, you will automatically lose any data
modifications made between the time of the most recent full/differential
backup and the time of the failure.
Security
Database security covers and enforces security on all aspects and
components of databases. This includes:
Data stored in database
Database server
Database management system (DBMS)
Other database workflow applications
Database security is generally planned, implemented and maintained by a
database administrator and or other information security professional.
Some of the ways database security is analyzed and implemented include:
Restricting unauthorized access and use by implementing strong and
multifactor access and data management controls.
Load/stress testing and capacity testing of a database to ensure it does
not crash in a distributed denial of service attack or user overload.
Physical security of the database server and backup equipment from
theft and natural disasters.
Concurrency
Concurrency can be defined as the ability for multiple processes to access or
change shared data at the same time.Database concurrency controls ensure
that transactions occur in an ordered fashion. The main job of these controls
is to protect transactions issued by different users/applications from the
effects of each other. Concurrency is impacted when a process that is
changing data prevents other processes from reading the data being
changed or when a process that is reading data prevents other processes
from changing that data. Concurrency is also impacted when multiples
processes are attempting to change the same data concurrently and they
cannot all succeed without sacrificing data consistency.

Critically discuss the benefits and limitations of different


database technologies
Large business organizations make use of Data warehouses with data
mining techniques for business decision making. Explain what is a data
warehouse and how data mining is used in the decision making
process

(1) the features of DBMS


Conceptual database design
- a model of information used in an enterprise.
- independent of all physical considerations.
- identification of entities, relationships, and attributes.
- conceptual database are independent of DBMS
- they are free from the technical details such as the field size, field
types, constrains
and so on
allows for easy comunication between end-users and developers.
has a clear method to conver from high-level model to relational
model.
conceptual schema is a permanent description of the database
requirements.
Private Scope
Private variables and private methods are only accessible to the object they
are contained in.
Protected Scope
Protected variables and protected methods are accessible by the class they
are in and inheriting classes (sub classes).
Public Scope
Public variables and public methods are accessible outside the object they
are contained in. They are accessible to any other object. Example:
Production is on release 11/08.12, QA is on 11.09.12, and Test/Dev is on
11.10. So if you refresh Test, its code base would be that of production, or
11.08, but it was on 11.10 so QA would need to be resync the database code
(e.g., rerun the turn scripts for 11.09 and 11.10).

Once you think youre syncd then you need to perform verification to ensure
that you know where your starting point is.
Code Promotion
Refreshes are usually at the start a development cycle, which means that
you will probably run (test, prove, etc.) the next releases code base (scripts).
If you are dealing with QA, the Turn Center will actually do the turn via a TCW.
Code turns should ALWAYS be verified, regardless of who does them.
Database Use This is why the database exists utilization by an end-use
process. QA and Test have the same end-use processes; just the audience is
different. In Dev, the end-use process is the actual development and
database script creation.

Logical database design


based on a specific data model (e.g. relational)
independent of a particular DBMS and other physical considerations
logical structure of the database.

Physical database design.

Decide how the logical structure is to be physically implemented in the


target DBMS.
Decisions on
Index
DBMS
Application Programs
Hardware

(b) the advantages and disadvantages of DBMS


Advantages of DBMS
Shared Data
A database allows the sharing of data under its control by any number of
application programs or users.
Integrity
Centralized control can also ensure that adequate checks are incorporated in
the DBMS to provide data integrity .Data integrity means that the data
contained in the database is both accurate and consistent.

Security
Data is of vital importance to an organization and may be confidential . Such
confidential must not be accessed by unauthorized persons. Different levels
of security could be implemented for various types of data and operations.

Conflict Resolution
A database chooses the best file structure and access method to get optimal
performance for the response
critical applications, while permitting less critical applications to continue to
use the database, albeit with a relatively slower response.
Data Independence
Data independence is usually considered from two points of view : physical
data independence and logical data independence..
Physical data independence allows changes in the physical storage devices
or organization of the files to be made without requiring changes in the
conceptual view or any of the external views and hence in the application
programs using the database.
Logical data independence implies that application programs need not be
changed if
Fields are added to an existing record ; nor do they have to be changed if
fields not used by applications programs are deleted. To address your
question, improvements in speed and performance of your LAN and WAN
depend on several factors, budget and technology. With the LAN, I am going
to recommend a few general guidelines and best practices on design to
ensure reliable performance. For the WAN, there are several factors to
consider that are more cost prohibitive. Decide what works best for your
enterprise and environment.
To address potential performance issues on the LAN, you want to identify and
isolate any bottlenecks due to technology. On LANs, you are able to achieve
better performance results with high speed, low cost technologies like

Ethernet. Ensure that all of your servers in the Citrix MetaFrame farm are
capable of at least 100Mbps at full duplex. Oftentimes, I recommend that the
switches be hard wired for this configuration (or higher if applicable) to
reduce any potential problems with auto negotiation. A good LAN design also
ensures that the right VLAN and Spanning Tree implementations are in place
to reduce multicast and broadcast congestion and bridging loops. If not
currently implemented, ensure that the servers are on a managed switch
that supports multiple VLAN configurations and Spanning Tree. By
implementing managed switches in the environment, the switches will be
able to assist you with control over the server ports and reduce collisions. In
summary, ensure that you have managed switches on the network that can
control VLANs and bridging loops. Also ensure the server switch ports are set
to the right speed and duplex settings. These are the two major rules to
follow when developing better performance on the LAN side of the
enterprise.

.
Disadvantages of DBMS
Cost of software/hardware and migration
A significant disadvantage of the DBMS system is cost . In
addition to the cost of purchasing or developing the software, the Hardware
has to be upgraded to allow for the extensive programs and work spaces
required for their execution and storage. The processing overhead introduced
by DBMS to implement security, integrity, and sharing of the data causes a
degradation of the response and through put times.
.
Problem associated with centralization
While centralization reduces duplication, the lack of duplication
requires that the database be adequately backed up so that in the case of
failure the data can be recovered .Centralization also means that the data is
accessible from a single source . This increases the potential severity of
security breaches and disruption of the operation of the organization
because of downtimes and failures.
Complexity of Backup and Recovery

Backup and recovery operations are fairly complex in a DBMS


environment, and this is exacerbated in a concurrent multi user
Database system. WAN issues, Citrix MetaFrame clients are a good start.
Citrix MetaFrame clients are quite effective when circuits are already heavily
congested and you need to reduce the amount of traffic that the users are
transferring over the WAN. Unfortunately, Citrix tends to have a performance
hit when it comes to the end user experience. This is due to the fact that
depending on the Citrix MetaFrame deployment you have implemented, the
client when launched will open a single TCP session. With this single TCP
session, the screen updates and refreshes are sent to the client's machine at
the remote location. While this consumes less bandwidth, any sort of delay
or dropped packet causes the end-user response times to degrade
significantly. If there are any sources of delay within the network and a
packet is lost, the TCP window for the single-session client will drop
significantly. To compensate for this ensure that the links are not congested
and special treatment (QoS) policies are given to Citrix clients to ensure
packets are given the best performance. However, you must also be aware
that by doing so, you effectively compromise the performance of other
applications on the network. There are tools that allow you to troubleshoot
and analyze the performance of WAN-deployed applications. If you would like
more information on these tools, please let me know and I will happily supply
that information.
Monitor dashboards Provides Monitoring, EnerygyWise and Identity
dashboards to monitor the status and the performance of network.
Monitoring tools Provides tools such as Fault Monitor, Event Monitor,
MiniRMON and Topology Services to view the information on network faults,
events, links and ports in the network and perform remote monitoring
functions.
Diagnostic tools Provides framework such as Embedded Event
Manager (EEM) and Generic Online Diagnostics (GOLD) for diagnostic
operations across Cisco platforms running Cisco IOS Software.
Troubleshooting tools Provides troubleshooting workflows, Netshow
and VRF-lite to troubleshoot the network connectivity, diagnose device
problems, identify endhost problems, and verify end-to-end connectivity of
VRF configured devices.
Fault Settings Helps you to set up the fault polling parameters, fault
threshold settings, SNMP traps forwarding and receiving, and allows you to
view the fault device details.

Performance Settings Helps you to manage pollers and templates,


enable Automonitoring functionality, and manage IPSLA collectors and
devices.
Threshold Settings Helps you to manage Trendwatch, set up fault and
performance threshold settings

3.

Analyze different approaches to database design such as top-down approach or bottomup approach.

There are two basic strategies to dealing with information processing and software design: the
top-down and the bottom up approaches. These two paradigms are often used at the start of
development to create domain models and plot the path of work to be done on a project. While
they are often used concurrently, there are specific drawbacks and benefits to each, and balancing
this is key to building a successful piece of software.

Top-Down
The top-down approach, also known as step-wise design, essentially breaks a system or model
down into component sub-systems, each of which may further broken down further. However, no
first-level system are defined you wont describe a for loop, or define the attributes of an object
in the top-down approach. Systems end up as a series of black boxes; components that have
specific inputs and outputs, but no definite internal structure.
Why Top-Down?

This approach lends itself to most projects, and doesnt require a specific kind of team or
breakdown

It allows large teams to split themselves amongst subsystems

Due to definite inputs and outputs of each subsystem, combining them is simplified

It encourages object-oriented programming (OOP) via encapsulation

It is still very successful for functional programming

It works very well for small projects, by laying out specific tasks to be done.

Easy to maintain, because of this subsystem partitioning

Why Not Top-Down?

It is difficult to guarantee that the initial design adequately models the desired system

It is tougher to do testing, as a large portion of the design must be done first

On a large projects, reduntant code may become an issue

Bottom-Up
If you know what Legos are, you know what bottom-up design is. It consists of defining and
coding the very basic, definite parts of the system to be designed, then linking these parts
together to form the whole.
Why Bottom-Up?

This approach allows teams to code functioning sub-systems quickly

Testing can be done early and often, as first-level systems are defined first

It encourages and leads to reusable code

Pre-existing code is simpler to incorporate and test

Why Not Bottom-Up?

Without some forethought, modules may be difficult to link together

The resulting system may be tangled and difficult to maintain

Without an overarching design, it can be difficult to define specific functionality for each
module

Example :These are two design approaches, which can be explained as:
You can imagine a tree like structure , in which when you
are following top-down appoarch you move from root node to
leaf node and when you follow bottom-up apprach you follow
leaf node to root node.
Top-down approach:

In this an overview of the system is first formulated,


specifying but not detailing any first-level subsystems.
Each subsystem is then refined in yet greater detail,
sometimes in many additional subsystem levels, until the
entire specification is reduced to base elements.
Bottom-up approach:
In this approach the individual base elements of the system
are first specified in great detail. These elements are
then linked together to form larger subsystems, which then
in turn are linked, sometimes in many levels, until a
complete top-level system is formed.

Task 2(LO 2: AC 2.1,2.2,2.3 and M1,M2)

Analyse and write a requirement specification for your system applying the any fact
finding methods

Perform an analysis of the problem using object-oriented techniques


An external view of the enterprise model of the student registration including student
records, department and staff information, course requirements, and class sche
dules will be developed using Unified Modeling Language (UML). This System
Requirement Specifications documents will form part of the documentation for the project.
Some desired features of the new system include:
The ability to search/view course offerings on-line
Provide transcripts on-line
Evaluate prerequisites for courses against student records
Inform students of registration stops and provide
ability to resolve and registration conflict(s)
Allow students to fill out applications for graduation and plans of study.
Scope and Limitations
Analysis methodology will involve business analysis, requ
irement analysis, data analysis, process analysis, (web)
and application architecture:

Business analysis State the business rules, business system interfaces, business function,
business ownership, sponsorship and associated project budget requirement
Requirement analysis System I/O description, user requirement definition, functional and
security requirement
Data analysis Involve data collection process, datavalidation, data storage, manipulation
and retrieval
Process analysis Data/process flow analysis, process decomposition and system interfaces
Application architecture Analyze
application information structure,
usability, user interface design,
interaction and application implementation

Design a relational database system to meet a given requirement


Draw Entity Relationship Diagram (ERD) identifying the main Entities and Relationships.
o

Explain entity types and Key attributes and their types in a data model.

o List the Primary key and foreign key(s) for each entity.

entity types

Strong Entity: Entities having its own attribute as primary keys are called strong entity.
For example, STUDENT has STUDENT_ID as primary key. Hence it is a strong entity.

Weak Entity: Entities which cannot form their own attribute as primary key are known
weak entities. These entities will derive their primary keys from the combination of its
attribute and primary key from its mapping entity.

Consider CLASS and SECTION entity. The SECTION has SECTION _ID and NAME as its
attribute. But SECTION _ID alone cannot be a primary key, since it fails to tell for which course
it is related to. We will not be uniquely identifying the course section by this attribute alone. But
if this attribute along with CLASS_ID gives the meaning for each section and we can uniquely
identify the sections.

Composite Entity: Entities participating in the many to many relationships are called
composite entity. In this case, apart from two entities that are part of relation, we will one
more hidden entity in the relation. We will be creating a new entity with the relation, and
create a primary key by using the primary keys of other two entities.
Consider the example, multiple students enrolled for multiple courses. In this case, we
create STUDENT and COURSE. Then we create one more table for the relation
Enrolment and name it as STUD_COURSE. Add the primary keys of COURSE and
STUDENT into it, which forms the composite primary key of the new table.

Recursive Entity: If a relation exists between the same entities, then such entities are
called as recursive entity. For example, mapping between manager and employee is
recursive entity. Here manager is mapped to the same entity Employee. HOD of the
department is another example of having recursive entity.

Key attributes

Simple Attribute
These kinds of attributes have values which cannot be divided further. For example,
STUDENT_ID attribute which cannot be divided further. Passport Number is unique
value and it cannot be divided.

Composite Attribute
This kind of attribute can be divided further to more than one simple attribute. For
example, address of a person. Here address can be further divided as Door#, street, city,
state and pin which are simple attributes.

Derived Attribute
Derived attributes are the one whose value can be obtained from other attributes of
entities in the database. For example, Age of a person can be obtained from date of birth
and current date. Average salary, annual salary, total marks of a student etc are few
examples of derived attribute.

Stored Attribute
The attribute which gives the value to get the derived attribute are called Stored Attribute.
In example above, age is derived using Date of Birth. Hence Date of Birth is a stored
attribute.

Single Valued Attribute


These attributes will have only one value. For example, EMPLOYEE_ID, passport#,
driving license#, SSN etc have only single value for a person.

Multi-Valued Attribute
These attribute can have more than one value at any point of time. Manager can have
more than one employee working for him, a person can have more than one email
address, and more than one house etc is the examples.

Simple Single Valued Attribute

This is the combination of above four types of attributes. An attribute can have single
value at any point of time, which cannot be divided further. For example,
EMPLOYEE_ID it is single value as well as it cannot be divided further.

Simple Multi-Valued Attribute


Phone number of a person, which is simple as well as he can have multiple phone
numbers is an example of this attribute.

Composite Single Valued Attribute


Date of Birth can be a composite single valued attribute. Any person can have only one
DOB and it can be further divided into date, month and year attributes.

Composite Multi-Valued Attribute


Shop address which is located two different locations can be considered as example of
this attribute.

Descriptive Attribute
Attributes of the relationship is called descriptive attribute. For example, employee works
for department. Here works for is the relation between employee and department
entities. The relation works for can have attribute DATE_OF_JOIN which is a
descriptive attribute.

Primary key
A primary key is a column or group of columns that uniquely identify a row. Every table should
have a primary key. And a table cannot have more than one primary key. The PRIMARY
KEY characteristic can be specified as part of a column definition, as in the first column of the
Country table, or it can be specified as a separate clause of the CREATE TABLE statement, as in the
statement that creates the Job table. The primary key in the Job table is made up of three
columns: job_code, job_grade, and job_country. While a value can appear more than once in any
of these columns taken individually, the fact that they are collectively a primary key means that
the three values taken together cannot occur in more than one row.

Foreign key
A foreign key is a column or set of columns in one table whose values must have matching
values in the primary key of another (or the same) table. A foreign key is said to reference its
primary key. Foreign keys are a mechanism for maintaining data integrity. In the Job table, for
example, any country listed in the job_country column must also exist in the Country table. By
stating that the job_country column of the Job table is a foreign key that references the
country column of the Country table, you are guaranteeing this, because InterBase will return an
error if a value is entered the job_country column that does not have a matching entry in the
country column of the Country table.

Build a relational database system based on a prepared design using any using appropriate
RDBMS software, e.g. Microsoft SQL Server, Oracle etc. Make sure you follow all the
necessary steps in building the database. In building the relational database, you are expected
to include the following:
relations, fields
data types
referential constraints
views, indexes
stored procedures, triggers etc

Apply a range of database tools and techniques to enhance the user interface
Draw a Context Diagram and a high Level Data Flow Diagram to depict the given system.

The aim of the presentation is to give information about the tools and
techniques used by two organisations in the use of databases and storing
data.
What is a database?

A database is a organised collection of inter-related data that is structured


into tables, records, fields, queries, reports, views and other objects.
The data is typically organized to model aspects of reality in a way that
supports processes requiring information.
Example
Use of database in a beauty salon
A beauty salon would use a database to record their customer information
such as;
Name
Address
Phone Number
Appointments
If they have any allergies (or anything that can prevent treatment)
A beauty salon can use a database to record staff information and can use it
to record if they need stock updated such as foundation, eye shadow, makeup brushes etc..
Data that can be stored for customers/staff
The information that can be recorded in a database for customers would
include;
Name
Address
Contact number
Allergies
Email
Appointments
Information for the staff would include;
Name
address
phone number
Their scheduled appointments
How a database is useful for a beauty salon
A database is very useful for a beauty salon because they would need to
include information about their customers so if they had a appointment they
could ring them to remind them and to record if they had any previous
appointments.
It would also be useful because if they had any allergies or something that
could stop them from getting treatment it is recorded in the database. It
would also be good because if they needed to restock any equipment they
can record what is needed.

Task 3(LO 3: AC 3.1,3.2,3.3 and D1)

1) Implement a query language into the relational database system


Obtain from the Users some representative enquiries for the Database. Formulate the
SQL queries to produce some reports. Make sure that you have enough data in your
database to show reports.

Problems of Concurrent transactions


Lost updates (Problems)
Time

T1

T1

T2

Balx

Begintransaction

90

T2

Begin-transaction

Read (balx)

90

T3

Read (balx)

Balx=balx+50

90

T4

Balx=balx-20

Write(balx)

140

T5

Write(balx)

commit

70

T6

ommit

Preventing Lost update problem

70

Time

T1

T1

T2

blax

Begin-transaction

200

T2

Begin-tansaction

Write-lock(balx)

200

T3

Write-lock(balx)

read(balx)

200

T4

WAIT

Balx=balx+100

200

T5

WAIT

Write(balx)

300

T6

WAIT

Commit/unlock(balx)

300

T7

Read(balx)

300

T8

Balx=balx-50

300

T9

Write(balx)

250

T10

Commit/unlock(balx)

250

Dirty Read problem(Uncommited Dependency Occurs when one transaction


can see intermediate results of other transaction before it has commited)

Time

T3

T4

balx

T1

Begin-transaction

150

T2

Read(balx)

150

T3

Balx=blax+30

150
180

150

T4

Begin-transaction

T5

Read(balx)

Write(balx)
.
.

T6

Blax=balx-20

rollback

180

T7

Write(balx)

160

T8

commit

160

Preventing Dirty Read with 2Phase protocol

Time

T3

T4

balx

T1

Begin-transaction

100

T2

Write-lock(balx)

100

T3

Read(balx)

100

T4

Begin-transaction

Balx=balx=100

100

T5

Write-lock(balx)

Write(balx)

200

T6

WAIT

Rollback/unlock(balx)

100

T7

Read(balx)

100

T8

Balx=balx-10

100

T9

Write(balx)

90

T10

Commit/unlockbalx)

90

Unrepeatable read problems (Inconsistent analysis Occurs when transaction


reads several but 2nd transaction updates same of them during execution of
first)
Tim
e

T5

T1

T6

blax

baly

balz

sum

50

Begin-transaction

200

60

Sum=0

200

60

50

Begin-transaction
T2
T3

Read(balx)

Read(balx)

200

60

50

T4

Balx=balx-20

Sum=sum+balx

200

60

50

200

T5

Write(balx)

Read(baly)

180

60

50

200

T6

Read(balz)

Sum=sum+baly

180

60

50

160

T7

Balz=balz+10

180

60

50

160

T8

Write(balz)

180

60

50

160

T9

commit

Read(balz)

180

60

65

160

T10

Sum=sum+balz

180

60

65

225

T11

commit

180

60

65

225

Preventing Unrepeatable Read with 2Phase locking (2Pl)


Tim
e

T5

T1

T6

bal
x

baly

bal
z

sum

Begin-transaction

10
0

100

50

Sum=0

10
0

100

50

10
0

100

50

T2

Begin-transaction

T3

Write-lock(balx)

T4

Read(balx)

Read-lock(balx)

10
0

100

50

T5

Balx=balx-15

WAIT

10
0

100

50

T6

Write(balx)

WAIT

85

100

50

T7

Write-lock(balz)

WAIT

85

100

50

T8

Read(balz)

WAIT

85

100

50

T9

Balz=balz+10

WAIT

85

100

50

T10

Write (balz)

WAIT

85

100

65

T11

Commit/unock(balx,baly,bal
z)

WAIT

85

100

65

Read(balx)

85

100

65

T12

T13

Sum=sum+balx

85

100

65

85

T14

Read-lock(baly)

85

100

65

85

T15

Read(baly)

85

100

65

85

T16

Sum=sum+baly

85

100

65

185

T17

Read-lock (balz)

85

100

65

185

T18

Read(balz)

85

100

65

185

T19
T20

Sum=sum+balz

85

100

65

250

Commit/unlock(balx,baly,b
alz)

85

10
0

65

Table Name: Booking


FIELD NAME
BID
PID
BusID

Table Name: Bus

DATA TYPE
varchar(30)
varchar(30)
varchar(30)

CONSTRAINT
Primary key
Not null
Not null

DESCRIPTION

25
0

FIELD NAME
BusID
BusNAME
BusType

DATA TYPE
varchar(30)
varchar(30)
varchar(30)

CONSTRAINT
Primary key
Not null
Not null

DESCRIPTION

CONSTRAINT
Primary key
Foreign key
Not null
Not null
Not null

DESCRIPTION

DATA TYPE
varchar(30)
varchar(30)
varchar(30)
varchar(30)
varchar(30)

CONSTRAINT
Primary key
Not null
Not null
Not null
Not null

DESCRIPTION

DATA TYPE
varchar(30)
varchar(30)

CONSTRAINT
Primary key
Foreign key

DESCRIPTION

Table Name: Bus_ Status

FIELD NAME
BSID
BusID
Source
Destination
Totalseats

DATA TYPE
varchar(30)
varchar(30)
varchar(30)
varchar(30)
varchar(30)

Table Name: Passengers


FIELD NAME
PID
PNAME
PHONE
ADDRESS
NRC

Table Name:Ticket

FIELD NAME
TID
PID

PNAME
Price
DepTime
SeatNo

varchar(30)
int
datetime
int

Not
Not
Not
Not

null
null
null
null

You might also like