You are on page 1of 53

Database Concepts


 Is an integrated collection of interrelated files, along with details of the interpretation of the data contained therein.  Is a collection of interrelated and interactive data files which avoids unnecessary Redundant data and which has Data independence


What is DBMS ?
 Stands for Database Management Systems.  Is a Software that allows access to data contained in a Database.  The Objective of DBMS is to provide a convenient and effective method of defining, storing and retrieving the information contained in the database.


Terms used in DBMS
      Entities & Entity types Attributes Domains Key Relationships Records and files


Entities & Entity types
 Entities are the basic units used in modeling classes of concrete or abstract objects. For example a person, place or thing.  Entity type or Entity set is a group of similar objects of concern to an organization for which it maintains data. Examples of Entity set are job positions, courses, employees, products etc.


6 . elementary items. data element. items. or object property.Attributes  The properties that characterize an entity set are called its Attributes. data field.  An Attribute is also referred to by the terms data items.

Example of Attributes GUEST Name Soc_Sec_No Address Room No 7 .

8 .  Example: The set of values that the attribute Employee.Domains  Each Attributes of an entity set has a particular value.Soc_Sec_No can assume is a positive integer of 9. The set of possible values that given attribute can have is called its domain.

 This attribute is unique and will identify an instance of the entity set. 9 .  Such attributes which uniquely will identify an entity set is called a PRIMARY KEY.Key  A key is a single attribute or combination of two or more attributes of a entity set that is used to identify one or more instances of the set.

Relationships  The Relationship set is used in data modeling to represent an association between entity set.A grade is a attribute of the ENROLLMENT relationship set between the entity sets COURSE and STUDENT. 10 .  This associations could have certain properties represented by the attributes of the relationship set.

 An instance of record is a RECORD.  Such a representation is called a RECORD TYPE. 11 .Records and Files  The physical representation of an entity set is made by aggregating the attributes used to model the entity set .

What is Meta Data ?  Data about Database 12 .

Abstract and Data Integration Non Database environment without any shared data. Application 1 Application 2 Offline data Online Data Offline data Online Data 13 .

 In a non database operating environment consisting of a number of application programs .  Sharing of data is achieved in this environment by duplicating common data.  Each application program is responsible for maintaining its own set of data and a change in a data item must be effected in each copy of the data. 14 .Abstract and Data Integration contd….  The necessary data is stored in private files. each such application has its own need of viewing the real world.

Application 1 Application 2 Database Management System Online Data Online Data 15 .Abstract and Data Integration Database environment with shared data.

16 .Who is a DBA?  A Person (Or Group of Persons) who has the responsibility of controlling the Centralized data of a database environment.

17 .Conceptual record and two views of it  Changes in the conceptual record do not affect the application programs in a data base environment  In a non database environment the logical record as viewed by the application program is identical to the conceptual record.  In a database environment the logical record as viewed by the application program need not be the same as the conceptual record. and the physical record is determined and controlled by the application program.

Sec-No Employee Salary Logical Record 2 User 2 Employee Name Employee Address Employee Soc.Example of Conceptual record Employee Name Employee Address Logical Record 1 User 1 Employee Name Employee Address Employee Soc.Sec-No Employee Salary Employee Skill Set Conceptual Record DBA 18 .

The Three views of Data  Logical View (Users)  Conceptual View (DBA)  Internal View 19 .

2 Dec Skill : String length 20 20 .Sec-No Conceptual view Employee Name Employee Address Employee Soc.Sec-No Employee Salary Employee Salary Internal View Name : string length 25 Address: String length 51 Soc_Sec_No: Dec 9 offset Employee Skill Set Salary : 9.Logical View Employee Name Employee Address Employee Name Employee Address Employee Soc.

Defined by DBA. seen by the application programmer or user.  The lowest level. is the internal view. or simply view. Defined by DBA for Optimization.  The next level of abstraction is the sum of user views. called the Global View or conceptual view. is called External view.Database Design Abstraction Using Level of  Abstraction of Data can be done in the three Levels as shown in previous slide  The highest level. Defined by user or Programmer. 21 . a description of actual method of storing data . user view.

