Index: S.No NO. Need of The Project
Index: S.No NO. Need of The Project
Index: S.No NO. Need of The Project
1
2
NEED OF PROJECT
3
4
2.1 What is DBMS?
Users/programmers
Application Programs/Queries
DBMS
SOFTWARE Software to Process
Queries/Programs
Software to Access
Stored Data
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.
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.
7
DISADVANTAGES OF DBMS
8
2.2 THREE SCHEMA ARCHITECTURE OF A DBMS
(Conceptual level)
Defined by DBA
Conceptual View
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.
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.
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.
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
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
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.
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.
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.
Middle
First
name Last
name
name
Name
Employee
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.
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.
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.
CARDINALITY RATIO
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
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
DISADVANTAGE OF NORMALIZATION
The no. and complexity of joint increases with the increase in
normalization.
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.
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.
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.
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)
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.
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.
Non-procedural.
Common language for all relational database.
Integrity constraints.
Recovery and concurrency.
Security.
21
ORACLE DATA TYPES
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
CUSTOMER TABLE
26
ACCOUNT TABLE
LOAN TABLE
27
PAYMENT TABLE
28
29
SYSTEM CATALOG
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,
30
SYSTEM CATALOG
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,
31
SYSTEM CATALOG
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,
32
SYSTEM CATALOG
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,
33
SYSTEM CATALOG
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,
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