Education and Research

We enable you to leverage knowledge anytime, anywhere!

RDBMS- Core Day1

Ver. No.:4.0 ER/CORP/CRS/DB92 Ver. No.: 0.1 Confidential Copyright © 2008, Infosys Technologies Ltd.

General Guideline
© (2008) Infosys Technologies Ltd. This document contains valuable confidential and proprietary information of Infosys. Such confidential and proprietary information includes, amongst others, proprietary intellectual property which can be legally protected and commercialized. Such information is furnished herein for training purposes only. Except with the express prior written permission of Infosys, this document and the information contained herein may not be published, disclosed, or used for any other purpose.

Copyright © 2008, Infosys Technologies Ltd.

2

Confidential

Confidential Information
 This Document is confidential to Infosys Technologies Limited. This document contains information and data that Infosys considers confidential and proprietary (“Confidential Information”). Confidential Information includes, but is not limited to, the following:
 Corporate and Infrastructure information about Infosys  Infosys’ project management and quality processes  Project experiences provided included as illustrative case studies

  

Any disclosure of Confidential Information to, or use of it by a third party, will be damaging to Infosys. Ownership of all Infosys Confidential Information, no matter in what media it resides, remains with Infosys. Confidential information in this document shall not be disclosed, duplicated or used – in whole or in part – for any purpose other than reading without specific written permission of an authorized representative of Infosys. This document also contains third party confidential and proprietary information. Such third party information has been included by Infosys after receiving due written permissions and authorizations from the party/ies. Such third party confidential and proprietary information shall not be disclosed, duplicated or used – in whole or in part – for any purpose other than reading without specific written permission of an authorized representative of Infosys.
Copyright © 2008, Infosys Technologies Ltd.

3

Confidential

Infosys Technologies Ltd. on time  Completion of the self review questions in the lab guide  Study and understand all the artifacts including the reference materials / e-learning / supplementary materials specified  Completion of the project (if applicable for this course) on time inclusive of individual and group activities  Taking part in the self assessment activities  Participation in the doubt clearing sessions Copyright © 2008.Learning approach  The following are strongly suggested for a better learning and understanding of this course:  Noting down the key concepts in the class. explained by the educator  Analyze all the examples / code snippets provided  Study and understand the self study topics  Completion and submission of all the assignments. 4 Confidential .

5 Confidential .C Map.RDBMS Core Copyright © 2008. Infosys Technologies Ltd.

6 Confidential .DML and DCL Languages  Concept of Joins  Concept of Sub Queries  Views Copyright © 2008.Course Objectives  Introduction of basic RDBMS concepts  Familiarization with SQL  Commands of DDL. Infosys Technologies Ltd.

Keys • ER Modeling • ERD Case Studies Day2 • Transforming an ER model to Relational Schema • Functional Dependencies • Normalization Day3 • Introduction to SQL and SQL Plus Day 4 • • • Day 5 • • • Day 6 • • Aggregate Functions Group By and Having clause Joins Independent Sub Queries Correlated Sub queries Use of EXISTS and NOT EXISTS Views DCL • DDL • DML (Till Order By) Copyright © 2008. 7 Confidential .Session Plan Day1 • Traditional Approach. • Why DBMS ? • Users of DBMS • Data Models • RDBMS. Infosys Technologies Ltd.

. Abraham Silberschatz. Second ed. Sixth ed. Third ed  C. Copyright © 2008. “Database system concepts”. 8 Confidential . "An introduction to Database Systems". Narosa Publications.  Elmasri. "Fundamentals of Database Systems". Infosys Technologies Ltd. Addison Wesley. Navathe. Computer Science Series(1991).. McGraw-Hill International editions.J.References  Henry F Korth.Date.

9 Confidential . Infosys Technologies Ltd.Session Plan Day1          Traditional File Approach Advantages of a DBMS Three layers of abstraction Users of DBMS Database Models Types of Databases Relational Model Basics Keys Conceptual Design  ER Modelling  ER Modelling Notations  ERD Case study  Merits & Demerits of ER Modeling Copyright © 2008.

dat Customer_Loan.Traditional Method of Data Storage Loan_Processing (Application Program) Fixed_Deposit_Processing (Application Program) Transaction_Processing (Application Program) File System Customer_Details.dat Customer_Fixed_Deposit.dat Customer_Transaction. 10 Confidential . Infosys Technologies Ltd.dat Copyright © 2008.

