Upcoming SlideShare
×

# 02 rdbms session02

1,135 views

Published on

Published in: Technology
2 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
Your message goes here
• Be the first to comment

Views
Total views
1,135
On SlideShare
0
From Embeds
0
Number of Embeds
14
Actions
Shares
0
0
0
Likes
2
Embeds 0
No embeds

No notes for slide
• Students have learnt the structure of different types of dimensions and the importance of surrogate keys in Module I. In this session, students will learn to load the data into the dimension tables after the data has been transformed in the transformation phase. In addition, students will also learn to update data into these dimension tables. Students already know about different types of dimension tables. Therefore, you can start the session by recapitulating the concepts. Initiate the class by asking the following questions: 1. What are the different types of dimensions? 2. Define flat dimension. 3. What are conformed dimension? 4. Define large dimension. 5. Define small dimension. 6. What is the importance of surrogate key in a dimension table? Students will learn the loading and update strategies theoretically in this session. The demonstration to load and update the data in the dimension table will be covered in next session.
• Students know the importance of surrogate keys. In this session students will learn the strategy to generate the surrogate key. Give an example to explain the strategy to generate the surrogate keys by concatenating the primary key of the source table with the date stamp. For example, data from a Product table has to be loaded into the Product_Dim dimension table on Feb 09, 2006. The product_code is the primary key column in the Product table. To insert the surrogate key values before loading the data into the dimension table, you can combine the primary key value with the date on which the data has to be loaded. In this case the surrogate key value can be product_code+09022006.
• Students have learnt the structure of different types of dimensions and the importance of surrogate keys in Module I. In this session, students will learn to load the data into the dimension tables after the data has been transformed in the transformation phase. In addition, students will also learn to update data into these dimension tables. Students already know about different types of dimension tables. Therefore, you can start the session by recapitulating the concepts. Initiate the class by asking the following questions: 1. What are the different types of dimensions? 2. Define flat dimension. 3. What are conformed dimension? 4. Define large dimension. 5. Define small dimension. 6. What is the importance of surrogate key in a dimension table? Students will learn the loading and update strategies theoretically in this session. The demonstration to load and update the data in the dimension table will be covered in next session.
• Students know what is the structure of Flat dimension. You can initiate the session by asking the following questions: 1. What are flat dimension tables? 2. What is the structure of flat dimension? 3. Given examples of a flat dimension? Next, tell the strategy to load the data into the flat dimension table. You can explain the loading strategy with the help of the example given in SG. Continue this session by asking the following questions: 4. What are large flat dimension tables? 5. Give examples of large flat dimensions? Then, explain the strategy to load data into the large flat dimension table. Before explaining the strategy to load data into the small dimension table ask the following questions and the tell the strategy to load the data into the dimension table. 6. What are small flat dimension tables? 7. Give examples of small flat dimension tables. With the help of these questions, students will be able to recall about flat dimensions, they have learnt in Module I. Explain this topic with the help of an example given in SG.
• Explain the strategy to load the data into conformed dimension with help of an example to load the data in the date dimension given in SG. Explain the strategy to load the data into the Snowflaked dimension with the help of an example given in SG.
• Explain the strategy to load the data into conformed dimension with help of an example to load the data in the date dimension given in SG. Explain the strategy to load the data into the Snowflaked dimension with the help of an example given in SG.
• Explain the strategy to load the data into conformed dimension with help of an example to load the data in the date dimension given in SG. Explain the strategy to load the data into the Snowflaked dimension with the help of an example given in SG.
• Explain the strategy to load the data into conformed dimension with help of an example to load the data in the date dimension given in SG. Explain the strategy to load the data into the Snowflaked dimension with the help of an example given in SG.
• Explain the strategy to load the data into conformed dimension with help of an example to load the data in the date dimension given in SG. Explain the strategy to load the data into the Snowflaked dimension with the help of an example given in SG.
• Explain the strategy to load the data into conformed dimension with help of an example to load the data in the date dimension given in SG. Explain the strategy to load the data into the Snowflaked dimension with the help of an example given in SG.
• Student already have learnt about SCDs in Module I. Therefore, you can start this topic by asking the following questions to students: What are type 1 SCDs? Given an example to explain type 1 SCDs. This will recapitulate what they have learnt about type 1 SCD in Module 1. Now explain the strategy to load the data into these dimension tables with help of the given diagram. Relate this diagram to the example given in SG.
• Student already have learnt about type 2 SCDs in Module I. Therefore, you can start this topic by asking the following questions to students: What are type 2 SCDs? Given an example to explain type 2 SCDs. This will recapitulate what they have learnt about type 2 SCD in Module 1. Now explain the strategy to update the data into these dimension tables with help the example given in SG. After explaining the examples, you can ask students to think of an example of a type 2 SCD and then tell the strategy to update the data into this dimension table.
• You can summarize the session by running through the summary given in SG. In addition, you can also ask students summarize what they have learnt in this session.
• You can summarize the session by running through the summary given in SG. In addition, you can also ask students summarize what they have learnt in this session.
• You can summarize the session by running through the summary given in SG. In addition, you can also ask students summarize what they have learnt in this session.
• ### 02 rdbms session02

