Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Index: S.No NO. Need of The Project

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 80

INDEX

S.NO CONTENTS PAGE


NO.
1 NEED OF THE PROJECT
2 AN OVERVIEW OF DBMS
2.1 DBMS AND ITS ADVANTAGES AND
DISADVANTAGES
2.2 THREE SCHEMA ARCHITECTURE
2.3 ENTITIES AND ATTRIBUTES AND
RELATIONS
2.4 KEYS
2.5 ER DIAGRAM NOTATION
2.6 NORMALIZATION
2.7 INTRODUCTION ABOUT SQL

3 CONCEPTUAL DATABASE DESIGN


4 SCHEMA DESIGN
5 SYSTEM CATALOG
6 DESIGN TABLES
7 QUERIES
8 JOINS
9 VIEWS

1
2
NEED OF PROJECT

Our project deals with computerization of a BANK SYSTEM.


Through computerization of this system we try to get easy & fast access of data
regarding various aspects in managing the bank like easier handling of data regarding
customer for their convenience and also help in faster coordination of data regarding
customer & the various facilities provided by the bank whenever required.

3
4
2.1 What is DBMS?

It is a collection of programs that enables users to create and maintain a database. It is a


General-purpose software system that facilitates the process of defining, constructing
and manipulating databases. Defining a database involves specifying the data types,
structures and constraints for the data to be stored in the database. Constructing the
database is the process of storing the data itself on some storage medium that is
controlled
DATABASE by the DBMS. Manipulating a database includes functions such as querying
the database to reflect changes in the miniworld, and generating reports from the data.
SYSTEM

Users/programmers

Application Programs/Queries

DBMS
SOFTWARE Software to Process
Queries/Programs

Software to Access
Stored Data

Stored Database Stored


Definition 5 Database
(Meta-Data)
ADVANTAGES OF DBMS

 CONTROLLED REDUNDANCY
In TFP, there is duplication of same data in several files. Centralized control of
data by the DBA (Database Administration) avoids unnecessary duplication of
data and effectively reduces the total amount of storage space required. It also
reduces duplication of effort needed to perform updates several times in each of
the files. Another advantage of in consistencies that tend to be present in
redundant data files. For example: - Birth date can be entered differently in two
places. In DBMS since the data is stored in only 1 place it doesn’t permit
inconsistency.

 SHARING OF DATA
A database allows the sharing of data under its control by any number of users or
application programs.

 INTEGRITY
Data integrity means that the data contained in the database is both accurate and
consistent. Centralized control can ensure that adequate checks are incorporated
in the DBMS to provide data integrity. For example: - Age of an employee should
be between 18 and 75.
If we are referring an object such an object should exists.

 SECURITY RESTRICTIONS CAN BE APPLIED


When multiple users share a database is likely that same users will not be
authorizes to access all information in the database i.e. confidential unauthorized
persons must not access data. In addition, some users may be permitted only to
retrieve data whereas others can read and write. DBA can ensure that proper
access procedures are followed before accessing sensitive data.

 STANDARS CAN BE ENFORCED

6
With central control of the database the DBA can ensure that all applicable
standards are followed in the representation of data. Data is necessary to help data
exchange between the systems.

 REDUCED APPRICATION DEVELOPMENT


In database approach, developing a new application takes very little time
designing and implementing a new database from scratch may take more time
than writing a single specialized file application. However, once a database is up
and running substantially less time is generally required to create new
applications using DBMS facilities.
 FLEXIBILTY
Sometimes it may be necessary to add a file to the database or to extent the data
elements in an existing file. Modern DBMS allow certain types of changes to the
structure of the data and existing application programs.

 AVIALABILITY OF UP-TO DATE INFORMATION


As soon as one users update is applied to the database all other users can
immediately see this update. This availability of up-to-date information is
essential for many online transactions processing applications (OLTPApp.) For
example: - reservation system or banking databases.

7
DISADVANTAGES OF DBMS

 A significant disadvantage of the DBMS system is cost because of initial


investment in hardware, software and training.

 The processing overhead introduced by the DBMS to implement security,


integrity, concurrency control and the recovery functions causes degradation of
the response and through put time.

8
2.2 THREE SCHEMA ARCHITECTURE OF A DBMS