11 Confidential .Problems: Traditional Approach • • Data Security Data Redundancy • • • • Data Isolation Program / Data Dependence Lack of Flexibility Concurrent Access Anomalies Copyright © 2008. Infosys Technologies Ltd.

Infosys Technologies Ltd. 12 Confidential . • These set of programs allow users to access and modify files • Primary Goal is to provide a convenient and efficient way to store. retrieve and modify information Layer of abstraction between the application programs and the file system • Copyright © 2008.Database Management System • DBMS is consist of collection of interrelated files and set of programs.

13 Confidential . Infosys Technologies Ltd.Where does the DBMS fit in? Loan_Processing (Application Program) Fixed_Deposit_Processing (Application Program) Transaction_Processing (Application Program) DBMS File System Customer_Loan Customer_Details Customer_Transaction Customer_Fixed_Deposit Bank Database Copyright © 2008.

14 Confidential .Difference Between File and DBMS Operations File system Interface End User Application Programs DBMS Interface End User Application Programs Interface through Query (SQL) Interface through high level language SELECT * FROM Customer_Details READ CUSTOMER_DETAILS-FILE AT END STOP RUN DBMS Operating System (Disk Manager. File Manager) Customer_Details file Customer_Loan file File System (Disk Storage) Customer_Details table Customer_Loan table Database(Disk Storage) Copyright © 2008. File Manager) Operating System (Disk Manager. Infosys Technologies Ltd.

Infosys Technologies Ltd. 15 Confidential .Three-layer Architecture External / View Level (Individual User View) External Schema A External Schema B External Schema C Conceptual View (Common User View) Conceptual Schema Internal Level (Storage View) Internal Schema Copyright © 2008.

Infosys Technologies Ltd. 16 Confidential .Detailed System Architecture Mike (User) Graham (User) Jack (User) Justin (User) External Schemas External View A External View B Schemas & mappings built & maintained by the DBA External / conceptual mapping DBMS Conceptual Schema Conceptual view Conceptual / Internal mapping Database Administrator (DBA) Storage structure definition (Internal Schema) Database ( Internal view) Copyright © 2008.

Infosys Technologies Ltd.2)) External Conceptual Cust_ID Loan_No Amount_in_Dollars TYPE = BYTE (4). 17 Confidential . OFFSET = 8 Internal Copyright © 2008.An example of the three levels Customer_Loan Cust_ID : 101 Loan_No : 1011 Amount_in_Dollars : 8755. OFFSET = 4 TYPE = BYTE (7). OFFSET = 0 TYPE = BYTE (4).00 CREATE TABLE Customer_Loan ( Cust_ID NUMBER(4) Loan_No NUMBER(4) Amount_in_Dollars NUMBER(7.

18 Confidential .Users of a DBMS  Database Administrator (DBA)  Managing information contents  Liaison with users  Enforcing security and integrity rules  Strategizing backup & recovery  Monitoring performance  Database designers  Application programmers  End users Copyright © 2008. Infosys Technologies Ltd.

19 Confidential .Advantages of a DBMS  Data independence  Reduction in data redundancy  Better security  Better flexibility  Effective data sharing  Enforces integrity constraints  Enables backup and recovery Copyright © 2008. Infosys Technologies Ltd.

Data Models Definition of data model : A conceptual tool used to describe :  Data  Data relationships  Data semantics  Consistency constraints Copyright © 2008. 20 Confidential . Infosys Technologies Ltd.

21 Confidential . Infosys Technologies Ltd.Types of data models  Object based logical model  Entity relationship model  Record based logical model  Hierarchical data model  Network data model  Relational data model Copyright © 2008.

com 102 Smith S. 22 Confidential .00 1011 8755. Mike 1020 Savings Downtown Smith_Mike@yahoo.g. Infosys Technologies Ltd.00 E.com 1011 8755.Record based data model – Hierarchical data model ROOT 101 Smith A.com 2010 2555.00 103 Langer G. Justin 3421 Savings Plainsboro Langer_Justin@yahoo. Graham 2348 Checking Bridgewater Smith_Graham@rediffmail.: Information Management System (IMS) from IBM Copyright © 2008.00 2015 2000.

Record based data model – Network data model
101 Smith A. Mike 1020 Savings Downtown Smith_Mike@yahoo.com 1011 8755.00

102 Smith S. Graham 2348 Checking Bridgewater Smith_Graham@rediffmail.com 2010 2555.00 103 Langer G. Justin 3421 Savings Plainsboro Langer_Justin@yahoo.com 2015 2000.00 104 Quails D. Jack 2367 Checking Downtown Quails_Jack@yahoo.com Jones_Simon@rediffmail.com 2056 3050.00

105 Jones E. Simon 2389 Checking Brighton

E.g.: Integrated Data Management System(IDMS) from Honeywell
Copyright © 2008, Infosys Technologies Ltd.

23

Confidential

Record based data model – Relational data model

Copyright © 2008, Infosys Technologies Ltd.

24

Confidential

Relational model basics
 Data is viewed as existing in two dimensional tables known as relations  A relation (table) consists of unique attributes (columns) and tuples (rows)  Sometimes the value to be inserted into a particular cell may be unknown, or it may have no value. This is represented by a NULL  Null is not the same as zero, blank or an empty string  Relational Database: Any database whose logical organization is based on relational data model.  RDBMS: A DBMS that manages the relational database.

Copyright © 2008, Infosys Technologies Ltd.

25

Confidential

1 Copyright © 2008.  Primary Key During the creation of the table.Keys in relational model  Candidate key A Candidate key is a set of one or more attributes(minimal) that can uniquely identify a row in a given table. the Database Designer chooses one of the Candidate Key from amongst the several available. to uniquely identify row in the given table.  Alternate Key The candidate key that is chosen to perform the identification task is called the primary key and the remaining candidate keys are known as alternate keys. No of Alternate Keys = No of Candidate Keys . Infosys Technologies Ltd. 26 Confidential .

Infosys Technologies Ltd. 27 Confidential . OR  The attributes which do not participate in the Candidate key.Key and Non-key Attributes in Relational Model  Key Attributes The attributes that participate in the Candidate key are Key attributes  Non-Key Attributes  The attributes other than the Candidate Key attributes in a table/relation are called Non-Key attributes. Copyright © 2008.

PhoneNo) Assumptions: i.{FirstName. FirstName. 28 Confidential . ii. Email.{PhoneNo}. LastName.{FirstName. Empno for each trainee is different.{Email}.LastName} Primary key: {Empno} Alternate Key: {Email}. Infosys Technologies Ltd. PhoneNo for each trainee is different iv.Example Given a relation Trainee(Empno.{PhoneNo}.LastName} Copyright © 2008. Combination of FirstName and LastName for each trainee is different Candidate key: {Empno}. Email for each trainee is different iii.

L 3)Z. 29 Confidential .L Identify the following in relation R1? Candidate Key(s) Primary Key Alternate Key Key attribute(s) Non-key attribute(s) Copyright © 2008. Infosys Technologies Ltd. 1)X 2)X.Exercise on Key attributes Given a relation R1(X.Z.L) and the following attribute(s) can uniquely identify the records of relation R1.Y.

