Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.



Published on

Published in: Business, Technology


  1. 1. UNIT 3 : DATABASES & SQL Developed by : Ms. Nita Arora Kulachi Hansraj Model School Ashok Vihar
  2. 2. <ul><li>Relational Data Model </li></ul><ul><ul><li>Concept of Domain </li></ul></ul><ul><ul><li>Tuple </li></ul></ul><ul><ul><li>Relation </li></ul></ul><ul><ul><li>Primary Key, Alternate Key, Candidate key </li></ul></ul><ul><li>Relational Algebra </li></ul><ul><ul><li>Selection </li></ul></ul><ul><ul><li>Projection </li></ul></ul><ul><ul><li>Union </li></ul></ul><ul><ul><li>Cartesian Product </li></ul></ul>
  3. 3. Advantages of the DBMS Approach <ul><li>The Database Approach Versus the Traditional File Processing Approach </li></ul><ul><ul><li>Storing data in a non-redundant database improves consistency of data. </li></ul></ul><ul><ul><ul><li>There is only one copy of each item of data. </li></ul></ul></ul><ul><li>Unproductive Maintenance avoided. </li></ul><ul><ul><li>In file based systems, changes to file structure cause endless problems on maintenance (re-writing code). </li></ul></ul><ul><ul><li>Using a DBMS, program access is through a limited view (using SQL). </li></ul></ul><ul><ul><ul><li>Thus programs can’t see minor changes to the database. </li></ul></ul></ul>
  4. 4. What is a database? <ul><li>A database is a collection of related data elements </li></ul><ul><ul><li>Tables (entities) </li></ul></ul><ul><ul><li>Columns (fields or attributes) </li></ul></ul><ul><ul><li>Rows (records) </li></ul></ul>
  5. 5. Some of the Advantages of using a DBMS <ul><ul><ul><li>Sharing of data </li></ul></ul></ul><ul><ul><ul><li>Control of redundancy and thus Data consistency </li></ul></ul></ul><ul><ul><ul><li>Improved data integrity </li></ul></ul></ul><ul><ul><ul><li>Better data accessibility </li></ul></ul></ul><ul><ul><ul><li>Representing complex relationships among data </li></ul></ul></ul><ul><ul><ul><li>Enforcing integrity constraints </li></ul></ul></ul><ul><ul><ul><li>Better security of data (as long as backup is perfect) </li></ul></ul></ul><ul><ul><ul><li>More control over concurrency </li></ul></ul></ul><ul><ul><ul><li>Better backup and recovery procedures </li></ul></ul></ul><ul><ul><ul><li>Providing multiple interfaces </li></ul></ul></ul><ul><ul><ul><li>Faster development of new applications </li></ul></ul></ul><ul><ul><ul><li>Economy of scale </li></ul></ul></ul>
  6. 6. Some of the Disadvantages of using a DBMS <ul><ul><ul><li>High cost of Software </li></ul></ul></ul><ul><ul><ul><li>Hardware costs high due to software complexity </li></ul></ul></ul><ul><ul><ul><li>Requirement for skilled staff </li></ul></ul></ul><ul><ul><ul><li>Higher programming costs - greater skill required </li></ul></ul></ul><ul><ul><ul><li>Slower processing of some applications </li></ul></ul></ul><ul><ul><ul><li>Increased vulnerability (all your eggs in one basket) </li></ul></ul></ul><ul><ul><ul><li>More difficult recovery (if disaster strikes) </li></ul></ul></ul>
  7. 7. DBMS Architecture <ul><li>Usually taken to imply a three level architecture. </li></ul><ul><li>The complexity of a large database is handled by a DBMS by providing three views of the data. </li></ul><ul><ul><li>An internal view of how the data is stored and accessed </li></ul></ul><ul><ul><li>A conceptual view of what data is available in the database. </li></ul></ul><ul><ul><li>Local or external views which are a limited and simplified view of the database as suitable for a single application or group of associated applications. </li></ul></ul><ul><li>Data abstraction </li></ul><ul><ul><li>Users deal with conceptual representation of the data. </li></ul></ul><ul><ul><li>They have little control over how the data is stored. </li></ul></ul>
  8. 8. Three Level Architecture <ul><li>One of the fundamental aspects of the database approach using a DBMS is that, by providing levels of data abstraction, it hides complexity of data storage from users. </li></ul>External Level View 1 View 4 View 2 View 3 etc. Conceptual Level Conceptual Schema Internal Schema Internal Level Physical Data Independence Logical Data Independence
  9. 9. DIFFERENT DATA MODELS <ul><li>Hierarchical Data Model </li></ul><ul><li>Network Data Model </li></ul><ul><li>Relational Data Model </li></ul><ul><ul><li>Relational Model propounded by E.F.Codd </li></ul></ul>
  10. 10. RELATIONAL DATA MODELS : Terminology <ul><li>Relation </li></ul><ul><li>Attribute / Field / Column </li></ul><ul><li>Tuple / Record / Row </li></ul><ul><li>Concept of Domain </li></ul><ul><li>Concept of Degree </li></ul><ul><li>Cardinality </li></ul><ul><li>View </li></ul>
  11. 11. RELATIONAL DATA MODELS : Terminology (Contd….) <ul><li>Primary Key </li></ul><ul><li>Candidate key </li></ul><ul><li>Alternate key </li></ul><ul><li>Foreign key </li></ul>
  12. 12. Relational Algebra <ul><li>The relational algebra is a collection of operations on relations. </li></ul><ul><li>Each operation takes one or more relations as operand and produces another relation as its result </li></ul>
  13. 13. Relational Algebra <ul><li>Operations defined in relational algebra include : </li></ul><ul><ul><li>Select </li></ul></ul><ul><ul><li>Project </li></ul></ul><ul><ul><li>Cartesian Product </li></ul></ul><ul><ul><li>Union </li></ul></ul><ul><ul><li>* Set difference </li></ul></ul><ul><ul><li>* Set intersection </li></ul></ul><ul><ul><li>* Natural join </li></ul></ul><ul><ul><li>* Division </li></ul></ul><ul><ul><li>Note : * items not in syllabus </li></ul></ul>
  14. 14. Select <ul><li>Extracts specified tuples (rows) from a specified relation (table). </li></ul>
  15. 15. Project <ul><li>Extracts specified attributes(columns) from a specified relation. </li></ul>
  16. 16. Join <ul><li>Builds a relation from two specified relations consisting of all possible concatenated pairs, one from each of the two relations, such that in each pair the two tuples satisfy some condition. (E.g., equal values in a given col.) </li></ul>(Natural or Inner) Join A1 B1 A2 B1 A3 B2 B1 C1 B2 C2 B3 C3 A1 B1 C1 A2 B1 C1 A3 B2 C2
  17. 17. Outer Join <ul><li>Outer Joins are similar to PRODUCT -- but will leave NULLs for any row in the first table with no corresponding rows in the second. </li></ul>A1 B1 A2 B1 A3 B2 A4 B7 B1 C1 B2 C2 B3 C3 A1 B1 C1 A2 B1 C1 A3 B2 C2 A4 * * Outer Join
  18. 18. Join Items