View A View B View Z


… ……………
External level
User on application view
(Defined by app. Programmer
Consultation with DBA)

Mapping supplied by DBMS

(Conceptual level)
Defined by DBA
Conceptual View

Mapping supplied by DBMS

Internal level
Defined by DBA

External view

9
The goal of the 3-schema architecture is to separate the user application and the physical
database. In this architecture schemas can be defined at the following 3 levels.

 EXTERNAL LEVEL OTR USER LEVEL


User level/ external or user view

It is the highest level of database abstraction where only those portions of the
database of concerned to the user are included. Any number of user views may
exist for a given global or conceptual view. Each external view is described by
means of a schema called an external schema. It consists of the definition of the
logical records and the relationships in the external view. Each external schema
describes the part of the database that a particular user group is interested in and
hides the rest of the database from the user group.

 LOGICAL LEVEL / CONCEPTUAL OR GLOBAL VIEW

At this level of database abstraction all the database entities and the relationships
among them are included. This view is defined by conceptual schema. There is
only one conceptual schema per database. It describes all the records and the
relationships included in the conceptual view. The description of data at this level
is in a format independent of its physical representation. It also includes features
that specify the checks to retain data consistency and integrity.

 PHYSICAL LEVEL OR INTERNAL VIEW

This view is at the lowest level of abstraction, closest to the physical storage
method used. It indicates how the data will be stored and describes the data
structures and access methods to be used by the database.
This view is expressed by internal schema, which contains
the definition of stored record. The method of representing the data fields and
access aids used.

10
THREE VIEWS OF DATA

Logical Emp name Emp name


View Emp soc-sec-no
Emp address Emp address
Emp salary

Logical Record 1 Logical Record 2

Conceptual Emp name: string


View Emp soc-sec-no: key
Emp address: string
Emp skill: string
Emp salary: integer
Department: string

Conceptual record

Internal
Name: string length 25 offset 0
View
soc-sec-no: 9 dec offset 25 unique
Department: string length 6 offset 34
Address: string length 6 offset 40
Skill: string length 20 offset 91
Salary: 9,2 dec offset 111

Employee record length 120

11
MAPPING BETWEEN VIEWS
 EXTERNAL – CONCEPTUAL MAPPING
It is a mapping between the external and conceptual views. It gives the
correspondence among the records and the relationships of the external and
conceptual views. There is a mapping from a particular logical record in the
external view to one or more conceptual records in the conceptual view. It may
happen that the names of fields and the records may be different at 2 levels.

 CONCEPTUAL – INTERNAL MAPPING


It is the mapping between conceptual view and the internal view. It specifies how
each conceptual record is to be stored and the characteristics and size of each field
of the record i.e. it specifies the method of deriving the conceptual record from
the physical database.

DATA INDEPENDENCE

The 3-schema architecture can be used to explain the concept of data


independence. It is defined as the capacity to change the schema at one level of a
database system without having to change the schema at the next higher level.

 LOGICAL DATA INDEPENDENCE


It is defined as the capacity to change the conceptual schema without changing
external schemas. We may change the conceptual schema to expand the database
or to reduce the database. External schemas need not be changed only the view
definition and mappings need to be changed in a DBMS that supports logical data
independence.

 PHYSICAL DATA INDEPENDENCE

12
It is the capacity to change internal schema without having to change the
conceptual or external schemas. Changes to the internal schema may be needed
because some physical files had to be recognized to improve the performance of
retrieval or update.

2.3 ENTITY, ATTRIBUTES AND RELATIONSHIP

 ENTITY
It represents a real world object or concept for example: - employ, car, student etc

 ATTRIBUTES
Attributes are the particular properties that describe an entity for example: - car
entity has got colour, model, price, year of making these are its attributes.

SEVERAL TYPES OF ATTRIBUTES:

 COMPOSITE V/S SIMPLE (I.E. ATOMIC) ATTRIBUTES


Composite attributes can be divided into smallest sub parts i.e. other basic
attributes. Whereas simple or atomic attributes cannot be further subdivided into
smallest parts.
Example: - Name (first name, middle name, last name)
Address (street no., house no., area)

Middle
First
name Last
name
name
Name