Scheme & Schema  The view of data at each levels as described previously is known as SCHEME. 22 . is used interchangeably in the database with the word SCHEMA.  It also describes the way in which Entities at one level of Abstraction can be mapped to the next level.  SCHEME means a Systematic Plan for attending some goal.  A SCHEME is an OUTLINE or PLAN that describes the records and relationships existing in the view.

23 .Conceptual Vs Physical Database  Conceptual Database is the model or abstraction of the objects of concern to the database.  Physical database is the data that is stored on secondary storage devices.

What is Data Independence  Logical Data Independence  Physical Data Independence 24 .

 Logical Data Independence also insulates application programs from operations such as combining two records into one or splitting and existing record into two or more records.Logical Data Independence  It indicates that the conceptual schema can be changed without affecting the existing external schema. 25 .

Physical Data independence  It indicates that the Physical storage structures or devices used for storing the data could be changed without necessitating a change in the conceptual view or any of the external views. 26 .

Summarizing DBMS  A DBMS is a complex software system that is used to manage. store and manipulate data and the metadata used to describe the data. 27 .

Types of DBMS  Flat file Structures  Hierarchical Database Management Systems (HDBMS)  NET WORK Database Management Systems  Relational Database Management Systems (RDBMS)  Object Relational Database Management Systems (ORDBMS) 28 .

 Database features included in spreadsheets are based on a flat-file structure. 29 .Flat file Structures  A database with a single table is called a flat file structure.  A flat-file structure is good only for extremely simple databases  Many spreadsheets include some database features like sorting entries and counting or summarizing entries that meet certain criteria.

and thus an increased chance of errors. 30 .Example of Flat file Structure A Single Kind of Record with Fixed number of fields Notice the repetition of data.

 All fields have only one “parent”.  A“tree” of records in which each record contains two elements  A root or master field. location or ordering of the records . each parent may have many “children” . (a key). which identifies the type.  31 .Hierarchical Database Management Systems The hierarchical data model is set up like a "forest" or collection of tree structures.  Subordinate fields which define the rest of the data within a record .

Example of HDBMS 32 .

Example Of HDBMS Contd.. Question #1: What is the average weight of babies delivered by Jones to mothers with heights > 170 cm? 33 .

34 . Now we've found Jones . Question #1: What is the average weight of babies delivered by Jones to mothers with heights > 170 cm? First we scan through the Physician records looking for Jones...Example Of HDBMS Contd..

.Example Of HDBMS Contd. Question #1: What is the average weight of babies delivered by Jones to mothers with heights > 170 cm? . This mother's height is > 170 cm 35 ... so we scan through the relevant Mother records looking for mothers with heights > 170 cm.

Question #1: What is the average weight of babies delivered by Jones to mothers with heights > 170 cm? . so we scan through her babies looking at the weights. We've read 6 records in all... 36 ..Example Of HDBMS Contd. Now we can calculate the average weight for these two babies.

and each relationship must be explicitly defined when the database is created . 37 .Pros & Cons Of HDBMS  Pros: speed and efficiency for certain kinds of applications.  Cons: how data is accessed is predefined. The hierarchical data model is a good choice when the data to be modeled is also like a tree.

38 .  The Advantage of Network Database Management Systems over HDBMS is that the Access path is not fixed in Network compared to HDBMS.Network Database Management Systems  A Network Database Management Systems is just like HDBMS with modifications wherein each Child Node can be connected to More than one Parent Node via connectors.

39 .  It is the basis for the Relational database management systems (RDBMS). E. F.Relational Database Management Systems  Dr. Codd proposed the relational model for database systems in June 1970 in his paper called “A Relational Model of Data for Large Shared Data Banks “.