What are the candidate keys? Case 1 Assumptions One customer can have only one account An account can belong to only one customer while deciding the Candidate key do not get misguided by the data present in the table. Justin 3421Savings Plainsboro 104Quails D.com Jones_Simon@rediffmail. 30 Confidential .com Copyright © 2008.com Smith_Graham@rediffmail. Infosys Technologies Ltd. Mike 1020Savings Downtown 102Smith S.com Langer_Justin@yahoo. Simon 2389Checking Brighton Customer_Detail records from Customer_Details table Cust_Email Smith_Mike@yahoo.com Quails_Jack@yahoo. Graham 2348Checking Bridgewater 103Langer G. Cust_ID Cust_Last_ Cust_Mid Cust_First Account Account_ Bank_Branch Name _Name _Name _No Type 101Smith A. Jack 2367Checking Downtown 105Jones E.

Simon 2389Checking Brighton Customer_Detail records from Customer_Details table Cust_Email Smith_Mike@yahoo. Infosys Technologies Ltd.com Jones_Simon@rediffmail.com Copyright © 2008.com Quails_Jack@yahoo. 31 Confidential . Mike 1020Savings Downtown 102Smith S. Graham 2348Checking Bridgewater 103Langer G.What are the candidate keys? Case 2 Assumptions One customer can have many accounts An account can belong to only one customer Cust_ID Cust_Last_ Cust_Mid Cust_First Account Account_ Bank_Branch Name _Name _Name _No Type 101Smith A.com Langer_Justin@yahoo.com Smith_Graham@rediffmail. Justin 3421Savings Plainsboro 104Quails D. Jack 2367Checking Downtown 105Jones E.