Employee

 SINGLE VALUED V/S MULTIVALUED ATTRIBUTES


Attributes have a single value for a particular entity are called single valued
For example: - age of a person.

13
Attributes can have a set of values for the same entity
For example: - employ phone no. or college degree of a person

Phone no.

Employee - For multi -valued.

 STORED V/S DERIVED ATTRIBUTE


When 2 or more attribute values are related for example: - age and birth date
attributes of a person. The value of age can be determined from the current date
and the value of that person’s birth date. The age attribute is hence called a
derived attribute and is said to be derivable from the birth date attribute, which is
called the stored attribute.

Birth date

Employee Age

 NULL VALUES
Null value is used when a particular entity may not have an applicable value for
an attribute.
For example: - apartment no would exist only for people living in apartments
while other would be having a null value.
Null can also be used if we do not know the value of an attribute
for a particular entity.
For example: - phone no. of an employ if not known then a null value is put in.

 KEY ATTRIBUTES
An entity type has an attribute whose values are distinct for each entity. It is used
to uniquely identify a record in a table. For example: - toll no. of a student.

It has 2 main properties:


 Uniqueness constraints
 Not null values

Emp-id

Employee

14
VALUES SETS/ DOMAIN OF AN ATTRIBUTE

It specifies the set of values that may be assign to that attribute for each individual entity.

 RELATIONSHIP
It is an association between entities it is used to model the interaction that exist
among different entities. It is represented by diamond box.

Constraints on relationship type

 CARDINALITY RATIO

It specifies the no. of relationship instances that an entity can participate in

i. 1:1 cardinality
It means that an entity in A is associate with at most one entity in B and in
entity in B is associated with at most one entity in A

Manage
Emp s Dept
1 1

ii. 1:M or M:1 cardinality


An entity in A is associated with many no. of entities in B however
can be associated with at most one entity in A. example costumer
borrow loan.

M Works 1
Emp for dept

iii. M: N
An entity in A is associated with many no. of entities in B and an entity
in B is associated with any no. of entities in A.

15
2.4 CONCEPT OF KEYS

 SUPER KEY
It is the set of attributes whose combine value uniquely identified the entities in
the entities set. An entity set, which contains employee data the set of, attributes
(eid, ename, eadd) can be considered as a super key.

 CANDIDATE KEY
It is the minimal super key i.e. super keys for which no proper subset is a super
key.

 PRIMARY KEY
This key is used to uniquely identify each tuple in the entity in the set, primary
key values must not be null and must be unique throughout the column. A
multicolumn primary key is called a composite primary key.

 FOREIGN KEY
It represents the relation between the tables. A foreign key is a columns or a set of
columns whose values are derived from the primary key of any other table. The
existence of foreign key implies that a table with foreign key must have
corresponding primary key values in primary key table to have some meaning.

 ALTERNATE KEY
All other attributes other then the primary key attribute is called alternate key.

16
2.5 NOTATIONS IN ERD
 Entity

 Weak entity

 Relationship

 Identifying relationship

 Key attribute

 Attributes A

 Partial key

 Multivalued attributes

 Composite attributes

17
 Derived attributes

 Total participation
R E

2.6 NORMALIZATION
It is the process of analyzing the relations based on their fd’s and primary keys to
achieve the following desirable properties

 Minimizing redundancy
 Minimizing insertion, update and deletion anomalies

ADVANTAGES OF NORMALIZATION

 Few null values in the tables.


 Increases the performance of database.
 Database becomes compact.
 It helps to simply the string of tables.

DISADVANTAGE OF NORMALIZATION
 The no. and complexity of joint increases with the increase in
normalization.

SEVERAL NORMAL FORMS ARE:

 First normal form (1NF)


 Second normal form (2NF)
 Third normal form (3NF)
 Boyce-codd normal form (BCNF)
 Fourth normal form (4NF)
 Fifth normal form (5NF)

First normal form (1NF)

A table or relation schema is said to be in 1NF when each cell of the table
contains precisely 1 value i.e. if the values in the domain of each attribute of
the relation are atomic (simple, indivisible)

18
Various anomalies
 REDUNDANT INFORMATION
