Unit - IV Application Structure Structure of DBMS: DBMS (Database Management System) acts as an interface between the user and the database. The user requests the DBMS to perform various operations such as insert, delete, update and retrieval on the database. The components of DBMS perform these requested operations on the database and provide necessary data to the users . Applications: - It can be considered as a user friendly web page where the user enters the requests. Here he simply enters the details that he needs and presses buttons to get the data. End User: - They are the real users of the database. They can be developers, designers, administrator or the actual users of the database. DDL: - Data Definition Language (DDL) is a query fired to create database, schema, tables, mappings etc in the database. These are the commands used to create the objects like tables, indexes in the database for the first time. In other words, they create structure of the database. DDL Compiler: - This part of database is responsible for processing the DDL commands. That means these compiler actually breaks down the command into machine understandable codes. It is also responsible for storing the metadata information like table name, space used by it, number of columns in it, mapping information etc.
28
Embed
Unit - IV Application Structure · Unit - IV Application Structure Structure of DBMS: DBMS (Database Management System) acts as an interface between the user and the database. The
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Unit - IV
Application Structure
Structure of DBMS:
DBMS (Database Management System) acts as an interface between the user and the database.
The user requests the DBMS to perform various operations such as insert, delete, update and
retrieval on the database.
The components of DBMS perform these requested operations on the database and provide
necessary data to the users
.
Applications: - It can be considered as a user friendly web page where the user enters the
requests. Here he simply enters the details that he needs and presses buttons to get the
data.
End User: - They are the real users of the database. They can be developers, designers,
administrator or the actual users of the database.
DDL: - Data Definition Language (DDL) is a query fired to create database, schema,
tables, mappings etc in the database. These are the commands used to create the
objects like tables, indexes in the database for the first time. In other words, they create
structure of the database.
DDL Compiler: - This part of database is responsible for processing the DDL
commands. That means these compiler actually breaks down the command into
machine understandable codes. It is also responsible for storing the metadata
information like table name, space used by it, number of columns in it, mapping
information etc.
DML Compiler: - When the user inserts, deletes, updates or retrieves the record from the
database, he will be sending request which he understands by pressing some buttons.
But for the database to work/understand the request, it should be broken down to
object code. This is done by this compiler. One can imagine this as when a person is
asked some question, how this is broken down into waves to reach the brain!
Query Optimizer: - When user fires some request, he is least bothered how it will be
fired on the database. He is not all aware of database or its way of performance. But
whatever be the request, it should be efficient enough to fetch, insert, update or delete
the data from the database. The query optimizer decides the best way to execute the
user request which is received from the DML compiler. It is similar to selecting the
best nerve to carry the waves to brain!
Stored Data Manager: - This is also known as Database Control System. It is one the
main central system of the database. It is responsible for various tasks
o It converts the requests received from query optimizer to machine
understandable form. It makes actual request inside the database. It is like
fetching the exact part of the brain to answer.
o It helps to maintain consistency and integrity by applying the constraints. That
means, it does not allow inserting / updating / deleting any data if it has child
entry. Similarly it does not allow entering any duplicate value into database
tables.
o It controls concurrent access. If there is multiple users accessing the database at
the same time, it makes sure, all of them see correct data. It guarantees that
there is no data loss or data mismatch happens between the transactions of
multiple users.
o It helps to backup the database and recover data whenever required. Since it is
a huge database and when there is any unexpected exploit of transaction, and
reverting the changes are not easy. It maintains the backup of all data, so that it
can be recovered.
Data Files: - It has the real data stored in it. It can be stored as magnetic tapes, magnetic
disks or optical disks.
Compiled DML: - Some of the processed DML statements (insert, update, delete) are
stored in it so that if there is similar requests, it will be re-used.
Data Dictionary: - It contains all the information about the database. As the name
suggests, it is the dictionary of all the data items. It contains description of all the
tables, view, materialized views, constraints, indexes, triggers etc.
User Interfaces
A user interface is the view of a database interface that is seen by the user. User interfaces are
often graphical or at least partly graphical (GUI - graphical user interface) constructed and offer
tools which make the interaction with the database easier.
Form-based interfaces
This interface consist of forms which are adapted to the user. He/She can fill in all of the fields
and make new entries to the database or only some of the fields to query the other ones. But
some operations might be restricted by the application.
Form-based user interfaces are wide spread and are a very important means of interacting with a
DBMS. They are easy to use and have the advantage that the user does not need special
knowledge about database languages like SQL.
Text-based interfaces
To be able to administrate the database or for other professional users there are possibilities to
communicate with the DBMS directly in the query language (in code form) via a input/output
window.
We will see this possibility later in the lesson Structured Query Language SQL.
Text-based interfaces are very powerful tools and allow a comprehensive interaction with a
DBMS. However, the use of these is based on active knowledge of the respective database
language.
GIS Interface
A GIS user interface often integrates features of a database interface. The database interaction
takes place through the combination of different interfaces:
Graphical interaction via a selection on the map
Combination of form-based and text-based interaction (e.g. special Query-Wizards for the easier
creation of database queries)
Transaction
A transaction can be defined as a group of tasks. A single task is the minimum processing unit
which cannot be divided further.
Let’s take an example of a simple transaction. Suppose a bank employee transfers Rs 500 from
A's account to B's account. This very simple and small transaction involves several low-level
tasks.
A’s Account
Open_Account(A)
Old_Balance = A.balance
New_Balance = Old_Balance - 500
A.balance = New_Balance
Close_Account(A)
B’s Account
Open_Account(B)
Old_Balance = B.balance
New_Balance = Old_Balance + 500
B.balance = New_Balance
Close_Account(B)
ACID Properties
A transaction is a very small unit of a program and it may contain several lowlevel tasks. A
transaction in a database system must maintain Atomicity, Consistency, Isolation, and Durability
− commonly known as ACID properties − in order to ensure accuracy, completeness, and data
integrity.
Atomicity − This property states that a transaction must be treated as an atomic unit, that is,
either all of its operations are executed or none. There must be no state in a database where a
transaction is left partially completed. States should be defined either before the execution of the
transaction or after the execution/abortion/failure of the transaction.
Consistency − The database must remain in a consistent state after any transaction. No
transaction should have any adverse effect on the data residing in the database. If the database
was in a consistent state before the execution of a transaction, it must remain consistent after the
execution of the transaction as well.
Durability − The database should be durable enough to hold all its latest updates even if the
system fails or restarts. If a transaction updates a chunk of data in a database and commits, then
the database will hold the modified data. If a transaction commits but the system fails before the
data could be written on to the disk, then that data will be updated once the system springs back
into action.
Isolation − In a database system where more than one transaction are being executed
simultaneously and in parallel, the property of isolation states that all the transactions will be
carried out and executed as if it is the only transaction in the system. No transaction will affect
the existence of any other transaction.
States of Transactions
A transaction in a database can be in one of the following states –
Active − In this state, the transaction is being executed. This is the initial state of every
transaction.
Partially Committed − When a transaction executes its final operation, it is said to be in a
partially committed state.
Failed − A transaction is said to be in a failed state if any of the checks made by the database
recovery system fails. A failed transaction can no longer proceed further.
Aborted − If any of the checks fails and the transaction has reached a failed state, then the
recovery manager rolls back all its write operations on the database to bring the database back to
its original state where it was prior to the execution of the transaction. Transactions in this state
are called aborted. The database recovery module can select one of the two operations after a
transaction aborts −
Re-start the transaction
Kill the transaction
Committed − If a transaction executes all its operations successfully, it is said to be committed.
All its effects are now permanently established on the database system.
Form Events
Events are things that happen to objects, such as the clicking of a command button or the
opening and closing of a form, etc. These events trigger an action to be carried out.
Events occur for forms when you open or close a form, move between forms, or work with data
on a form. An easy way to view the available Events for a Form (Control or Report) is to open
the properties window of the form.
Eg: In Microsoft Access form events can be used in the form of,
If you open a Form, the following Events occur in the following order:
Open
Load
Resize
Activate
(GotFocus)
Current
If there is no active Control on a Form, the GotFocus event will occur. If there is an Active
Control, the GotFocus Event will not occur. This is because the Focus is on the form rather than
a Control, and therefore this Event can occur if the focus is not on an on object within the form.
On Open Event
The Open Event occurs when a form is opened, but before the first record is displayed.
Therefore, attach code here that you wish to run as soon as the form is opened. The Open event
will not occur when you activate (move to a previously opened form), i.e. if you open a second
form from the first form, then close the second form, the first form’s On Open Event will not
occur as the first form has not been closed and re-opened, it has just been hidden behind the
second form.
If the Form is based on a Query, the Query is run prior to the On Open Event.
On Load Event
Whereas the on Open Event occurs when the form is opened and before the first record is
displayed, the On Load Event occurs when the first record is displayed.
On Resize Event
The Resize Event occurs when a form is opened or whenever the form’s size changes.
On Activate Event
The Activate Event occurs when a form receives the focus and becomes the active window.
You make a form active by: Opening it; Clicking on form with your mouse, or clicking a control
on the form; Invoking the SetFocus method. The On Activate event can only occur if the form is
visible. If the form is not visible an error will occur.
On GotFocus Event this rarely used Event only occurs when the form gets focus, but only if
there are no visible enabled controls on the form. Which is unlikely.
On Current Event
The On Current event occurs when the focus moves to a new or different record making it the
current record, or when the Form is Refreshed or Requeried.
This Event occurs when a form is opened, whenever the focus leaves one record and moves to
another, and when the Form’s underlying Table or Query is requeried. This event is one of the
more commonly used Events. If you wish to run code whenever a record is displayed, this is the
place to put it.
4.6 Custom Reports
Reports are typically printed on paper, but they are increasingly being created for
direct display on the screen.
Report can be used to format the data and present results from complex analysis.
4.6.1 VB.NET Crystal Reports for Beginners
Open Visual Studio .NET and select a new Visual Basic .NET Project.
Create a new Crystal Reports for Product table from the above database
crystalDB.
The Product Table has three fields (Product_id,Product_name,Product_price) and
we are showing the whole table data in the Crystal Reports.
From main menu in Visual Studio select PROJECT-->Add New Item . Then
Add New Item dialogue will appear and select Crystal Reports from the dialogue
box.
Select Report type from Crystal Reports gallery.
Accept the default settings and click OK.
Next step is to select the appropriate connection to your database. Here we are
going to select OLEDB connection for SQL Server
Select OLE DB (ADO) from Create New Connection .
Select Microsoft OLE DB Provider for SQL Server .
Next screen is the SQL Server authentication screen . Select your Sql Server name ,
enter userid , password and select yourDatabase Name . Click next , Then the screen shows
OLE DB Property values , leave it as it is , and click finish.
Then you will get your Server name under OLEDB Connectionfrom there select database name
(Crystaldb) and click the tables , then you can see all your tables from your database.
From the tables list select Product table to the right side list .
Click Next Button
Select all fields from Product table to the right side list .
Click Finish Button. Then you can see the Crystal Reports designer window . You can arrange
the design according your requirements. Your screen look like the following picture.
Now the designing part is over and the next step is to call the created Crystal Reports in VB.NET
through Crystal Reports Viewer control .
Select the default form (Form1.vb) you created in VB.NET and drag a button
and CrystalReportViewer control to your form.
Select Form's source code view and put the code on top
Imports CrystalDecisions.CrystalReports.Engine
Put the following source code in the button click event
Next : VB.NET Crystal Reports from multiple tables