1. 1. Relational Database Management SystemsObjectives In this session, you will learn to: Map an ER diagram to a table Ver. 1.0 Session 2 Slide 1 of 16
2. 2. Relational Database Management SystemsConceptual Model Reflects entities and their relationships, based on the data processing needs of an organization Can be mapped to a relational, hierarchical, or network model Is independent of individual applications, database management systems, hardware, and physical storage of data Ver. 1.0 Session 2 Slide 2 of 16
3. 3. Relational Database Management SystemsMapping ERDs to Tables • A database that conforms to an ER diagram can be represented by a collection of tables in the relational system. • The mapping of ER diagrams to tables can be discussed in relation to the following: Regular entities Attributes Relationships Weak entities Subtypes and Supertypes Ver. 1.0 Session 2 Slide 3 of 16
4. 4. Relational Database Management SystemsRegular Entities They can exist in isolation, independent of any other entity. They are the “building blocks” of the database. Each regular entity maps to a table. Ver. 1.0 Session 2 Slide 4 of 16
5. 5. Relational Database Management SystemsAttributes Each property or attribute shown in the ER diagram maps to a column in the appropriate table. Ver. 1.0 Session 2 Slide 5 of 16
6. 6. Relational Database Management SystemsRelationships Each type of relationship maps to tables in a different manner in the relational database management system. The most important principle is to create tables where information from the real world is stored and retrieved in an optimal way; that is, a minimum number of tables with a minimum number of attributes. In a relational system, a join operation retrieves all information by combining two or more tables. Are of the following types: One-to-One One-to-Many Many-to-Many Ver. 1.0 Session 2 Slide 6 of 16
7. 7. Relational Database Management SystemsWeak Entities A weak entity is an entity whose existence depends on some other entity. It cannot exist if the entity on which it depends does not exist. Ver. 1.0 Session 2 Slide 7 of 16
8. 8. Relational Database Management SystemsSubtypes and Supertypes Each entity type (subtypes and supertypes) maps to a separate table. The primary key of the supertype is the foreign key of the subtype: It creates a link between the two. The foreign key of the subtype is also its primary key. Ver. 1.0 Session 2 Slide 8 of 16
9. 9. Relational Database Management SystemsTips on Logical Database Design Attributes: Do not introduce any unnecessary attributes. An attribute serves three purposes: To identify its owner entity To refer to another entity To simplify the description of an entity Keys: Relational systems require keys that uniquely identify the rows of a table. There are various types of keys: Primary Foreign Candidate Alternate Composite Ver. 1.0 Session 2 Slide 9 of 16
10. 10. Relational Database Management SystemsTips on Logical Database Design (Contd.) Any attribute (or set of attributes) that uniquely identifies a row in a table is a candidate for the primary key. Such an attribute is called a candidate key. Any attribute that is a candidate for the primary key but is not the primary key is called the alternate key. Keys can be simple or composite: A simple key is composed of a single attribute. A composite key, on the other hand, comprises two or more attributes. Ver. 1.0 Session 2 Slide 10 of 16
11. 11. Relational Database Management SystemsJust a minute Define the following terms: 1. Candidate Key 2. Alternate Key Answer: 1. Any attribute (or set of attributes) that uniquely identifies a row in a table is a candidate for the primary key. Such an attribute is called a candidate key. 2. Any attribute that is a candidate for the primary key but is not the primary key is called the alternate key. Ver. 1.0 Session 2 Slide 11 of 16
12. 12. Relational Database Management SystemsTips on Logical Database Design (Contd.) Entities: Some attributes may acquire further attributes during database design and become entities. Subentities: Replace optional attributes of an entity with subentities. This is called specialization. Specialization is the result of taking a subset of a higher-level entity set to form a lower-level entity set. Generalization is the result of taking the union of two or more lower-level entity sets to produce a higher‑level entity set. Ver. 1.0 Session 2 Slide 12 of 16
13. 13. Relational Database Management SystemsDemo: Mapping the ER Diagram to Tables Problem Statement Map the ER diagram to its corresponding tables. Ver. 1.0 Session 2 Slide 13 of 16
14. 14. Relational Database Management SystemsSummary In this session, you learned that: The conceptual model reflects entities and their relationships. Data analysis helps determine entities and relationships. The conceptual model is independent of the system where it is to be implemented. Regular entities are not dependent. They can exist in isolation, independent of any other entity. Each entity maps to a table. Each attribute in an E/R diagram maps to an attribute in a table. Entities with common attributes should be merged. Attributes may acquire further attributes and become entities. The mapping of relationships depends on the type of relationship. Each type of relationship maps to tables in a different manner in the relational database management system. Ver. 1.0 Session 2 Slide 14 of 16
15. 15. Relational Database Management SystemsSummary (Contd.) In one-to-one relationships, one instance of an entity can relate to only one instance of the related entity. In a one-to-many relationship, one instance of an entity can relate to more than one instance of the related entity. Many-to-many relationships map to tables. One-to-one relationships are not very common and may map to foreign keys in tables. A weak entity is an entity whose existence depends on some other entity. A subtype is a subset of another entity. A subtype is always dependent on supertype for its existence. The primary key of the supertype is the foreign key of the subtype. It creates a link between the two. Ver. 1.0 Session 2 Slide 15 of 16
16. 16. Relational Database Management SystemsSummary (Contd.) A candidate key is a candidate for the primary key. An alternate key is a candidate key that is not a primary key. Optional attributes should be replaced with subentities; this is also called specialization. To simplify multiple references, a new superentity should be introduced; this is also called generalization. Ver. 1.0 Session 2 Slide 16 of 16