Data in the tables in the 1NF may be redundant.

 INSERTION ANOMALY
The department of a particular employ cannot be recorded until the
employ is assign a project.
 UPDATION ANOMALY
For a given employ the ecode and the department is repeated several
times. Hence if a employ is transferred to another department this
change will have to be recorded in every instance or record of the
employ. Any omissions will lead to inconsistencies.

 DELETION ANOMALY
If an employ completes work on all projects the employees record will
be deleted the information regarding the employees department will
also be lost.

Second normal form (2NF)

An attribute of relation schema R is called 0 prime attribute if it is a member


of sum candidate key of R. an attribute is called non prime if it is not a
prime attribute i.e. if it is not a member of any candidate key.

2NF is based on the concept of full functional


dependency (FFD). A FD X – Y (x determines y) is a FFD if removal of any
attribute A from X means that the dependency doesn’t hold anymore.
A FD x determines y is a partial dependency if some
attribute A E X can be removed from x and dependency still holds.

A relation R is in 2NF iff it is 1NF and every non-prime attribute is


FDD on the prime attribute .i.e if every attribute in the record is FD upon the
whole key and not just part of the key.
The table should there for decompose without any loss
of information into 2 tables emp-dept.1 and emp-proj1. The original table
can be reconstructed with a join and such decomposition is called non-loss
decomposition.

Third normal form (3NF)

3NF is based on the concept of transitive dependency.

19
AFD x-y in a relation schema R is a transitive dependency if there is a set of
attributes z i.e. neither a candidate key nor a subset of any key of R, and both
x-z and z-y holds.

The problems with this kind of dependency are:


 INSERTION
The department head of a new department does not have any employee
as yet cannot be entered. This is because primary key is unknown.

 UPDATION
For a given department the particular head’s code is repeated several
times. Hence, if the department is changed the change will have to be
made consistency across the table.

 DELETION
If there is a single record for adopt and that employ is deleted. Hence
there will also be a loss of information.

Boyce-codd normal form (BCNF)

A relation R is in BCNF iff every determinant is a candidate key.

The original definition of 3NF was inadequate in some situations. It was not
satisfactory for relations that:
Had multiple candidate keys where
i. The candidate keys were composite
ii. The candidate keys overlap (has at least 1 attribute in common)

Fourth normal form (4NF)

4NF is based on multi-valued dependency (MVD). An employ may work on


several projects and may have projects and dependents are independent of
each other. To keep the relation state consistent we must have a separate tuple
to represent every combination of an employee’s dependent and an employees
project.
1NF disallowed an attribute in a tuple to have a set of values. If we
have 2 or more multi-valued independent attribute in a same relation schema,
we get into a problem of having to repeat every value of one of the attributes
with every value of the other attribute to keep the relation state consistent and
to maintain the independence among the attributes involved. Informally

20
whenever 2 independent 1:N relationships A: B and A: C are mixed in the
same relation and MVD may arise.
The above relation contains redundant data and hence
leads to anomalies. We decompose employ into projects and employ
dependents.

2.7 INTRODUCTION TO SQL

It is the language used to access data within oracle database. SQL was originated
with the system are project in 1974 at IBM research center in 1986 ANSI adopted
SQL as a standard language for DBMS.
SQL is a set oriented language a query against one or
more data tables produces a result data table.

KEY FEATURES OF SQL

 Non-procedural.
 Common language for all relational database.
 Integrity constraints.
 Recovery and concurrency.
 Security.

CLASSIFICATION OF SQL STATEMENTS


SQL statements are divided into 3 sub languages.

 Data definition language


Use to define the objects in relational database. Example CREATE,
ALTER AND DROP.

 DML (Data manipulation language)


It is used for query, insertion, deletion and updation in the data stored in
the database example: SELECT, UPDATE, INSERT and DELETE.

 DCL (DATA CONTROL LANGUAGE)


It is used for controlling data and excess to database example:
COMMINT, REVOKE.

SQL plus is a product from Oracle Corporation that allowed user to


interact using SQL commands.

21
ORACLE DATA TYPES

 CHAR (w)-fixed character values of width w.Maximum width 255.


 VARCHAR 2(w)
Variable length character strings of maximum length 200 character.
 NUMBER (w,p)
