MCS-201 · Unit 16

Data Access Using Python

Section 1 of 7

Block 4 · Unit 16Data Access Using Python9 min · Section 1 of 7

16.1Databases and Database Management Systems

Covers IGNOU MCS-201 §16.1, 16.2

Before connecting Python to a database, you need a clear idea of what a database is and why organisations use database systems instead of ordinary files.

Database and DBMS

Users of a DBMS

UserRole
End usersUse applications built on the database (students, bank customers, clerks)
Application programmersWrite programs (in Python, Java, etc.) that access the database
Database designersDecide the structure: entities, relationships, tables, constraints
Database administrators (DBA)Install, configure, back up, secure and tune the DBMS; grant permissions

Advantages and limitations

Advantages over separate filesLimitations
Reduced redundancy: data stored once, centrallyHardware, software and licence costs
Consistency: one copy, so updates are seen everywhereComplex to design and administer
Sharing by many users and programs at onceStaff need training
Integrity: rules (constraints) keep data validA failure of the central database affects all applications
Security: authentication and access rightsConversion from old file systems takes effort
Data independence: programs are not tied to storage detailsSome overhead for very small, simple tasks
Backup, recovery and concurrency control built in

Example of inconsistency without a database: a student’s new address is updated in the examination file but not in the accounts file, so the two departments disagree.

Architecture

Most applications today use a three-tier architecture:

Three-tier architecture
Presentation tier          Application tier               Data tier
(browser, mobile app) <--> (web/app server running   <--> (DBMS: MySQL server
                            business logic, e.g.           storing the data)
                            Python code)

Each tier can be changed or scaled independently; users never connect to the database directly.

The three-schema architecture separates three views of the same database:

LevelDescribesWho uses it
External (view) levelThe part of the data each user group seesEnd users, applications
Conceptual (logical) levelAll entities, attributes, relationships and constraintsDesigners, DBA
Internal (physical) levelHow data is stored on disk: files, indexesDBMS, DBA

This separation gives data independence: the physical storage can change without changing programs (physical independence), and the logical design can grow without changing every user’s view (logical independence).

Key takeaways

  • Database = organised, shared, persistent data; DBMS = software that manages it.
  • Users: end users, programmers, designers, administrators.
  • DBMS benefits: less redundancy, consistency, sharing, integrity, security, independence.
  • Three-tier: presentation, application, data; three-schema: external, conceptual, internal.

Practice questions

Answer on paper first, then check. The explanation matters more than the letter you chose.

Question 1 · multiple choice

Which of these is a DBMS?

Show answer

Answer: B. MySQL

MySQL is database server software; SQL is the language it understands; CSV is a file format.

Question 2 · multiple choice

What is data redundancy?

Show answer

Answer: B. Unnecessary duplication of the same data in several places

Redundancy leads to inconsistency when one copy is updated and another is not; a DBMS reduces it.

Question 3 · multiple choice

Which level of the three-schema architecture describes how data is stored on disk?

Show answer

Answer: C. Internal

The internal (physical) level deals with files, indexes and storage structures.

Question 4 · multiple choice

In a three-tier web application, where does the Python code that applies business rules usually run?

Show answer

Answer: B. In the application tier

The application (middle) tier sits between the users and the DBMS.

Question 5 · multiple choice

Which is a limitation of database systems?

Show answer

Answer: D. Higher cost and complexity of setup and administration

Hardware, software, design and training costs are the main drawbacks; the others are advantages.

Question 6 · short answer

Explain, with an example, how a DBMS ensures data consistency compared with a file-based system.

Show worked answer

In a file-based system each department keeps its own copy of shared data, so an update made in one file may not be made in the others. For example, if a student’s phone number is changed in the examination file but not in the hostel file, the two records disagree. In a DBMS the student’s details are stored once in a central table; every department reads the same row, so a single update is immediately seen by all users, and the data stays consistent.

↑ ↓ move↵ openTab switch type