UNIT 3 : DATABASES  &  SQL Developed by : Ms. Nita Arora   Kulachi Hansraj Model School Ashok Vihar
Relational Data Model Concept of Domain Tuple Relation Primary Key, Alternate Key, Candidate key Relational Algebra Selection Projection Union Cartesian Product
Advantages of the DBMS Approach The Database Approach Versus the Traditional File Processing Approach Storing data in a non-redundant database improves consistency of data. There is only one copy of each item of data. Unproductive Maintenance avoided. In file based systems, changes to file structure cause endless problems on maintenance (re-writing code). Using a DBMS, program access is through a limited view (using SQL). Thus programs can’t see minor changes to the database.
What is a database? A database is a collection of related data elements Tables (entities) Columns (fields or attributes)  Rows (records)
Some of the Advantages of using a DBMS Sharing of data  Control of redundancy and thus Data consistency  Improved data integrity  Better data accessibility  Representing complex relationships among data  Enforcing integrity constraints  Better security of data (as long as backup is perfect) More control over concurrency  Better backup and recovery procedures  Providing multiple interfaces  Faster development of new applications  Economy of scale
Some of the Disadvantages of using a DBMS High cost of Software Hardware costs high due to software complexity Requirement for skilled staff Higher programming costs - greater skill required Slower processing of some applications  Increased vulnerability (all your eggs in one basket) More difficult recovery (if disaster strikes)
DBMS Architecture Usually taken to imply a three level architecture.  The complexity of a large database is handled by a DBMS by providing three views of the data.  An  internal view  of how the data is stored and accessed A  conceptual view  of what data is available in the database. 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. Data abstraction  Users deal with conceptual representation of the data. They have little control over how the data is stored.
Three Level Architecture 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. 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
DIFFERENT DATA MODELS Hierarchical Data Model Network Data Model Relational Data Model Relational Model propounded by E.F.Codd
RELATIONAL DATA MODELS :  Terminology Relation Attribute / Field / Column Tuple / Record / Row Concept of Domain Concept of Degree Cardinality View
RELATIONAL DATA MODELS :  Terminology (Contd….) Primary Key Candidate key Alternate key Foreign key
Relational Algebra The relational algebra is a collection of operations on relations. Each operation takes one or more relations as operand and produces another relation as its result
Relational Algebra Operations defined in relational algebra include : Select Project Cartesian Product Union * Set difference * Set intersection * Natural join * Division Note : * items not in syllabus
Select Extracts specified tuples (rows) from a specified relation (table).
Project Extracts specified attributes(columns) from a specified relation.
Join 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.) (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
Outer Join Outer Joins are similar to PRODUCT -- but will leave NULLs for any row in the first table with no corresponding rows in the second. 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
Join Items

Rdbms

  • 1.
    UNIT 3 :DATABASES & SQL Developed by : Ms. Nita Arora Kulachi Hansraj Model School Ashok Vihar
  • 2.
    Relational Data ModelConcept of Domain Tuple Relation Primary Key, Alternate Key, Candidate key Relational Algebra Selection Projection Union Cartesian Product
  • 3.
    Advantages of theDBMS Approach The Database Approach Versus the Traditional File Processing Approach Storing data in a non-redundant database improves consistency of data. There is only one copy of each item of data. Unproductive Maintenance avoided. In file based systems, changes to file structure cause endless problems on maintenance (re-writing code). Using a DBMS, program access is through a limited view (using SQL). Thus programs can’t see minor changes to the database.
  • 4.
    What is adatabase? A database is a collection of related data elements Tables (entities) Columns (fields or attributes) Rows (records)
  • 5.
    Some of theAdvantages of using a DBMS Sharing of data Control of redundancy and thus Data consistency Improved data integrity Better data accessibility Representing complex relationships among data Enforcing integrity constraints Better security of data (as long as backup is perfect) More control over concurrency Better backup and recovery procedures Providing multiple interfaces Faster development of new applications Economy of scale
  • 6.
    Some of theDisadvantages of using a DBMS High cost of Software Hardware costs high due to software complexity Requirement for skilled staff Higher programming costs - greater skill required Slower processing of some applications Increased vulnerability (all your eggs in one basket) More difficult recovery (if disaster strikes)
  • 7.
    DBMS Architecture Usuallytaken to imply a three level architecture. The complexity of a large database is handled by a DBMS by providing three views of the data. An internal view of how the data is stored and accessed A conceptual view of what data is available in the database. 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. Data abstraction Users deal with conceptual representation of the data. They have little control over how the data is stored.
  • 8.
    Three Level ArchitectureOne 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. 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.
    DIFFERENT DATA MODELSHierarchical Data Model Network Data Model Relational Data Model Relational Model propounded by E.F.Codd
  • 10.
    RELATIONAL DATA MODELS: Terminology Relation Attribute / Field / Column Tuple / Record / Row Concept of Domain Concept of Degree Cardinality View
  • 11.
    RELATIONAL DATA MODELS: Terminology (Contd….) Primary Key Candidate key Alternate key Foreign key
  • 12.
    Relational Algebra Therelational algebra is a collection of operations on relations. Each operation takes one or more relations as operand and produces another relation as its result
  • 13.
    Relational Algebra Operationsdefined in relational algebra include : Select Project Cartesian Product Union * Set difference * Set intersection * Natural join * Division Note : * items not in syllabus
  • 14.
    Select Extracts specifiedtuples (rows) from a specified relation (table).
  • 15.
    Project Extracts specifiedattributes(columns) from a specified relation.
  • 16.
    Join Builds arelation 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.) (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.
    Outer Join OuterJoins are similar to PRODUCT -- but will leave NULLs for any row in the first table with no corresponding rows in the second. 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.