It is used to stored numbers fixed or floating-point w stands for precision
and p for scale.
 DATE DD-MM-YY standard format.
 LONG
Variable length character value up to 2 gigabytes.

22
23
BANK ERD

B_C ADDRESS
ODE
B_PH
BANK
BRANCH
B_NAM
E
1

PROVID
E

C_DATE M
C_I L_NO
C_NAME L_DAT
D E

1 BORRO M
CUSTOMER LOAN L_du
W
ration

1 l_type
C_ADDR l_AMOUN
C_AGE ESS T
1
OPEN
S C_ph

M Loan-
paym
ent
A_NO
C_TYPE

ACCOUNT 24
Payment
P_no P_DATE P_amount
M

C_BALANCE

25
BANK_BRANCH TABLE

ATTRIBUTE DATA TYPE SIZE DESCRIPTION


S
B_code CHAR 4 IT IS BRANCH CODE

B_NAME VARCHAR2 15 IT DISPLAYS NAME OF


BRANCH

B_ph Number 7 Branch phone number


B_address VARCHAR2 30 Branch address

CUSTOMER TABLE

ATTRIBUTE DATA TYPE SIZE DESCRIPTION


S
C_ID CHAR 4 IT IS CUSTOMER ID

C_NAME VARCHAR2 15 IT DISPLAYS THE NAME OF


CUSTOMER

C_ADD VARCHAR2 30 IT DISPLAYS THE ADDRESS


OF THE CUSTOMER
C_PH NUMBER 8 IT DISPLAYS THE PHONE
NO. OF CUSTOMER
C_date DATE IT DISPLAYS THE DATE

26
ACCOUNT TABLE

ATTRIBUTE DATA TYPE SIZE DESCRIPTION


S
A_NO CHAR 4 IT DISPLAYS THE ACOUNT
NUMBER

C_BALANCE NUMBER 8,2 IT DISPLAYS THE ACCOUNT


BALANCE

C_TYPE VARCHAR2 15 IT DISPLAYS THE ACCOUNT


TYPE
C_ID CHAR 4 IT DISPLAYS THE
CUSTOMER ID

LOAN TABLE

ATTRIBUTE DATA TYPE SIZE DESCRIPTION


S
L_NO CHAR 4 IT IS BRANCH NUMBER

L_TYPE VARCHAR2 30 IT DISPLAYS THE TYPE OF


LOAN

L_AMOUNT NUMBER 8,2 IT DISPLAYS THE LOAN


AMOUNT
L_DATE DATE IT DISPLAYS THE TIME
PERIOD
L_DURATION NUMBER 4 IT DISPLAYS THE EARNING

27
PAYMENT TABLE

ATTRIBUTE DATA TYPE SIZE DESCRIPTION


S
P_NO CHAR 4 IT DISPLAYS THE PAYMENT
NO.
P_AMOUNT NUMBER 8 IT DISPLAYS THE AMOUNT

P_DATE DATE IT DISPLAYS DATE


L_NO CHAR 4 IT DISPLAYS THE LOAN
NUMBER

28
29
SYSTEM CATALOG

RELATIONAL ATTRIBUTES PRIMARY FOREIGN FOREIGN NOT


NAMES NAMES KEY KEY KEY NULL
RELATION
BANK B_CODE YES NO NO ----
BRANCH
BANK B_NAME NO NO NO ----
BRANCH
BANK B_PH NO NO NO ----
BRANCH
BANK B_ADDRESS NO NO NO ----
BRANCH

NORMALIZATION:-

1NF: This table is in 1nf as the values of all the attributes are atomic.

2NF:- This table is in 2nf as all the non-key attributes are full functional
dependent on primary key,

3NF:- This table is in 3nf as it is in 2nd and there is no dependency between


non-key attributes.

30
SYSTEM CATALOG

RELATIONAL ATTRIBUTES PRIMARY FOREIGN FOREIGN KEY NOT


NAMES NAMES KEY KEY RELATION NULL
LOAN L_NO YES NO NO ----
LOAN L_AMOUNT NO NO NO ----
LOAN L_DATE NO NO NO ----
LOAN L_DURATION NO NO NO ----
LOAN L_TYPE NO NO NO ----
LOAN C_ID NO YES CUSTOMER -----
LOAN B_CODE NO YES BANK_BRANCH -----