40 .  Rule 3: The systematic treatment of Null values: It is fundamental to DBMS that null values are supported in the representation of missing and inapplicable information.  Rule 2: The rule of guarantied access: Every item of data must be logically addressable by resorting to a combination of table name. primary key value and column name.The Codd Rules The Codd 12 rules are as follows:  Rule 1: The information rule: All information is explicitly and logically represented in one way – by data values in tables.

 Rule 4: The Database description rule: The description of database is held and maintained using some logical structures used to define the data.. Rule 5: The comprehensive sub-language rule: There must be at least one language which statements can be expressed as character and strings confirming to some well defined syntax. that is comprehensive in supporting the following:  Data definition  View definition  Data Manipulation  Interpretation Constraints  Authorization  Transaction Boundaries 41  .The Codd Rules Contd. thus allowing users with appropriate authority to query such information in the same ways and using the same languages as they would any other data in the database.

.The Codd Rules Contd. Rule 7: The insert and Update rule: The capability of handling the base relation or in fact a derived relation.   Rule 6: The View Updating rule: All views that can be updated in theory can also be updated by the system. when ever changes to the storage representation or access method to the data are changed. is a single operand must hold good for all retrieve. delete and insert activities. Rule 9: The Logical independence rule: Application programs and terminal activities must remain logically unimpaired when ever information preserving changes of any kind that are theoretically permitted and made to the base tables. Rule 8: The Physical independence rule: User access to the database via terminals monitors or application programs must remain logically consistent. updated. 42   .

 No components of PRIMARY KEY can have missing values.and stored in database as data in tables (meta data). The following integrity rule should apply to every relational database.. This is the basic rule of entity integrity.  For each distinct FOREIGN KEY value there must exist a matching PRIMARY KEY value in the same domain. 43 . Confirmation to this rule ensures what is called Referential integrity.  Rule 10: The Integrity independence rule: An integrity constraint defined for the database must be definable to the language referred in rule 5.The Codd Rules contd.

 44 . Rule 12: The sub version rule: If a RDBMS supports a lower level language that permits for example now at a time processing from this language must not be able to bypass any integrity rules or constraints defined in the higher level set at a time.distributed database must remain logically impaired if the data should then become distributed in the context of distributional relational database..The Codd Rules contd.  Rule 11: The Distribution rule: An RDBMS must have Distribution independence that is application running on a non. relational language.

 Data Integrity for accuracy and consistency. 45 .  Set of Operators to act on the relations.Components of the Relational Model The relational model consists of the following:  Collection of objects or relations.

you create several tables to store different pieces of information about your employee such as an employee table. and a Salary table. in order to store information about all the employees in your company. In a relational database .Definition of a Relational Database  A Relational Database is a collection of relations or two-dimensional tables to store information. 46 . a department table.  Example.

Example of Relational Database 47 .

Row Or Tuple. Primary Key. Column or Attribute. Field or Cell. Null.Relational Database Terminology        Tables or Relation. 48 . Foreign key.

Relating Multiple Tables  Each Row of data in a table is uniquely identified by a primary key (PK).  You can logically relate data from multiple tables using the foreign keys (FK). 49 .

Guidelines for PK and FK  No Duplicate values are allowed in a primary key.  You cannot define foreign keys without existing primary (unique) keys.  A Foreign key Values must match an existing primary key value or unique key values. or else be null. 50 . pointers. not physical.  Foreign keys are based on data values and are purely logical.

 Use a set of operators.  Contains a collection of tables. 51 .Relational Database Properties A Relational database  Can be accessed and modified by executing structured query Language (SQL) Statements.

retrieve.Structured Query Language Sql Allows you to communicate with database server and has the following advantages:  Efficient  Easy to Learn and use  Functionally complete (Sql allows you to define.) 52 . and manipulate data in the tables.

encapsulation. involving abstraction. modularity and hierarchy (with inheritance). 53 .Object Relational Database Management Systems  Object-oriented analysis is another way to model the world.