Infosys Technologies Ltd.com Jones_Simon@rediffmail. Graham 2348Checking Bridgewater 103Langer G. An account can belong to more than one customer (joint account) Cust_ID Cust_Last_ Cust_Mid Cust_First Account Account_ Bank_Branch Name _Name _Name _No Type 101Smith A. 32 Confidential .What are the candidate keys? Case 3 : Assumptions One customer can have many accounts. Simon 2389Checking Brighton Customer_Detail records from Customer_Details table Cust_Email Smith_Mike@yahoo.com Copyright © 2008. Jack 2367Checking Downtown 105Jones E.com Langer_Justin@yahoo.com Quails_Jack@yahoo. Mike 1020Savings Downtown 102Smith S. Justin 3421Savings Plainsboro 104Quails D.com Smith_Graham@rediffmail.

com Quails_Jack@yahoo. Simon 2389Checking Brighton Customer_Detail records from Customer_Details table Cust_Email Smith_Mike@yahoo.com Langer_Justin@yahoo. Justin 3421Savings Plainsboro 104Quails D. Jack 2367Checking Downtown 105Jones E. Customer_Details Cust_ID Cust_Last_ Cust_Mid Cust_First Account Account_ Bank_Branch Name _Name _Name _No Type 101Smith A.Choosing a Primary key from Candidate keys -Guidelines  Give preference to numeric column(s)  Give preference to single attribute  Give preference to minimal composite key Primary Key of the table.com Copyright © 2008. Infosys Technologies Ltd. Mike 1020Savings Downtown 102Smith S.com Jones_Simon@rediffmail.com Smith_Graham@rediffmail. 33 Confidential . Graham 2348Checking Bridgewater 103Langer G.

DEPT (Parent /Master/Referenced Table) EMP (Child /Referencing Table) DeptNo DName EmpNo 1001 1002 1003 1004 EName Elsa John Maria Maida EDeptNo D1 D2 Null D1 D1 D2 IVS ENR  Points to remember  Foreign key values do not (usually) have to be unique.  Foreign keys can also be null .  To enter the data in child table corresponding data must be present in master table or NULL is the default entry in child table in the referenced column ( FK column) Copyright © 2008. Infosys Technologies Ltd. 34 Confidential .Foreign Key  Foreign key • A Foreign Key is a set of attribute (s) whose values are required to match values of a column in the same or another table.

Foreign Key  Foreign key  Points to remember  A Foreign Key is a set of attributes of a table. Infosys Technologies Ltd.  A table which has a Foreign Key referring to its own Candidate Key is known as Self-Referencing table Copyright © 2008. This is known as Referential constraint. whose values are required to match values of some Candidate Key in the same or another table  Foreign Key column must match the values of the corresponding Candidate Key column. 35 Confidential .

36 Confidential . Infosys Technologies Ltd.Education and Research We enable you to leverage knowledge anytime. anywhere! DATABASE DESIGN TECHNIQUE Copyright © 2008.

Another term used for this method is normalization from functional dependencies. Bottom Up approach In Bottom up approach we start defining required attribute first and then group these attribute to form the entities.Relationship modeling. Some references call this Entity . This approach generally leads to redundant information in one or more table. 37 Confidential .Database Design Techniques Top down Approach In Top down approach we start defining the data set and then we go on defining data elements in those sets. Infosys Technologies Ltd. Copyright © 2008.

