ScholarQuill logoScholarQuillUniversity Notes
  • Notes
  • Past Papers
  • Blogs
  • Todo
Login
ScholarQuill logoScholarQuillUniversity Notes
Login
NotesPast PapersBlogsTodo
More
SubjectsDiscussionCGPA CalculatorGPA CalculatorStudent PortalCourse Outline
About
About usPrivacy PolicyReportContact
Notes
Past Papers
Blogs
Todo
Analytics
    Current Subject
    🧩
    Database Systems
    COMP2114
    Progress0 / 34 topics
    Topics
    1. Basic Database Concepts2. Database Approach vs File Based System3. Database Architecture4. Three Level Schema Architecture5. Data Independence6. Relational Data Model7. Attributes8. Schemas9. Tuples10. Domains11. Relation Instances12. Keys of Relations13. Integrity Constraints14. Relational Algebra15. Selection in Relational Algebra16. Projection in Relational Algebra17. Cartesian Product in Relational Algebra18. Types of Joins19. Normalization20. Functional Dependencies21. Normal Forms22. Entity-Relationship Model23. Entity Sets24. Attributes in Entity-Relationship Model25. Relationship in Entity-Relationship Model26. Entity-Relationship Diagrams27. Structured Query Language (SQL)28. Joins in SQL29. Sub-Queries in SQL30. Grouping and Aggregation in SQL31. Concurrency Control32. Database Backup and Recovery33. Indexes34. NoSQL Systems
    COMP2114›Schemas
    Database SystemsTopic 8 of 34

    Schemas

    7 minread
    1,116words
    Intermediatelevel

    Schemas in the Context of Databases

    In the context of databases, a schema refers to the logical structure that defines the organization of data. It describes the way in which the data is organized and how the relations (tables) are related to one another. A schema acts as a blueprint for how the database is constructed, including tables, views, indexes, constraints, and the relationships between entities.

    A schema is important because it provides a logical framework to represent the structure of the database and ensures that data is stored and managed in a consistent way.


    Types of Schemas

    In the relational model, schemas are generally described at different levels to support the abstraction of data. These levels are typically divided into three levels:

    1. Internal Schema (Physical Level)
    2. Conceptual Schema (Logical Level)
    3. External Schema (View Level)

    Each of these levels has a distinct role in defining the database structure and its interaction with users and applications.


    1. Internal Schema (Physical Schema)

    The internal schema is the lowest level in the database architecture. It defines the physical storage of data in the system. This schema deals with how data is stored on physical media (like hard drives or SSDs) and includes details about indexing, data compression, file structures, and memory management.

    • It defines:
      • Data storage structures: The physical implementation of tables, indexes, and how the database is stored on disk.
      • Access paths: The mechanisms used for efficiently retrieving data (e.g., B-trees, hashing).
      • File organization: How the data is actually written and organized in storage.
      • Performance optimization: Techniques for speeding up query execution, such as indexing and partitioning.

    The internal schema is transparent to users. Users don't typically interact with this schema directly. Instead, the DBMS takes care of mapping the logical schema (Conceptual schema) to the physical storage.


    2. Conceptual Schema (Logical Schema)

    The conceptual schema represents the logical view of the entire database. It defines the structure of the database in terms of entities, relationships, and constraints, but it is independent of how the data is physically stored. This schema describes what data is stored and the relationships between data, without getting into the details of how it will be implemented.

    • It defines:
      • Tables (Relations): The logical structures that represent entities (e.g., customers, orders).
      • Attributes: The properties of entities, which are the columns of the tables.
      • Primary and Foreign Keys: Defines the uniqueness of records and relationships between tables.
      • Constraints: Rules that the data must follow, such as NOT NULL, CHECK, UNIQUE, and REFERENTIAL INTEGRITY constraints.
      • Views: Virtual tables that are derived from the actual tables (not stored physically but can be queried like tables).

    The conceptual schema does not include physical details. It focuses on what data should be stored and how it is logically structured. Users and applications interact with the conceptual schema.


    3. External Schema (View Schema)

    The external schema represents the user’s view of the database. Different users or applications may have different needs and requirements, and the external schema allows for these variations. It is essentially a customized view of the database, tailored to the specific needs of a user or group of users.

    • It defines:
      • Views: A view is a subset of the database, created to represent specific information relevant to a particular user. For example, a sales manager may have a view that only includes customer and order information.
      • Access Control: Defines which parts of the database the user can access and what operations they can perform (e.g., SELECT, INSERT, UPDATE, DELETE).

    The external schema is the highest level of abstraction in the database. It allows for data independence, meaning that changes to the internal or conceptual schema do not affect how users interact with the database. Multiple external schemas can exist for different users or applications.


    The Three-Level Schema Architecture

    The three-level schema architecture (also called the ANSI/SPARC architecture) is the standard database architecture for DBMS design. It separates the database system into three levels, ensuring data independence and flexibility for both users and administrators.

    • External Schema: User-specific views of the data (can be many different views).
    • Conceptual Schema: Logical view of the entire database, independent of physical storage.
    • Internal Schema: Physical storage and access paths.

    The goal of this architecture is to separate the physical storage of data from its logical representation and to allow users to interact with the database at an abstract level, independent of the physical details.


    Benefits of Using Schemas

    1. Data Independence:

      • The three-level architecture allows for data independence, meaning that changes in one schema do not affect the other schemas. This makes it easier to manage and modify the database without impacting users.
      • Physical Data Independence: Changes in the internal schema (e.g., changes in the storage method) do not affect the conceptual schema.
      • Logical Data Independence: Changes in the conceptual schema (e.g., adding or removing attributes) do not affect the external schema or users' views.
    2. Security and Access Control:

      • By using external schemas (views), you can control what parts of the database each user can access. This allows you to restrict access to sensitive data or present different subsets of the data to different users.
    3. Simplification:

      • For the end-user, interacting with the external schema simplifies the complexity of the underlying database structure. Users do not need to worry about how data is physically stored or how the entire database is structured, as they only see the relevant subset of data.
    4. Flexibility:

      • Since the conceptual schema provides a higher level of abstraction, the schema can be adjusted without affecting the user applications. This provides flexibility for database maintenance and evolution.

    Example

    Let's consider an example of a university database with students, courses, and enrollments.

    • Internal Schema:

      • Details of how the data is physically stored on disk (e.g., indexing on student IDs, courses stored in separate files, etc.).
    • Conceptual Schema:

      • Defines the structure of tables like Students, Courses, and Enrollments.
        • Students(StudentID, Name, Age)
        • Courses(CourseID, CourseName, Credits)
        • Enrollments(StudentID, CourseID, EnrollmentDate)
    • External Schema:

      • Different views for different users:
        • Student View: A student can only see their name, ID, and courses they are enrolled in.
        • Admin View: A university administrator can see all students, courses, and enrollment data.

    Conclusion

    In database systems, schemas are crucial in defining the logical structure of data and controlling how it is stored and accessed. The three-level schema architecture—internal, conceptual, and external schemas—provides a layered abstraction, ensuring data independence and making it easier to manage complex databases. This separation allows for more flexibility, security, and efficiency in database management and user interaction.

    Previous topic 7
    Attributes
    Next topic 9
    Tuples

    Past Papers

    Open this section to load past papers

    Click on Show Past Papers to see past papers.
    On This Page
      Reading Stats
      Est. reading time7 min
      Word count1,116
      Code examples0
      DifficultyIntermediate