Unit-16: Develop data-driven
software
Associate Diploma in Software Development
ITUSD-1-0015-1-3
Recommended learning hours: 72
Lesson 1: Understand data
applications
Learning Objectives
By the end of this lesson you will learn:
● Multi-layer applications (Unit 16: KLO 1.1)
a) Business logic layer
b) Data-access layer
c) User interface layer
3
Vocabulary
● Application ● CRUD
● Architecture ● User Interface (UI)
● Data ● Frontend
● Business Logic ● Input Field
● Processing ● Form
● Validation
● Database
● Query
● SQL (Structured
Query Language)
4
What are Data Applications?
=> Software programs that handle, process, and manage data.
=> Common in systems like banking apps, inventory systems, and
websites.
=> Work with databases, user interfaces, and business rules.
5
Multi-Layer Architecture Overview
Definition:
An approach where the application is separated into
layers, each responsible for specific functions.
Main Layers:
-Business Logic Layer
-Data-Access Layer
-User Interface (UI) Layer
6
Business Logic Layer
=> Handles rules, calculations, and decisions.
=>Ensures correct data processing.
=>Example: Calculating invoice totals, applying tax.
7
Data Access Layer
=>Connects the application to databases.
=>Performs CRUD operations (Create, Read, Update, Delete).
=>Uses SQL or APIs to communicate with databases.
8
User Interface Layer
=>What the user sees and interacts with.
=>Includes forms, buttons, menus, etc.
=>Designed to be user-friendly and interactive.
9
Why Use Multi-Layer Architecture?
=> Better organization and maintenance
=> Improves security and scalability
=> Separates design (UI), logic, and data handling
10
Real-World Example
Online Shopping App
UI Layer: Product pages, shopping cart
Business Logic: Apply discounts, calculate totals
Data Layer: Store product, order, and customer data
11
Class will be divided into groups. Each group will be
asked to select any App (online shopping, banking, To-
Do list etc).
Each group will create a chart or drawing identifying
the three layers:
• What is shown to the user (UI)?
• What rules/logic the app follows (Business Logic)?
12
Lesson 2: Understand Data
Sources
Learning Objectives
By the end of this lesson you will understand:
● Databases. (Unit 16, KLO 2.1)
● XML Databases.(Unit 16, KLO 2.2)
● Open Database Connection (ODBC) (Unit 16, KLO 2.3)
14
Vocabulary
● Database ● Query
● Relational Database ● SQL
● Table ● XML
● Record ● XML Database
● Field ● ODBC
● Primary Key ● Connection
● Foreign Key String
15
Database
What is a Database?
● A database is an organized collection of data.
● It allows users to store, manage, and retrieve information efficiently.
● Used in almost every application—websites, banking, schools,
hospitals, etc.
17
Key Features of a Database
● Structured format (usually in rows and columns)
● Searchable and sortable
● Supports data relationships
● Can handle large volumes of data
18
Real-Life Examples
● Student records in a school system
● Inventory in an online store
● Customer info in a banking app
19
Types of Databases
==> Relational Databases (SQL)
e.g., MySQL, PostgreSQL, Oracle
==> NoSQL Databases
e.g., MongoDB, Firebase
==> XML Databases
e.g., BaseX, eXist-db
20
How a Database Works
● Data is stored in tables (like spreadsheets)
● You use a language like SQL to ask questions or get data (called
queries)
● Can be connected to apps via ODBC or other methods
21
Creating a Simple Database in MySQL Workbench
Step 1: Open MySQL Workbench
Launch MySQL Workbench from your [Link] to your MySQL
Server by clicking on the connection (e.g., “Local instance MySQL”).
Step 2: Create a New Database (Schema)
In the top menu, go to File > New Model(optional for creating diagrams).
1. Or directly go to the "SCHEMAS" tab on the left panel.
2. Right-click in the blank space under SCHEMAS.
3. Click "Create Schema".
22
Creating a Simple Database in MySQL Workbench
Step 3: Name Your Database
1. Enter a name for your database (e.g., school_db).
2. Choose default collation (you can leave it as default like
utf8mb4_general_ci).
3. Click Apply
Step 4: Review & Apply SQL Script.
4. A window will pop up showing the SQL command:
CREATE SCHEMA 'school_db';
2. Click Apply.
3. Click Finish.
23
Creating a Simple Database in MySQL Workbench
Step 5: Set the Database as Default
1. Right-click on your new schema (school_db) in the SCHEMAS list.
2. Select “Set as Default Schema”.
Step 6: Create a Table
1. Expand your schema → Right-click "Tables" → Click "Create Table".
2. Enter a table name (e.g., students).
3. Define columns:
id → INT → Primary Key → Auto Increment
name → VARCHAR(100)
age → INT
email → VARCHAR(150)
4. Click Apply → Review SQL → Apply → Finish 24
Creating a Simple Database in MySQL Workbench
Step 7: Insert Sample Data (Optional)
1. Right-click your table (students) → Select Rows - Limit 1000.
2. Click the “Edit” button on the result grid.
3. Add sample rows and click Apply.
25
Create a database for the product list of a mobile company.
26
XML Database
What is an XML Database?
● A type of database that stores and manages data in XML format.
● Unlike traditional relational databases, it stores documents as
hierarchical structures.
● Useful for applications with complex or flexible data models.
28
Why Use XML Databases?
● Stores semi-structured data.
● Data is self-descriptive using tags.
● Supports document-centric storage (e.g., articles, reports).
● Good for data exchange between systems.
29
Key Features
● Stores entire XML documents.
● Supports XPath, XQuery for querying.
● Handles nested and variable data easily.
● Maintains document order and hierarchy.
30
Types of XML Databases
● Native XML Databases
Store data as XML (e.g., BaseX, eXist-db)
● XML-enabled Relational Databases
Traditional databases with XML support (e.g., Oracle, SQL Server).
31
Example XML Data
<student>
<name>Jane Doe</name>
<id>1001</id>
<courses>
<course>Math</course>
<course>Science</course>
</courses>
</student>.
32
Advantages vs. Relational Databases
Feature XML Database Relational Database
Tables (rows &
Data Format Hierarchical XML
columns)
Flexibility High Medium
Query Language XQuery / XPath SQL
Document-based Structured tabular
Best For
data data
33
Structure
Example:
<library> <!-- This is the root element -->
...
</library>
34
Video about XML
XML Database
35
=> Students will design a basic XML structure and simulate storing
and querying data in an XML database.
=> Define at least 3 elements for each entry.
=> Make sure your XML is well-formed (correct tags, nesting).
=>Write 2–3 sample XQuery or XPath queries to retrieve data
36
Open database connection
(ODBC)
ODBC
ODBC (Open Database Connectivity) is a standard API (Application
Programming Interface) that allows software applications to access
different types of databases using a common method—regardless of
the database system (e.g., MySQL, SQL Server, Oracle).
38
Why is ODBC Used?
=> To connect applications to databases.
=> To allow programs (like Excel, Java apps, or reporting tools) to
read/write data from any supported database without changing the
program code.
39
How ODBC Works
=> Application sends a request (e.g., get student records).
=> ODBC Driver translates the request into the database’s specific
language (SQL).
=> Database responds with the data.
=> ODBC returns the data to the application.
40
Components of ODBC:
=> ODBC Driver – Converts requests to/from database-specific
language.
=> Driver Manager – Manages all installed drivers.
=> Data Source Name (DSN) – Configuration that stores the info
needed to connect (server, database name, etc.).
41
Advantages of ODBC
=> Works with many databases (cross-platform).
=> Reduces the need to rewrite applications for each database.
=> Widely supported in enterprise tools and environments.
42
Video
[Link]
43
Lesson 3: Understand XML
Learning Objectives
By the end of this lesson you will understand:
● Structure (Unit 16, KLO 3.1)
● Syntax (Unit 16, KLO 3.2)
● Validation(Unit 16, KLO 3.3)
● Styles (Unit 16, KLO 3.4)
45
Vocabulary
● File ● Check
● Data ● Type
● Group ● Control
● Level ● Confirm
● Section ● Pattern
● Rule
● Format
● Mistake
46
Structure
Structure
XML (Extensible Markup Language) organizes data using a tree-like
structure, where data is stored in elements (also called tags). These
elements have a hierarchical relationship with each other — just like
a family tree.
48
Structure
a) Root Element
❖ The topmost element in an
Example:
XML file.
<library>
<!-- This is the root element -->
❖ Every XML document must
...
have only one root element.
</library>
❖ It contains all other elements.
49
Structure
b) Child Element
❖ A child element is directly
<library>
inside another element
<book> <!-- This is a child of
(usually inside the root).
<library> -->
...
❖ It represents a part of the
</book>
parent’s data.
</library>
50
Structure
c) Sub-child Element
<library>
❖ A sub-child element is a child
<book>
of a child element.
<title>XML Basics</title> <!--
This is a sub-child of <library> -->
❖ It’s a deeper level in the
<author>John Smith</author>
hierarchy.
</book>
</library>
51
Structure
Visual Structure
<library> ← Root
└ <book> ← Child
├── <title> ← Sub-child>
52
Syntax
XML Syntax
XML has specific rules for writing code so that it is readable and
usable by computers and people. These rules are called syntax. If the
syntax is not followed, the XML will be invalid or unreadable.
54
XML Syntax
Rule Description Example
1. XML must have one One element must
✅ <data>...</data>
root element wrap all others
2. Tags must be Every opening tag
✅ <name>John</name>
properly closed needs a closing tag
3. Tags are case-
<Name> ≠ <name> ✅ <Name> + </Name>
sensitive
4. Elements must be ❌ <a><b></a></b>
Tags can't overlap
properly nested ✅ <a><b></b></a>
5. Attribute values Use double or single ✅ <book title="XML
must be in quotes quotes Guide">
55
Optional but Recommended
Start the file with a declaration:
<?xml version="1.0" encoding="UTF-8"?>
56
1. Fix missing and incorrect closing tags.
2. Ensure the root element wraps all child elements.
3. Indent child and sub-child elements.
4. Use proper nesting.
5. Add the XML declaration at the top.
<library>
<book><title>XML Basics<title><author>John Smith</author>
<book>
<book><title>Advanced XML</title><author>Jane Doe</author>
57
Validation
XML Validation
XML validation ensures that an XML document is not only well-
formed but also follows a specific structure defined by a set of rules.
This helps verify that the data in the XML is correct, consistent, and
usable by other systems.
59
Document Type Definition (DTD)
A DTD defines the structure and rules of an XML document. It
specifies which elements can appear, their attributes, and how they
are nested. DTDs are one of the oldest methods of XML validation
and can be included inside the XML file (internal DTD) or linked from
outside (external DTD). However, DTDs only support basic data types
and don’t support XML namespaces.
60
Validating Parsers
A validating parser is a program that checks XML files against a
defined structure like a DTD or XSD. It ensures the file not only has
correct syntax but also follows the expected layout and data rules. If
the file doesn’t match the structure, the parser reports errors or
warnings. These parsers are essential in automated systems that rely
on structured XML data..
61
XML Schema
An XML Schema is a more advanced and powerful way to define the
structure of an XML document compared to DTD. It uses XML syntax
itself and supports complex data types, restrictions, and
namespaces. XML Schema allows you to specify things like whether a
number should be an integer, a date, or a string, giving much more
control over the kind of data allowed.
62
XSD Schema Validator
An XSD Schema Validator is a tool that checks whether an XML
document follows the rules defined in an XSD (XML Schema
Definition) file. It confirms that the XML elements are in the correct
order, required fields are present, and that the data types are
correct. This validator is often used in web services, APIs, and
enterprise systems to guarantee data quality before processing.
63
XML Video with Validation
Step by Step - XML
64
XML Validation with DTD and XSD
❖ Create an XML document.
❖ Validate it using a DTD (Document Type Definition).
❖ Validate it using an XML Schema (XSD).
❖ Use a validating parser to ensure the XML conforms to the
validation rules.
65
Styles
Styles
When we talk about "styles" in the context of XML, there are several
key concepts related to how data is presented or transformed. These
include CSS (Cascading Style Sheets) for styling HTML and XML
documents, and XSLT (Extensible Stylesheet Language
Transformations) for transforming XML into other formats, such as
HTML or plain text. Here’s a detailed explanation of different types of
styles in XML:
67
CSS (Cascading Style Sheets) for XML
CSS is typically used for styling HTML documents, but it can also be
applied to XML documents to control the visual appearance of the
data. While XML itself doesn’t define how the data is displayed, CSS
can be used to define styles like fonts, colors, layout, etc.
68
Example of CSS for XML
Style.C
<?xml version="1.0" encoding="UTF-8"?> book {
<books>
SS
font-family: Arial, sans-serif;
<book> margin: 10px;
<title>Learning XML</title> }
title {
<author>John Doe</author>
font-weight: bold;
<price>29.95</price>
color: blue;
</book> }
<book> author {
<title>Mastering XSLT</title> font-style: italic;
<author>Jane Smith</author> color: green;
<price>39.95</price> }
price {
</book>
color: red; }
</books> 69
How to link CSS with XML
You can then associate <?xml version="1.0" encoding="UTF-8"?>
this CSS with the XML <?xml-stylesheet
<books>
type="text/css" href="[Link]"?>
file to style it visually. <book>
The styles will be <title>Learning XML</title>
<author>John Doe</author>
applied when the XML <price>29.95</price>
is viewed through a </book>
<book>
browser or a rendering <title>Mastering XSLT</title>
tool that supports CSS. <author>Jane Smith</author>
<price>39.95</price>
</book>
</books> 70
XSLT (Extensible Stylesheet Language Transformations)
XSLT is used for transforming XML documents into different formats.
It allows you to apply a "stylesheet" that defines rules to match parts
of the XML and then transform them into HTML, plain text, or even
another XML structure.
XSLT is much more powerful than CSS because it allows you to
perform data transformations, not just presentation. You can
manipulate the XML structure itself and output it in a completely
different form.
71
XSLT (Extensible Stylesheet Language Transformations)
<?xml version="1.0" encoding="UTF-8"?> <b><xsl:value-of
<xsl:stylesheet select="title"/></b><br/>
xmlns:xsl="[Link] Author: <xsl:value-of
ransform" version="1.0"> select="author"/><br/>
<xsl:template match="/"> Price: $<xsl:value-of
<html> select="price"/>
<body> </li>
<h2>Books List</h2> </xsl:for-each>
<ul> </ul>
<xsl:for-each </body>
select="books/book"> </html>
<li> </xsl:template>
</xsl:stylesheet> 72
XSLT (Extensible Stylesheet Language Transformations)
In this XSLT document, we specify how to transform the XML
document into an HTML format. The xsl:for-each loop processes
each <book> element, displaying the title, author, and price inside a
list.
73
XSLT (Extensible Stylesheet Language Transformations)
<html>
<body> <b>Mastering XSLT</b><br/>
<h2>Books List</h2> Author: Jane Smith<br/>
<ul> Price: $39.95
<li> </li>
<b>Learning XML</b><br/> </ul>
Author: John Doe<br/> </body>
Price: $29.95 </html>
</li>
<li>
74
Steps to Apply XSLT Transformation:
1- XML Document: The XML file contains the data.
2- XSLT Stylesheet: The XSLT file defines how to transform the
XML data.
3- Processing: Using an XSLT processor (like xsltproc in Linux or
an XSLT processor in programming languages like Java or
Python), the transformation happens.
75
Match the following
Column 1 Column 2
XSLT Used to repeat over multiple elements in an XML document
CSS Declares the use of an external CSS file in an XML document
<?xml-stylesheet This is the role of CSS when used with XML
type="text/css"
href="[Link]"?>
xsl:for-each A transformation language for converting XML to another
format
Transform XML into HTML Applies style directly to an XML tag using an attribute
XML Presentation Styling Commonly used with XSLT for producing HTML output
style="color:red;" Used to define how data looks, not how it’s structured
76
THANK YOU