NORMALIZATION:-

1NF: This table is in 1nf as the values of all the attributes are atomic.

2NF:- This table is in 2nf as all the non-key attributes are full functional
dependent on primary key,

3NF:- This table is in 3nf as it is in 2nd and there is no dependency between


non-key attributes.

31
SYSTEM CATALOG

RELATIONAL ATTRIBUTES PRIMARY FOREIGN FOREIGN KEY NOT


NAMES NAMES KEY KEY RELATION NULL
CUSTOMER C_id YES NO NO ----
CUSTOMER C_NAME NO NO NO ----
CUSTOMER C_ADDRESS NO NO NO ----
CUSTOMER C_PH NO NO NO ----
CUSTOMER C_DATE NO NO NO ----
CUSTOMER C_AGE NO NO NO ----
CUSTOMER B_CODE NO YES BANK_BRANCH

NORMALIZATION:-

1NF: This table is in 1nf as the values of all the attributes are atomic.

2NF:- This table is in 2nf as all the non-key attributes are full functional
dependent on primary key,

3NF:- This table is in 3nf as it is in 2nd and there is no dependency between


non-key attributes.

32
SYSTEM CATALOG

RELATIONAL ATTRIBUTES PRIMARY FOREIGN FOREIGN NOT


NAMES NAMES KEY KEY KEY NULL
RELATION
PAYMENT P_NO YES NO NO ---
PAYMENT P_DATE NO NO NO ----
PAYMENT P_AMOUNT NO NO NO ----
PAYMENT L_NO NO YES LOAN ----

NORMALIZATION:-

1NF: This table is in 1nf as the values of all the attributes are atomic.

2NF:- This table is in 2nf as all the non-key attributes are full functional
dependent on primary key,

3NF:- This table is in 3nf as it is in 2nd and there is no dependency between


non-key attributes.

33
SYSTEM CATALOG

RELATIONAL ATTRIBUTES PRIMARY FOREIGN FOREIGN NOT


NAMES NAMES KEY KEY KEY NULL
RELATION
ACCOUNT A_NO YES NO NO ---
ACCOUNT C_ID NO YES CUSTOMER ----
ACCOUNT C_BALANCE NO NO NO ----
ACCOUNT C_TYPE NO NO NO ----

NORMALIZATION:-

1NF: This table is in 1nf as the values of all the attributes are atomic.

2NF:- This table is in 2nf as all the non-key attributes are full functional
dependent on primary key,

3NF:- This table is in 3nf as it is in 2nd and there is no dependency between


non-key attributes.

34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
Q1: Select all the values from Bank_branch and customer ?

51
Q2: Select all the values from account table ?

52
Q3: Select all the values of the loan table and payment table?

53
Q4:List names of branches beginning with’j’?

54
Q5: List all the customers whose name start with ‘A’ and has exactly 4 characters?

55
Q6:List the number of loans given by bank?

56
Q6: List maximum balance in accounts of bank

57
Q 8: List minimum duration of loan from loan table

58
Q9: List the customer C_id, the account number

59
Q10: List branch names with first alphabet in upper case

60
Q11: List branch name in upper case

61
Q12: List custid of customers who have account but no loan in the bank

62
Q13: Find all customers who have both an account and loan at the bank

63
Q14: List name of customers who don’t have a phoneno

64
Q15: List the total amount given as loan by bank

65
Q 16: List the average balance and number of accounts in the bank

66
Q17: List the average balance in each type of account
Sol:

67
Q18: List the paymentno corresponding to loannos l101,l103,l105

68
Q19: list the c_id , c_name arrange by c_name

69
Q20: Customer deposit money into bank

70
Q 21: Update the table ,add b_code create foreign key

71
72
73
Q1: List the details of all customers and their branch name

74
Q2: Give the detail of the loan,branch name and customer id

75
Q3: List the accountno, customer name, customer balance and branch code

76
Q4: List the amount of loan taken and amount of payment made for customer

77
78
Q1:Display all the contents of branch janakpuri .

79
Q2: Display all the contents of saving account.

80

You might also like