Presentation is loading. Please wait.

Presentation is loading. Please wait.

Database Concepts.

Similar presentations


Presentation on theme: "Database Concepts."— Presentation transcript:

1 Database Concepts

2 Introduction Database: A Database is a collection of interrelated data. Database System: It is basically a computer based record keeping system.

3 PURPOSE OF DATABASES Database reduce the data redundancy. (Duplication of data is known as DATA REDUNDANCY) Databases can control data inconsistency. (An inconsistent Database will provide incorrect or Conflicting information) Databases facilitate sharing of data. Database enforce standards. Databases can ensure data Security. Integrity can be maintained through databases.

4 Various levels of Data Abstraction in a Database System
View 1 View 2 View 3 Conceptual Level Physical Level

5 1) Internal Level (Physical Level)
This level Describes how the data is actually stored on the storage medium.At this level complex low-level data structures are described in details.

6 2) Conceptual Level This level describes WHAT data are actually stored in the database. It also describes the relationships existing among data. At this level, the database is described logically in terms of simple data-structures.

7 3) External Level (View Level)
This level is concerned with the way the data is viewed by the individual users. Only a part of the database relevant to the user(s) is provided to them through this level.

8 DATA INDEPENDENCE Since the databases keep on growing, there may be frequent changes at times. This should not lead to the redesigning and reimplementation of the database. The concept of data independence proves beneficial in such a context. The ability to modify a scheme definition in one level without affecting a scheme definition in the next higher level is called DATA INDEPENDENCE.

9 There are two levels of Data Independence
Physical Data Independence : It refers to the ability to modify the scheme followed at the Physical level without affecting the scheme followed at the Conceptual level. Logical Data Independence : It refers to the ability to modify the scheme followed at the Conceptual level without affecting the scheme followed at the View level.

10 DATA MODELS Relational Data Model Network Data Model
A Data Model is a collection of conceptual tools for describing data, data relationships, data semantics etc. Relational Data Model Network Data Model Hierarchical Data Model

11 Relational Data Model It represents data and relationships among data by a collection of tables known as relations, each of which has a number of columns with unique names.

12 Relational Data Model

13 Network Data Model The Network Model represents data by collection of Records and relationships among data are represented by links which can be viewed as pointers.

14 Network Data Model

15 Hierarchical Data Model
The Hierarchical Data Model is similar to the network model in the sense that data and relationships among data are represented by records and links respectively. It differs from the Network model, in that the records are organised as collection of TREES rather than arbitrary graphs.

16 Hierarchical Data Model

17 TERMINOLOGY Relation : A Table Tuple : The rows of Tables (Relations)
Different terms used in the Relational Model are: Relation : A Table Tuple : The rows of Tables (Relations) Attributes : The columns of Tables (Relations) Degree : The number of attributes in a relation. Cardinality: The number of tuples (rows) in a relation.

18 VIEW Views are like windows through which we can view desired information that is actually stored in a base table A view is a (Virtual) table that does not really exist in its own right but is instead derived from one or more existing base tables.

19 KEYS Primary Key: A Primary Key is a set of one or more attributes that can uniquely identify tuples within the relation Candidate Key: All attribute combinations inside a relation that can serve as Primary key are Candidate Keys as they are candidates for the Primary key position.

20 Alternate Key: A candidate key that is not the Primary key is called an Alternate Key.
Foreign Key: A non-key attribute, whose values are derived from the primary key of some other table, is known as Foreign-key in its current table.

21 Relational Algebra

22 Notation Projection Selection Union Intersection Cartesian product

23 Selection SQL Result Relational algebra salary < 200(E)
The same table E (for EMPLOYEE) as above. SQL Result Relational algebra select * from E where salary < 200 salary < 200(E) nr name salary 1 John 100 7 Tom 100 select * from E where salary < 200 and nr >= 7 salary < 200 and nr >= 7(E) nr name salary 7 Tom 100 Note that the select operation in relational algebra has nothing to do with the SQL keyword select. Selection in relational algebra returns those tuples in a relation that fulfil a condition, while the SQL keyword select means "here comes an SQL statement".

24 nr name salary SQL Result Relational algebra
Projection Example: The table E (for EMPLOYEE) nr name salary 1 John 100 5 Sarah 300 7 Tom 100 SQL Result Relational algebra select salary from E salary salary(E) 100 300 select nr, salary from E nr, salary(E) nr salary 1 100 5 300 7 100 Note that there are no duplicate rows in the result.

25 UNION Rollno Name Age Rollno Name Age Rollno Name Age Song Drama
13 Kush 15 2 Maya 15 17 Swati 14 10 Rishabh 15 13 Kush 15 The result of Drama U Song will be Rollno Name Age 2 Maya 15 10 Rishabh 15 13 Kush 15 17 Swati 14

26 SET DIFFERENCE OPERATION
Song Drama Rollno Name Age Rollno Name Age 13 Kush 15 2 Maya 15 17 Swati 14 10 Rishabh 15 13 Kush 15 The result of Drama - Song will be Rollno Name Age 17 Swati 14

27 SET INTERSECTION OPERATION
Song Drama Rollno Name Age Rollno Name Age 2 Maya 15 13 Kush 15 10 Rishabh 14 17 Swati 14 13 Kush 15 The result of Drama Song will be Rollno Name Age 13 Kush 15

28 Prepared by CH. Venugopala Rao PGT (Computer Science) KV, Gill Nagar Chennai


Download ppt "Database Concepts."

Similar presentations


Ads by Google