anywhere! ER MODELING -TOP DOWN APPROACH Copyright © 2008. Infosys Technologies Ltd. 38 Confidential .Education and Research We enable you to leverage knowledge anytime.

 Entity: Any thing that may have an independent existence and about which we intend to collect data. etc.: Trainee Name. BatchName.: Trainee belongs to a Batch  Attributes: Properties/characteristics that describe entities. Infosys Technologies Ltd. 39 Confidential .  e. also known as Entity type. Copyright © 2008.  e.  e.g.g.: Trainee  Relationships: Associations between entities.ER modeling  ER modeling: A graphical technique for understanding and organizing the data independent of the actual database implementation.g. Address. DOB.

 Weak entity: Entity that depends on other entity for its existence and doesn’t have key attribute (s) of its own e. e. : spouse of employee Copyright © 2008. 40 Confidential .g.Entity Types  Regular Entity: Entity that has its own key attribute (s). Infosys Technologies Ltd. student .g.customer.: Employee. policy holder etc.

: the account number of an account. Infosys Technologies Ltd. the employee id of an employee etc. 2.: 1. married.g. The domain of attribute marital status is having four values: single. 41 Confidential . Copyright © 2008. divorced or widowed.Attributes  The set of possible values for an attribute is called the domain of the attribute e.g.  Key attribute: The attribute (or combination of attributes) that is unique for every entity instance  e. The domain of the attribute month is having twelve values ranging from January to December.

Example Gender of the employee Address of the employee Age of the employee Skill set of the employee Date of joining of the employee Years of service of the employee Copyright © 2008. Infosys Technologies Ltd. 42 Confidential .Attributes Types Types of Attributes Simple attribute Composite attribute Single valued Multi-valued Stored Attribute Derived Attribute Definition Cannot be divided into simpler components Can be split into components Can take on only a single value for each entity instance Can take up many values Attribute that need to be stored permanently Attribute that can be calculated based on other attributes.

: 1. employee works-for department is binary 3. 43 Confidential .Degree of a Relationship  Degree: the number of entity types involved » One Unary » Two Binary » Three Ternary e. shop keeper is a ternary relationship Copyright © 2008. employee manager-of employee is unary 2. Customer purchases items from a shop keeper » Here customer purchase item. Infosys Technologies Ltd.g.

g. 44 Confidential .Cardinality  Relationships can have different connectivity  one-to-one (1:1)  one-to-many (1:N)  many-to-one (M:1)  many-to-many (M:N) e.: Employee head-of department (1:1) Lecturer offers course (1:N) assuming a course is taught by a single lecturer Student enrolls course (M:N) Copyright © 2008. Infosys Technologies Ltd.

45 Confidential .g. Infosys Technologies Ltd.Relationship Participation  Total : Every entity instance must be connected through the relationship to another instance of the other participating entity types  Partial: All instances need not participate e.: Employee Head-of Department Employee: partial Department: total Copyright © 2008.

Infosys Technologies Ltd.Education and Research We enable you to leverage knowledge anytime.NOTATIONS Copyright © 2008. Confidential . anywhere! ER MODELING .

47 Confidential . A weak Entity requires another Entity for it’s existence. For example. Example Order Item depends upon Order Number for its existence.ER Modeling -Notations An Entity can be defined as an object or concept about which user wants to store information. an employee Entity can have multiple skill values. Properties or characteristics of an Entity is called Attributes of entity If an attribute is the unique or distinguishing characteristic of the Entity it is called Key Attribute If an attribute can have more than one value then it is called multi-valued attribute. Without Order Number it is impossible to identify Order Item uniquely. Infosys Technologies Ltd. Copyright © 2008.

Copyright © 2008. an employee's monthly salary is based on the employee's basic salary and House rent allowance. We connect a weak entity through a strong entity using a weak relationship notation. Infosys Technologies Ltd. 48 Confidential . Relationships in ER Diagram illustrate how two entities of database share information.ER Modeling -Notations If the value of an attribute can be derived from another attribute it is called derived attribute. For example.

employees can supervise other employees Copyright © 2008. 49 Confidential . Infosys Technologies Ltd. M.ER Modeling -Notations Customer 1 Cardinality of relationship tells how many instances of an Entity type is relate to one instance of another Entity Type.N both represent ‘MANY’ and 1 represents ‘ONE’ Cardinality N 1 Account M Transaction An entity can be self linked. For example.

Composite attribute floor building DOB Name Address E# Employee Designation Copyright © 2008. Infosys Technologies Ltd. 50 Confidential .

Infosys Technologies Ltd.Unary Relationship Employee Manages Copyright © 2008. 51 Confidential .

