Unit1 - Subjective Questions
INT306 • Practice Questions with Detailed Answers
Compare File Processing Systems with Database Management Systems (DBMS). What are the main disadvantages of file processing systems that DBMS solves?
Comparison between File System and DBMS:
| Feature | File Processing System | Database Management System (DBMS) |
|---|---|---|
| Data Redundancy | High redundancy (duplicate data in various files). | Redundancy is minimized/controlled through normalization. |
| Data Consistency | High risk of inconsistency (update in one file may not reflect in others). | Data consistency is maintained via propagation of updates. |
| Data Access | Difficult; requires specific programs for different queries. | Easy; uses query languages (SQL) for efficient retrieval. |
| Security | Low; difficult to enforce granular constraints. | High; supports users, roles, and access privileges. |
| Concurrency | Poor; difficult to handle multiple users simultaneously. | Good; supports concurrent access and transaction management. |
Disadvantages of File Systems Solved by DBMS:
- Data Redundancy and Inconsistency: Since different programmers create different files, the same information may be duplicated. DBMS centralizes data to reduce this.
- Difficulty in Accessing Data: File systems require writing new programs to carry out new tasks. DBMS provides a query mechanism.
- Data Isolation: Data is scattered in various files and formats, making it hard to retrieve appropriate data.
- Atomicity Problems: File systems often lack mechanisms to ensure a transaction happens completely or not at all (e.g., fund transfer failures).
Explain the Three-Schema Architecture (ANSI/SPARC architecture). What is its primary objective?
Objective: The primary goal of the Three-Schema Architecture is to separate the user applications from the physical database. This separation ensures Data Independence.
The Three Levels:
-
Internal Level (Physical Schema):
- Describes how data is actually stored on the storage medium (disk).
- Deals with complex low-level data structures, file organizations, and access paths (indexes).
-
Conceptual Level (Logical Schema):
- Describes what data is stored in the database and the relationships among the data.
- It hides the details of physical storage structures.
- Concentrates on entities, data types, relationships, and constraints.
-
External Level (View Schema):
- Describes only part of the database that a particular user group is interested in.
- It hides the rest of the database from the user.
- There can be many external views for the same database.
Define Data Independence. Distinguish between Logical Data Independence and Physical Data Independence.
Definition: Data Independence is the ability to modify the schema definition in one level without affecting the schema definition in the next higher level.
Distinction:
-
Physical Data Independence:
- The capacity to change the internal schema (physical storage) without having to change the conceptual schema.
- Example: Creating a new index, changing the storage device, or switching from hashing to sequential file organization to improve performance does not require changing the logical structure of the data.
-
Logical Data Independence:
- The capacity to change the conceptual schema without having to change the external schemas or application programs.
- Example: Adding a new entity (table) or attribute (column) to the database should not break existing application code that does not use that new data.
- Note: Logical data independence is harder to achieve than physical data independence.
What is the difference between Database Schema and Database Instance? Give an example.
Database Schema:
- Definition: The logical structure or design of the database. It is the skeleton of the database that represents the view of the entire database.
- Change Frequency: It changes very infrequently (only during design updates).
- Analogy: Similar to a variable declaration or a class definition in programming.
- Example:
Database Instance:
- Definition: The collection of information (data) stored in the database at a particular moment in time. It is also called the "current state" or "extension" of the database.
- Change Frequency: It changes frequently as data is inserted, updated, or deleted.
- Analogy: Similar to the value of a variable at a specific execution step.
- Example:
Row 1: {John Doe, 101, 20}
Row 2: {Jane Smith, 102, 21}
List and explain the major components of a DBMS environment.
The five major components of a DBMS environment are:
-
Hardware:
- The physical electronic devices such as computers, I/O devices, and storage devices (hard drives, RAID arrays) where the database resides.
-
Software:
- The set of programs used to control and manage the overall database. This includes the DBMS software itself (like Oracle, MySQL), the Operating System, and network software.
-
Data:
- The most important component. It acts as a bridge between the machine components and the human components. It includes both the actual operational data and the metadata (schema/data about data).
-
Procedures:
- The instructions and rules that govern the design and use of the database. This includes instructions for logging in, backing up data, handling failures, and regulating access.
-
People:
- The users who interact with the system. They include:
- Database Administrators (DBA): Manage the system.
- Application Programmers: Write code to interact with the DB.
- End Users: Use the data (Naive or Sophisticated users).
- The users who interact with the system. They include:
Explain the concept of Data Modeling. Briefly describe the Relational Model and the Entity-Relationship (ER) Model.
Data Modeling:
Data modeling is the process of creating a visual representation of either a whole information system or parts of it to communicate connections between data points and structures. It creates a blueprint for the database.
Entity-Relationship (ER) Model:
- A high-level conceptual data model.
- It represents data as Entities (real-world objects), Attributes (properties of objects), and Relationships (associations between objects).
- It is widely used for database design and is represented diagrammatically using ER Diagrams.
Relational Model:
- A representational (logical) data model proposed by E.F. Codd.
- It represents data in the form of Tables (Relations) consisting of rows (tuples) and columns (attributes).
- Relationships between tables are established using common keys (Foreign Keys).
- It is the theoretical basis for SQL-based databases.
What are the different types of attributes in the ER Model? Explain with examples and their diagrammatic representation.
In the ER model, attributes describe the properties of entities:
-
Simple (Atomic) Attribute:
- Cannot be divided further.
- Example:
Age,Gender. - Symbol: Oval.
-
Composite Attribute:
- Can be divided into sub-parts.
- Example:
Address(composed of Street, City, Zip) orName(First Name, Last Name). - Symbol: Oval connected to sub-ovals.
-
Multi-valued Attribute:
- Can have multiple values for a single entity instance.
- Example:
Phone_Number(a person can have two numbers) orDegrees. - Symbol: Double Oval.
-
Derived Attribute:
- The value is derived from another attribute; it is not physically stored.
- Example:
Age(derived fromDate_of_Birth). - Symbol: Dashed Oval.
-
Key Attribute:
- Uniquely identifies an entity.
- Example:
Student_ID. - Symbol: Oval with underlined text.
Describe the concept of Cardinality Ratios in relationships with examples.
Cardinality ratios express the number of entities to which another entity can be associated via a relationship set.
-
One-to-One ():
- An entity in set A is associated with at most one entity in set B, and vice versa.
- Example: One
Personhas onePassport.
-
One-to-Many ():
- An entity in set A is associated with any number of entities in set B, but an entity in set B is associated with at most one entity in set A.
- Example: One
Departmentemploys manyEmployees.
-
Many-to-One ():
- Reverse of . Many entities in A are associated with one entity in B.
- Example: Many
Studentsbelong to oneClass.
-
Many-to-Many ():
- An entity in A is associated with any number of entities in B, and an entity in B is associated with any number of entities in A.
- Example:
Studentsenroll inCourses. (A student takes many courses; a course has many students).
Distinguish between Strong Entity Sets and Weak Entity Sets. How are they represented in an ER diagram?
Strong Entity Set:
- Definition: An entity set that has sufficient attributes to uniquely identify its members (i.e., it has a primary key).
- Dependence: Independent of other entity sets.
- Representation: Represented by a single rectangle.
- Example:
Employee(withEmp_IDas primary key).
Weak Entity Set:
- Definition: An entity set that does not have a primary key of its own. It relies on the primary key of a strong entity (owner) for identification.
- Discriminator: It has a partial key (discriminator) to distinguish entities within the set belonging to the same owner.
- Dependence: Existence depends on the owner entity.
- Representation: Represented by a double rectangle. The relationship connecting it to the strong entity is called an Identifying Relationship (double diamond).
- Example:
Dependentof anEmployee(identified byEmp_ID+Dependent_Name).
Explain Generalization and Specialization in the context of the Extended ER Model.
Generalization (Bottom-Up Approach):
- The process of combining a number of entity sets that share the same features into a higher-level entity set.
- It emphasizes similarities.
- Example: Entities
CarandTruckcan be generalized into a superclassVehiclecontaining common attributes likeVehicleID,LicensePlate.
Specialization (Top-Down Approach):
- The process of designating subgroupings within an entity set that differ from other subgroups.
- It emphasizes differences (specific attributes).
- Example: A generic entity
Accountcan be specialized intoSavings_Account(withInterestRate) andCurrent_Account(withOverdraftLimit).
Inheritance:
- In both cases, lower-level entities inherit attributes of the higher-level entities.
Detail the various Integrity Constraints in the Relational Model.
Integrity constraints ensure data accuracy and consistency in a relational database.
-
Domain Constraints:
- Specifies that the value of each attribute must be an atomic value from the defined domain (data type, range).
- Example:
Agemust be an integer .
-
Entity Integrity Constraint:
- States that no primary key value can be NULL.
- Reason: Primary keys are used to identify individual tuples; if null, identity is lost.
-
Referential Integrity Constraint:
- Maintained between two related tables (referencing and referenced).
- States that a Foreign Key value in the child table must either match a Primary Key value in the parent table or be NULL.
- Example: If
Studenttable referencesDept_IDfromDepartmenttable, you cannot assign aDept_IDto a student that doesn't exist in theDepartmenttable.
-
Key Constraints (Uniqueness):
- Specific attributes (Candidate Keys) must have unique values for every tuple in the relation.
- Example: No two employees can have the same
Social_Security_Number.
Define the following keys in the Relational Model: Super Key, Candidate Key, Primary Key, and Foreign Key.
-
Super Key:
- A set of one or more attributes that, taken collectively, allows us to identify uniquely a tuple in a relation. It may contain extraneous attributes.
- Example:
{Student_ID},{Student_ID, Name}.
-
Candidate Key:
- A "minimal" super key. It is a super key such that no proper subset of it is a super key.
- Example: If
Student_IDis unique,{Student_ID}is a candidate key.{Student_ID, Name}is not (becauseNameis redundant for uniqueness).
-
Primary Key:
- One candidate key chosen by the database designer to be the principal means of identifying tuples within a relation. It cannot be NULL.
-
Foreign Key:
- An attribute (or set of attributes) in a relation that refers to the primary key of another relation. It establishes the link between tables.
Compare Relational Databases (SQL) and Non-Relational Databases (NoSQL).
Relational Databases (SQL):
- Structure: Table-based (Rows and Columns).
- Schema: Pre-defined, rigid schema. Must define types before inserting data.
- Scaling: Vertically scalable (scale-up: adding more power to the server).
- Query Language: Uses Structured Query Language (SQL).
- Transactions: Follows ACID properties (Atomicity, Consistency, Isolation, Durability) strictly.
- Examples: MySQL, PostgreSQL, Oracle.
Non-Relational Databases (NoSQL):
- Structure: Document-based, Key-Value pairs, Graph-based, or Wide-column stores.
- Schema: Dynamic schema (Schema-less) for unstructured data.
- Scaling: Horizontally scalable (scale-out: adding more servers).
- Query Language: Focused on collection of documents; varies by DB (e.g., MongoDB query).
- Transactions: Often follows BASE properties (Basically Available, Soft state, Eventual consistency) (CAP theorem trade-offs).
- Examples: MongoDB, Cassandra, Redis, Neo4j.
Explain the Three-Tier DBMS Architecture. How does it differ from Two-Tier architecture?
Three-Tier Architecture:
This architecture separates the presentation, application logic, and data management into three distinct layers.
- Client (Presentation Tier): The user interface (GUI/Web Browser). It knows nothing about the database, only how to display data sent by the application server.
- Application Server (Business Logic Tier): Acts as an intermediary. It receives requests from the client, processes the business logic, and sends queries to the database server.
- Database Server (Data Tier): The actual DBMS that executes queries and returns results to the application server.
Difference from Two-Tier:
- Two-Tier: The client communicates directly with the database server using an API (like JDBC/ODBC). Business logic is either in the client (Fat Client) or the DB (Stored Procedures).
- Comparison: Three-tier is more secure (client has no direct access to DB), more scalable, and easier to maintain compared to Two-tier.
What is a Database Administrator (DBA)? List the key responsibilities of a DBA.
Definition: A Database Administrator (DBA) is a person or group responsible for the overall control and management of the database system.
Responsibilities:
- Schema Definition: Creating the original database schema (creating tables, defining constraints).
- Storage Structure and Access Method Definition: Deciding how data is stored and indexed for efficiency.
- Schema and Physical Organization Modification: Changing the schema if requirements change or tuning physical files for performance.
- Granting Authorization: Managing user accounts and determining which users can access or modify which parts of the database.
- Routine Maintenance: Backing up the database, monitoring disk space, and performance tuning.
What are the advantages of using a DBMS over traditional methods?
- Controlling Data Redundancy: Prevents duplicate data, saving storage and reducing inconsistency.
- Restricting Unauthorized Access: Provides security subsystems to create user accounts with specific access rights.
- Providing Persistent Storage for Program Objects: Complex data structures can be stored permanently.
- Providing Storage Structures for Efficient Query Processing: Uses indexes and query optimization algorithms.
- Backup and Recovery: Automatically handles recovery from crashes (power failure, disk failure) to a consistent state.
- Enforcing Integrity Constraints: Ensures data entered follows business rules (e.g., account balance cannot be negative).
Briefly explain the Network Model and the Hierarchical Model of databases.
These are legacy data models used before the Relational Model became dominant.
Hierarchical Model:
- Structure: Organizes data in a tree-like structure (Parent-Child relationship).
- Constraint: A child record can have only one parent (1:N relationship enforced).
- Traversal: To access data, one must traverse the tree from the root.
- Example: XML files, Windows Registry, IBM IMS.
Network Model:
- Structure: Organizes data in a graph structure.
- Flexibility: A child record can have multiple parents (allows M:N relationships directly).
- Implementation: Uses pointers/links to connect records.
- Complexity: Very complex to design and modify compared to the relational model.
- Example: IDMS.
What is the 'Degree' of a relationship set in ER modeling? Give examples.
Definition: The degree of a relationship set is the number of entity sets participating in that relationship.
-
Unary (Degree 1):
- A relationship involves a single entity set (Recursive relationship).
- Example:
EmployeemanagesEmployee(One employee is a manager of another).
-
Binary (Degree 2):
- A relationship involves two entity sets.
- Example:
Studentenrolls inCourse.
-
Ternary (Degree 3):
- A relationship involves three entity sets.
- Example:
Employeeworks on aProjectat aBranch. (Relationship among Employee, Project, and Branch).
-
N-ary:
- Involves N entity sets.
List the various applications of Database Management Systems.
DBMS is used in almost every sector where data needs to be managed efficiently:
- Banking: For customer information, accounts, loans, and banking transactions.
- Airlines: For reservations, schedule information, and flight tracking.
- Universities: For student information, course registrations, and grades.
- Credit Card Transactions: For purchases on credit cards and generation of monthly statements.
- Telecommunications: To keep records of calls made, generating bills, and maintaining prepaid balances.
- E-commerce: For inventory, order tracking, and recommendation engines (e.g., Amazon).
- Human Resources: For information about employees, salaries, and payroll taxes.
Explain the role of participation constraints (Total vs. Partial) in an ER Diagram.
Participation constraints specify whether the existence of an entity depends on its being related to another entity via the relationship type.
-
Total Participation (Existence Dependency):
- Every entity in the entity set must participate in the relationship.
- Representation: Double line connecting the entity set to the relationship diamond.
- Example: In a relationship between
LoanandBorrower, every Loan must belong to a Borrower. Total participation ofLoan.
-
Partial Participation:
- Some entities in the entity set may not participate in the relationship.
- Representation: Single line connecting the entity set to the relationship diamond.
- Example: In
EmployeemanagesDepartment, not every employee is a manager. Partial participation ofEmployee.