Lesson 19 - Develop Website Backend System
Lesson 19 - Develop Website Backend System
Objectives:
1. Define database conceptual model.
2. Identify and normalize attributes and data types.
3. Design data structures.
4. Learn to populate database with test and actual data.
Content:
Database conceptual model is defined
A database model shows the logical structure of a database, including the relationships and constraints
that determine how data can be stored and accessed. Individual database models are designed based on
the rules and concepts of whichever broader data model the designers adopt.
A database model shows the logical structure of a database, including the relationships and constraints
that determine how data can be stored and accessed. Individual database models are designed based on
the rules and concepts of whichever broader data model the designers adopt. Most data models can be
represented by an accompanying database diagram.
There are many kinds of data models. Some of the most common ones include:
You may choose to describe a database with any one of these depending on several factors. The biggest
factor is whether the database management system you are using supports a particular model. Most
database management systems are built with a particular data model in mind and require their users to
adopt that model, although some do support multiple models.
In addition, different models apply to different stages of the database design process. High-level
conceptual data models are best for mapping out relationships between data in ways that people
age 2 of 28
perceive that data. Record-based logical models, on the other hand, more closely reflect ways that the
data is stored on the server.
Selecting a data model is also a matter of aligning your priorities for the database with the strengths of a
particular model, whether those priorities include speed, cost reduction, usability, or something else.
Let’s take a closer look at some of the most common database models.
Relational model
The most common model, the relational model sorts data into tables, also known as relations, each of
which consists of columns and rows. Each column lists an attribute of the entity in question, such as
price, zip code, or birth date. Together, the attributes in a relation are called a domain. A particular
attribute or combination of attributes is chosen as a primary key that can be referred to in other tables,
when it’s called a foreign key.
Each row, also called a tuple, includes data about a specific instance of the entity in question, such as a
particular employee.
The model also accounts for the types of relationships between those tables, including one-to-one, one-
to-many, and many-to-many relationships. Here’s an example:
Within the database, tables can be normalized, or brought to comply with normalization rules that make
the database flexible, adaptable, and scalable. When normalized, each piece of data is atomic, or broken
into the smallest useful pieces.
Relational databases are typically written in Structured Query Language (SQL). The model was
introduced by E.F. Codd in 1970.
Hierarchical model
The hierarchical model organizes data into a tree-like structure, where each record has a single parent
or root. Sibling records are sorted in a particular order. That order is used as the physical order for
storing the database. This model is good for describing many real-world relationships.
age 3 of 28
This model was primarily used by IBM’s Information Management Systems in the 60s and 70s, but they
are rarely seen today due to certain operational inefficiencies.
Network model
The network model builds on the hierarchical model by allowing many-to-many relationships between
linked records, implying multiple parent records. Based on mathematical set theory, the model is
constructed with sets of related records. Each set consists of one owner or parent record and one or
more member or child records. A record can be a member or child in multiple sets, allowing this model
to convey complex relationships.
It was most popular in the 70s after it was formally defined by the Conference on Data Systems
Languages (CODASYL).
age 4 of 28
This model defines a database as a collection of objects, or reusable software elements, with associated
features and methods. There are several kinds of object-oriented databases:
A multimedia database
incorporates media, such as images, that could not be stored in a relational database.
A hypertext database
allows any object to link to any other object. It’s useful for organizing lots of disparate data, but it’s not
ideal for numerical analysis.
The object-oriented database model is the best known post-relational database model, since it
incorporates tables, but isn’t limited to tables. Such models are also known as hybrid database models.
age 5 of 28
Object-relational model
This hybrid database model combines the simplicity of the relational model with some of the advanced
functionality of the object-oriented database model. In essence, it allows designers to incorporate
objects into the familiar table structure.
Languages and call interfaces include SQL3, vendor languages, ODBC, JDBC, and proprietary call
interfaces that are extensions of the languages and interfaces used by the relational model.
Entity-relationship model
This model captures the relationships between real-world entities much like the network model, but it
isn’t as directly tied to the physical structure of the database. Instead, it’s often used for designing a
database conceptually.
Here, the people, places, and things about which data points are stored are referred to as entities, each
of which has certain attributes that together make up their domain. The cardinality, or relationships
between entities, are mapped as well.
age 6 of 28
A common form of the ER diagram is the star schema, in which a central fact table connects to multiple
dimensional tables.
A variety of other database models have been or are still used today.
A database built with the inverted file structure is designed to facilitate fast full text searches. In this
model, data content is indexed as a series of keys in a lookup table, with the values pointing to the
location of the associated files. This structure can provide nearly instantaneous reporting in big data and
analytics, for instance.
This model has been used by the ADABAS database management system of Software AG since 1970, and
it is still supported today.
age 7 of 28
Flat model
The flat model is the earliest, simplest data model. It simply lists all the data in a single table, consisting
of columns and rows. In order to access or manipulate the data, the computer has to read the entire flat
file into memory, which makes this model inefficient for all but the smallest data sets.
Multidimensional model
This is a variation of the relational model designed to facilitate improved analytical processing. While the
relational model is optimized for online transaction processing (OLTP), this model is designed for online
analytical processing (OLAP).
Each cell in a dimensional database contains data about the dimensions tracked by the database.
Visually, it’s like a collection of cubes, rather than two-dimensional tables.
Semistructured model
In this model, the structural data usually contained in the database schema is embedded with the data
itself. Here the distinction between data and schema is vague at best. This model is useful for describing
systems, such as certain Web-based data sources, which we treat as databases but cannot constrain
with a schema. It’s also useful for describing interactions between databases that don’t adhere to the
same schema.
Context model
This model can incorporate elements from other database models as needed. It cobbles together
elements from object-oriented, Semistructured, and network models.
Associative model
This model divides all the data points based on whether they describe an entity or an association. In this
model, an entity is anything that exists independently, whereas an association is something that only
exists in relation to something else.
Semantic model, which includes information about how the stored data relates to the real world
XML database, which allows data to be specified and even stored in XML format
Named graph
Triplestore
age 8 of 28
In addition to the object database model, other non-SQL models have emerged in contrast to the
relational model:
The
graph database model, which is even more flexible than a network model, allowing any node to connect
with any other.
The
multivalue model, which breaks from the relational model by allowing attributes to contain a list of data
rather than a single data point.
The
document model, which is designed for storing and managing documents or semi-structured data,
rather than atomic data.
Most websites rely on some kind of database to organize and present data to users. Whenever someone
uses the search functions on these sites, their search terms are converted into queries for a database
server to process. Typically, middleware connects the web server with the database.
A data type is an attribute that specifies the type of data that the object can hold: integer data,
character data, monetary data, date and time data, binary strings, and so on.
Each column in a database table is required to have a name and a data type.
An SQL developer must decide what type of data that will be stored inside each
column when creating a table. The data type is a guideline for SQL to
understand what type of data is expected inside of each column, and it also
identifies how SQL will interact with the stored data.
Each column in a database table is required to have a name and a data type.
An SQL developer must decide what type of data that will be stored inside each
column when creating a table. The data type is a guideline for SQL to
understand what type of data is expected inside of each column, and it also
identifies how SQL will interact with the stored data.
In MySQL there are three main data types: string, numeric, and date and time.
ENUM(val1, val2, A string object that can have only one value, chosen
val3, ...) from a list of possible values. You can list up to 65535
values in an ENUM list. If a value is inserted that is not
in the list, a blank value will be inserted. The values are
sorted in the order you enter them
SET(val1, val2, A string object that can have 0 or more values, chosen
val3, ...) from a list of possible values. You can list up to 64
values in a SET list
DOUBLE
PRECISION(size, d)
age 12 of 28
Note: All the numeric data types may have an extra option: UNSIGNED or
ZEROFILL. If you add the UNSIGNED option, MySQL disallows negative values
for the column. If you add the ZEROFILL option, MySQL automatically also
adds the UNSIGNED attribute to the column.
datetime2 From January 1, 0001 to December 31, 9999 with 6-8 bytes
an accuracy of 100 nanoseconds
Lookup Wizard Let you type a list of options, which can then be 4 bytes
chosen from a drop-down list
A data structure is a specialized format for organizing, processing, retrieving and storing data. There are
several basic and advanced types of data structures, all designed to arrange data to suit a specific
purpose. Data structures make it easy for users to access and work with the data they need in
appropriate ways.
The process of development and organization of data structures that can effectively store, manipulate,
and retrieve data in a computer program or system is termed data structure design. Effective data
management and organization are crucial for performance optimization, enabling efficient algorithms,
and facilitating data manipulation and access.
The specification of the programme (what the programme does) serves as the starting point for the data
structure design approach, which ends with the detailed programme design presented as a pseudo-
code.
1. Creation of diagrammatic representations of input and output data structures that will be used by the
programmer.
2. Creation of a single programme structure diagram with the combination of all data structure
programmes.
3. Determine and record the actions that the programme will take.
4. Connect the programme structure diagram to these specified operations and then put all these
operations in the suitable spot in the programme.
5. In the last step, this programme structure diagram is then transformed into a pseudo-code.
Efficiency: To make the best use of system resources like time and memory, data structures should
be created. They should carry out tasks quickly and simply, reducing the time and physical space
requirements of routine tasks like insertion, deletion, searching, and retrieval.
Correctness: The data structure should deliver correct results and serve the desired goal. It should
be able to handle every input and operation without making any unforeseen mistakes or
inconsistencies.
Encapsulation: Both the data and the operations that can be applied to it should be contained
within data structures. This protects data integrity and hinders unauthorized access by making sure
that the internal representation and alteration of the data are hidden from outside parties.
age 18 of 28
Abstraction: Data structures ought to offer a distinct and well-defined interface or abstraction that
shields users from implementation-specific details. It makes codebase easier to understand.
Reusability: To protect users from implementation-specific details, data structures should provide a
unique and clearly defined interface or abstraction. This promotes modularity and makes it simpler
to comprehend and manage the programme.
Credibility: Data structures should be created to support a variety of use cases and applications.
They ought to be adaptive and versatile, enabling simple extension or alteration without
significantly altering the underlying structure.
Maintainability: Maintainability should be considered while designing data structures so that the
codebase is simpler to comprehend, alter, and troubleshoot. The maintainability of the data
structures can be significantly improved by employing clear and succinct naming conventions,
adequate documentation, and adherence to coding standards.
Scalability: Scalable data structures can manage to expand or shift data sizes. The system should be
able to handle increasing workloads without noticeably degrading performance since it should
demonstrate strong performance characteristics even when dealing with enormous datasets.
Modularity: Modular data structures would enable autonomous component creation and testing.
This makes code organization easier, encourages code reuse, and makes debugging and
troubleshooting procedures simpler.
Consistency: The consistent architecture of data structures guarantees that related actions or
functionality operate predictably and consistently. It makes data structure less complex and more
usable.
Choosing the Right Data Structure: The right data structure must be chosen for an application to be
effective and scalable. Consider your data’s qualities and select a structure that offers effective
operations for the necessary use cases. Examples of common data structures are graphs, hash
tables, trees, arrays, linked tables, etc.
Understanding the Requirement: Be sure to fully comprehend the needs of your application before
building a data structure. Optimize the data structure based on the activities that must be carried
out frequently.
Optimization of Access Pattern: Before creating a data structure, make sure you thoroughly
understand the requirements of your application. Optimize the data structure based on the
frequent actions that must be taken.
Minimization of Memory Footprint: Effective data structures make good use of memory. Reduce
unused memory usage by selecting the right data types and storage-optimizing techniques. Think
about the trade-offs between time complexity and memory utilization.
Consider Caching: Performance can be greatly enhanced by using caching techniques. Create data
structures that benefit from caching techniques, such as by implementing LFU (Least Frequently
Used) or LRU (Least Recently Used) caching algorithms.
Minimized unnecessary copying: Reduce the amount of needless data copying to save overhead.
Use pointers or references to share data between data structures whenever possible to avoid
duplicating data.
Maintaining a balance between the elements like deletions, insertions, and lookups: Choose an
appropriate balance between effective deletions, insertions, and lookups depending on the criteria
of the application. Some data structures are more advantageous than others when it comes to
age 19 of 28
certain processes. For instance, balanced search trees like AVL trees offer quick lookups but take
longer to insert data than hash tables do.
Analyze Space and Time Complexity: Select an appropriate ratio of effective insertions, deletions,
and lookups based on the specifications of your application. Some data structures perform better
than others when it comes to certain processes. For example, hash tables insert data more quickly
than balanced search trees, such as AVL trees, which provide quick lookups.
Modularize the data structure: Create modular, reusable data structures for your applications.
Make construction elements that can be joined to create more intricate buildings. This strategy
encourages the maintainability of the code, minimizes duplication, and permits scalability.
Use pre-existing libraries: Use pre-existing libraries or frameworks that offer effective and scalable
data structures whenever possible. These libraries are often performance-tested and enhanced.
Test and Benchmark: Benchmark the performance of your data structures after thoroughly testing
them with representative data sets.
Most computer programming languages’ standard base data types, such as integers or floating-point
numbers, are typically insufficient to convey the logical intent for data processing and application.
However, in order to make processing easier, programmes that consume, manipulate, and output
information need to be aware of how data should be organized. Data structures enable the efficient
usage, persistence, and sharing of data by logically combining the data parts. They offer a formal model
that outlines the arrangement of the data items.
Data structures serve as the foundation for more complex applications. In order to create them, data
components are combined into logical units that reflect abstract data types relevant to the algorithm or
application. A “customer name” is an illustration of an abstract data type. It is made up of the character
strings for the “first name,” “middle name,” and “last name.”
Databases are a critical component of most software systems and applications. As a result, thoroughly
testing and validating databases is essential to ensure systems function properly.
Database Testing
Database testing refers to the process of checking a database system to verify it meets requirements and
performs as expected. The main goals of database testing include:
Validating Data Integrity: Confirming the accuracy and consistency of data stored in the database.
This includes checking for any corrupted, duplicate, or missing data.
Verifying Functionality: Testing common database operations like inserts, updates, deletes, and
queries to ensure they work as intended.
Assessing Performance: Load testing and benchmarking databases under expected workloads in
terms of response times, throughput, resource utilization, and scalability.
age 20 of 28
Testing Backup and Recovery: Validating backup plans and disaster recovery procedures
successfully restore database contents and functionality.
Checking Security: Testing user authentication, access controls, encryption, and other security
measures.
Confirming Compliance: Ensuring the database meets regulatory compliance standards if required.
This is common in financial services, healthcare, etc.
Database testing is an important step in minimizing data loss and corruption, avoiding system failures,
and reducing cybersecurity risks that could occur in production if databases have undiscovered flaws.
Unit Testing: Developers should create low-level test cases that target individual database
components like triggers, procedures, queries, etc. This is done during initial development.
Integration Testing: Expands testing to how the database interacts with other application
components like the UI, APIs, middleware, etc.
System Testing: Testing the entire system end-to-end, including the production-like database, to
validate functional requirements.
Performance Testing: Executing load and stress testing at expected production loads early on and
continuing through staging environments.
age 21 of 28
User Acceptance Testing (UAT): Having end users test with real-world scenarios and data to confirm
the system handles required use cases.
Regression Testing: Retesting the database anytime changes are made to confirm no new issues
were introduced.
Production Monitoring: Continuously monitoring database health, performance metrics, and logs
after going live.
This testing across the entire development lifecycle helps minimize defects and ensures optimal database
performance.
Planning
Defining the scope, objectives, timeline, environment needs, and resources required. Identify relevant
test conditions like target database, tooling, test data, etc.
Analysis
Study the database schema, architecture, and components to identify key areas to test like performance-
critical queries or tables, security controls, etc.
age 22 of 28
Test Design
Outline test cases that evaluate the desired functionality, performance, security, and data integrity per
requirements. Effective test cases include clear objectives, setup steps, test data, input values, expected
results.
Test Execution
Run designed test cases while recording results — passed, failed, blocked. Failed and blocked cases are
investigated and usually re-run after resolving underlying issues.
Defect Reporting
Log any defects uncovered and track them through resolution. Defect reports typically detail repro steps,
actual vs expected results, screenshots, stack traces, database logs, etc.
Test Closure
Final check of open defects and validation of fixes. Summary reports detail scope covered, successes,
challenges, and remaining risks if any.
Functional Testing
Validating database operations and components deliver expected functionality per specifications:
Schema Testing
Data Validation: Confirm expected data formatting, types, field lengths, mandatory fields, etc.
Referential Integrity: Ensure no orphan records exist that break foreign key relationships.
Performance Testing
Volume Testing
Security Testing
Attempt breaches from outside through exploits like SQL injection or unauthorized insider access.
Upgrade Testing
Test migrations to new RDBMS versions.
Regression Testing
Retest previously functioning components after any changes.
Test Environments
Database testing requires environments that mirror production:
Development: Used for initial unit and integration testing. Allows iterative coding without
corrupting real data.
QA/Staging: Isolated environment with production-sized data, users, transactions. Essential for
performance, load, UAT testing before going live.
Production: The live database used by end users. Continuously monitored and tested in production.
Virtual environments make replicating production easier without need to copy real data into lower
environments.
MySQL
Popular open source database. Test using SQL statements, MySQL Workbench GUI, Percona Toolkit.
Oracle
Leading enterprise database. Test with PL/SQL, SQL Developer, Oracle SQLcl.
PostgreSQL
Advanced open source SQL database gaining popularity. Test via psql, pgAdmin, PL/pgSQL.
MongoDB
Leading NoSQL document database. Validate using mongo shell, pymongo, Atlas cloud.
Cassandra
High performance NoSQL column store. Test with CQL, cqlsh, DataStax Studio.
age 25 of 28
IBM DB2
Mature enterprise database. Test through DB2 CLP, IBM Data Studio, JCL.
Specialized tools simplify planning, automating, managing, and reporting on database tests:
SQL Clients: Execute SQL statements — MySQL Client, Oracle SQLcl, psql
Database IDEs: Develop and debug — Toad, SQL Developer, SSMS
Diff Tools: Compare dataset differences — Toad, SQL Data Compare
Executable Specifications: Auto-generate tests from requirements — SpecFlow
Test Data Management: Rapidly provision test data — Delphix, CA Data Manager
Performance Monitoring: Analyze bottlenecks under load — SolarWinds DPA
Test Management: Document and track execution — TestRail, Kualitee
CI/CD Pipelines: Automate deployments and testing — Jenkins, Bamboo
age 26 of 28
Teachers Activity:
Ask Question
Show Presentation
Demonstration
Show video:
https://www.youtube.com/watch?v=wR0jg0eQsZA
Reference:
Site:
https://www.google.com/
https://www.youtube.com/
https://www.lucidchart.com/pages/database-diagram/database-models#:~:text=A%20database
%20model%20shows%20the,data%20model%20the%20designers%20adopt.
https://www.geeksforgeeks.org/attributes-and-its-types-in-data-analytics/
https://www.w3schools.com/sql/sql_datatypes.asp
https://ifacet.iitk.ac.in/knowledge-hub/data-structure-with-c/data-structure-design-principles-and-best-
practices-for-creating-efficient-and-scalable-data-structures/
https://medium.com/@sikirus81/database-testing-a-complete-guide-81e2b81b48c3
eBook:
Database Design and Implementation by: Dr. Weiru Chen
Database Design – 2nd edition by: Adrienne Watt and Nelson Eng
Assessment 19-1:
age 27 of 28
Written Test
Test I: True or False: Write the letter T if the statement is true and F if the statement is false on the
space provided.
_____________ 1. Data structures serve as the foundation for more complex applications
_____________ 2. Most computer programming languages’ standard base data types, such as
integers or floating-point numbers, are typically insufficient to convey the
logical intent for data processing and application.
_____________ 3. Reduce used memory usage by selecting the right data types and storage-
optimizing techniques. Think about the trade-offs between time
complexity and memory utilization.
_____________ 4. Create modular, reusable data structures for your applications.
_____________ 5. Benchmark the performance of your data structures after thoroughly
testing them with representative data sets.
_____________ 6. Reduce the amount of needless data copying to save overhead. Use
pointers or references to share data between data structures whenever
possible to avoid duplicating data.
_____________ 7. Performance can be greatly enhanced by using modeling techniques.
_____________ 8. Scalable data structures can manage to expand or shift data sizes.
_____________ 9. To make the best use of system resources like time and memory, data
structures should be created.
_____________ 10. The process of development and organization of data structures that can
effectively store, manipulate, and retrieve data in a computer program or
system is termed data structure design.
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
age 28 of 28
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
Test III: Multiple Choice: Write your chosen letter on the space provided.