Role names  Role names may be added to make the meaning more explicit subordinate M Employee 1 Manager Manages Copyright © 2008. 52 Confidential . Infosys Technologies Ltd.

Binary Relationship Employee M Works for 1 Department Copyright © 2008. Infosys Technologies Ltd. 53 Confidential .

Ternary Relationship Medicine Doctor Prescription Patient Copyright © 2008. 54 Confidential . Infosys Technologies Ltd.

Infosys Technologies Ltd. 55 Confidential .Relationship participation Employee 1 head of 1 department Copyright © 2008.

Attributes of a Relationship Medicine Number of days dosage Doctor Prescription Patient Copyright © 2008. Infosys Technologies Ltd. 56 Confidential .

Weak entity Id ---1 N E# name Employee has dependant The dependant entity is represented by a double lined rectangle and the identifying relationship by a double lined diamond Copyright © 2008. 57 Confidential . Infosys Technologies Ltd.

58 Confidential . Infosys Technologies Ltd.Case Study – ER Model For a college DB Assumptions :           A college contains many departments Each department can offer any number of courses Many instructors can work in a department An instructor can work only in one department For each department there is a Head An instructor can be head of only one department Each instructor can take any number of courses A course can be taken by only one instructor A student can enroll for any number of courses Each course can have any number of students Copyright © 2008.

Infosys Technologies Ltd.Steps in ER Modeling  Identify the Entities  Find relationships  Identify the key attributes for every Entity  Identify other relevant attributes  Draw complete E-R diagram with all attributes including Primary Key  Review your results with your Business users Copyright © 2008. 59 Confidential .

Infosys Technologies Ltd. 60 Confidential .Steps in ER Modeling Step 1: Identify the Entities  DEPARTMENT  STUDENT  COURSE  INSTRUCTOR Copyright © 2008.

hence the cardinality between course and student is Many to Many. COURSE M ENROLLED BY N STUDENT  The department offers many courses and each course belongs to only one department. hence the cardinality between department and course is One to Many.Steps in ER Modeling Step 2: Find the relationships  One course is enrolled by multiple students and one student enrolls for multiple courses. DEPARTMENT 1 HAS INSTRUCTOR M Copyright © 2008. 61 Confidential . hence the cardinality between department and instructor is one to Many. DEPARTMENT OFFERS COURSE 1 M  One department has multiple instructors and one instructor belongs to one and only one department . Infosys Technologies Ltd.

DEPARTMENT 1 HEADED BY 1 INSTRUCTOR  One course is taught by only one instructor. Infosys Technologies Ltd. but the instructor teaches many courses. hence the cardinality between course and instructor is many to one.)  Each department there is a “Head of department” and one instructor is “Head of department “.Steps in ER Modeling Step 2: Find the relationships(Cont.hence the cardinality is one to one . M OFFERS 1 COURSE INSTRUCTOR Copyright © 2008. 62 Confidential ..

Infosys Technologies Ltd. Instructor Name is the key attribute for “Instructor” Entity.    Step 4: Identify other relevant attributes  For the department entity.prerequisite For instructor entity. student name. telephone# For student entity. Student# (Student Number) is the key attribute for “Student” Entity. duration. course name. 63 Confidential . the relevant attribute is location    For course entity. as it identifies the Department uniquely.Steps in ER Modeling Step 3: Identify the key attributes  Deptname is the key attribute for the Entity “Department”. Course# (CourseId) is the key attribute for “Course” Entity. room#. date of birth Copyright © 2008.

64 Confidential .Steps in ER Modeling Step 5: Draw the E-R diagram Copyright © 2008. Infosys Technologies Ltd.

the bill will be generated. 65 Confidential . user id and password. The application also mentions the information of suppliers who supply the items to the retail shop. Customer can purchase one or more items in different quantities . The customer will provide bank account number and bank name ( the customer may have multiple account no ). A customer can register to purchase an item. The items can be of different classes based on their prices. The retail shop may give orders to supply the items based on some statistics they maintain about different items. Infosys Technologies Ltd.Case Study – Online Retail Application(self study)  Draw an ER diagram of Online Retail Application which allows customer to purchase items from a Retail shop. A bank account number is required to settle the bill. price of item and discount(if any) on the purchased items.      Copyright © 2008. After registration each customer will have unique customer Id. Based on the quantity .

66 Confidential . Infosys Technologies Ltd.Steps in ER Modeling (self study) Step 1: Identify the Entities  CUSTOMER  ITEM  SUPPLIER  BILL Copyright © 2008.

So it is a ternary relation ship.  One customer can pay many bill and one bill can be paid by only one customer. So many to many relationship between item and supplier. So one to many relation ship between customer and bill.Steps in ER Modeling(self study) Step 2: Find the relationships  Customer can purchase an item and each purchase will be corresponding to a bill. Copyright © 2008. One supplier may take order of many items. 67 Confidential .  Items can be ordered to one or more suppliers. Infosys Technologies Ltd.

Steps in ER Modeling(self study) Step 3: Identify the key attributes     Customer entity will be identified by CustomerId Item entity will be identified by ItemId Supplier entity will be identified by SupplierId Bill entity will be identified by BillId Copyright © 2008. 68 Confidential . Infosys Technologies Ltd.

69 Confidential .Steps in ER Modeling(self study) Step 4: Identify other relevant attributes of Entities and Relationships  For Customer entity the relevant attributes will be (CustomerId.CustomerName. AccountNo.Class)  For Supplier entity the relevant attributes will be (SupplierID. DateOfRegistration. BillDate) Copyright © 2008. SupplierContactNo)  For Bill entity the relevant attributes will be ( BillId. Infosys Technologies Ltd. ItemName. UnitPrice.ReOrderQuantity. SupplierId. Discount. UnitOfMeasurement. QuantityOnHand. UserId. SupplierName. BillAmount. Password.ReOrderLevel. AccountNo)  For Item entity the relevant attributes will be (ItemId.

. 70 Confidential .Steps in ER Modeling(self study) Step 4: Identify other relevant attributes of entities and Relationships (Cont.)  For Purchase Relation the relevant attributes will be (QtyPurchased. Infosys Technologies Ltd. OrderDate. DeliveryDate. NetPrice)  For OrderedTo relation the relevant attributes will be (OtyOfOrder. DeliveryStatus)  For Pays relation the relivent attributes will be (AccountNo) Copyright © 2008.

Steps in ER Modeling (self study) Step 5: Draw complete E-R diagram with all attributes Copyright © 2008. Infosys Technologies Ltd. 71 Confidential .

 Can help in database design. Copyright © 2008. (This will be discussed when we study Normalization on day two)  Sometime diagrams may lead to misinterpretations because of limited information present in the diagram. Can be understood by non-technical specialist. 72 Confidential . Infosys Technologies Ltd. Demerits  Physical design derived from E-R Model may have some amount of redundancy which may lead to inconsistency.  Intuitive and helps in Physical Database creation.  Gives a higher level description of the system.Merits and Demerits of ER Modeling Merits  Easy to understand. Represented in Business Users Language.

Copyright © 2008.  E-R Modeling will also help the database design  E-R modeling has some amount of inconsistency and anomalies associated with it. Infosys Technologies Ltd.  It is always better to represent business findings in terms of picture to avoid miscommunication  It is practically impossible to review the complete requirement document by business users. 73 Confidential .Summary of ER Modeling  Miscommunication between the application user and the designer is the major source of error.  An E-R diagram is one of the many ways to represent business findings in pictorial format.

Summary          Traditional File Approach Advantages of a DBMS Three layers of abstraction Users of DBMS Database Models Types of Databases Relational Model Basics Keys Conceptual Design  ER Modelling  ER Modelling Notations  ERD Case study  Merits & Demerits of ER Modeling Copyright © 2008. Infosys Technologies Ltd. 74 Confidential .

and may not be disclosed in whole or in part at any time. This work may not be used. transferred. in any manner or form. Copyright in the whole and any part of this document belongs to Infosys Technologies Ltd. without the prior written consent of Infosys Technologies Ltd.” Copyright © 2008. copied or reproduced in whole or in part. abridged.Thank You “The contents of this document are proprietary and confidential to Infosys Technologies Ltd. sold. Infosys Technologies Ltd. 75 Confidential Confidential . All rights reserved.” “© 2008 Infosys Technologies Ltd. to any third party without the prior written consent of Infosys Technologies Ltd. or in any media. adapted.

Sign up to vote on this title
UsefulNot useful