<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Alexander S. Ricciardi on Medium]]></title>
        <description><![CDATA[Stories by Alexander S. Ricciardi on Medium]]></description>
        <link>https://medium.com/@alex.omegapy?source=rss-ad07757dbf8a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*DhJQx4mUH0GOuGEYagxdMg.png</url>
            <title>Stories by Alexander S. Ricciardi on Medium</title>
            <link>https://medium.com/@alex.omegapy?source=rss-ad07757dbf8a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 08:02:58 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@alex.omegapy/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[The Two Phases of the AI Revolution]]></title>
            <link>https://levelup.gitconnected.com/the-two-phases-of-the-ai-revolution-3a42e9fd446d?source=rss-ad07757dbf8a------2</link>
            <guid isPermaLink="false">https://medium.com/p/3a42e9fd446d</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[ai-revolution]]></category>
            <dc:creator><![CDATA[Alexander S. Ricciardi]]></dc:creator>
            <pubDate>Mon, 27 Jul 2026 23:46:21 GMT</pubDate>
            <atom:updated>2026-07-27T23:46:21.725Z</atom:updated>
            <content:encoded><![CDATA[<p>This article proposes that the recent emergence of AI technologies is an AI revolution, and this revolution may unfold in two phases: a digital-intelligence phase reshaping knowledge work and decision-making, followed by an embodied and distributed intelligence phase integrating AI into robotics, infrastructure, industry, and other physical systems. It argues that within this revolution, AI accelerates scientific progress and improves productivity, while also disrupting the workforce and creating serious societal risks unless governments, businesses, educational institutions, and individuals adapt responsibly to its rapid development.</p><figure><img alt="AI workshop with presenter pointing at a screen titled The Two Phases of the AI Revolution, while a diverse team listens in a bright lab." src="https://cdn-images-1.medium.com/max/1024/1*vhclc_rE9twmyGCf7F8gMw.png" /></figure><p>Humanity is at the dawn of a new technological revolution fueled by AI, an AI revolution fueled by an intelligence explosion. AI is transformational technology that has the potential to fundamentally change how individuals work, communicate, make decisions, and conduct their daily lives. The AI revolution may be compared to the Industrial Revolution, as both revolutions involve a fundamental shift in how work is done and what is produced, improving existing products and creating new ones. The change brought about by the Industrial Revolution significantly affected people’s everyday lives; the AI revolution may bring even more profound and far-reaching changes to everyday life. Moreover, as with the Industrial Revolution, the AI revolution may unfold in two major phases. Starting with the digital-intelligence phase, in which digitally contained AI systems transform knowledge work, communication, research, and decision-making. The digital-intelligence phase is followed by the embodied and distributed intelligence phase, in which AI becomes integrated into robots, autonomous machines, and large distributed cyber-physical systems. Within these two phases, AI may transform the nature of work significantly, alter the composition of the workforce, accelerate scientific and technological progress, and create both opportunities and profound societal changes, causing social instability.</p><p>When comparing the AI revolution with the Industrial Revolution. The Industrial Revolution happened in two major phases. The first phase (1760–1840) was a shift from agrarian societies to industrialized, machine-driven manufacturing; the revolution was driven by steam power and coal (Library of Congress, n.d.; Kordas et al, 2022). The second phase (1840–1914) was a shift from steam-powered, coal, and wood production to steel, mass production, electricity, combustion engines, and petroleum (Majumdar, 2012; Kordas et al, 2022).</p><p><strong>Figure 1</strong> <br><em>The two Phases of the AI Revolution</em></p><figure><img alt="Infographic showing two phases of the AI revolution, from digital intelligence to embodied robotics, with a path from ANI to ASI." src="https://cdn-images-1.medium.com/max/1024/0*8Ey3YP5Lrdwz5X3U.png" /></figure><p><em>Note: </em>The infographic illustrates the two phases of the AI Revolution. Created with OpenAI Image 2 model.</p><p>The AI revolution may also unfold in two phases:</p><p>The first phase may be defined as the digital-intelligence phase. In this phase, AI is confined within data centers, and it evolves from narrow AI, Large Language Model (LLM), Large Reasoning Model (LRM), Agentic AI, to General Intelligence (AGI). This year, 2026, AI has reached the Agentic AI stage. AGI stage may be reached by 2030 (Kokotajlo et al., 2025)</p><p>“AGI stands for Artificial General Intelligence, which means an AI system with general, human-level (or beyond) ability to learn, reason, and apply knowledge across a wide range of tasks and domains. AGI systems conceivably could handle novel situations, not just perform well on a single, narrow task. The term is controversial in several ways, including that different people mean different things by “human-level intelligence,” and there’s no universally accepted test, so claims are hard to verify. There are also safety and ethical concerns debated by AI experts.” (Stanford Institute for Human-Centered Artificial Intelligence, n.d.)</p><p>The second phase may be defined as the embodied and distributed intelligence phase. In this phase, AI is embodied within robots, giving it the ability to perceive, navigate, interact, and act on the physical world. It is also when AI is heavily integrated within distributed cyber-physical systems, giving it the ability to coordinate autonomous machines and software agents; make real-time decisions; and monitor and control large industrial complexes, infrastructure networks, financial processes, governmental processes, transportation systems, supply chains, and other large distributed systems. In this phase, AI may evolve from AGI to Artificial Super Intelligence (ASI).</p><p>“Artificial superintelligence (ASI) is a hypothetical software-based artificial intelligence (AI) system with an intellectual scope beyond human intelligence. At the most fundamental level, this superintelligent AI has cutting-edge cognitive functions and highly developed thinking skills more advanced than any human.” (Mucci &amp; Stryker, 2023)</p><p>During the digital-intelligence phase that we are experiencing in its early stages today, 2026, similarly to the first phase of the Industrial Revolution, AI is beginning to be integrated into production systems, communication, and decision-making. This integration is changing the nature of many jobs, especially white-collar jobs that rely heavily on knowledge work, by automating cognitive and knowledge tasks. This automation has the capacity to simplify complex cognitive work and allow easy access to large repositories of technical, administrative, and scientific knowledge. Human workers’ roles will need to move toward oversight of AI, judgment, design, and responsibilities. For example, a junior software engineer, just a couple of years ago, was expected to do most of the coding for a software project based on directions provided by a senior software engineer. Today, a junior software engineer needs to understand how to prompt and oversee coding agents, use various coding harnesses, and verify/test/validate/comprehensively communicate the coding agents’ coding outputs to a team; these tasks are significantly more difficult than just coding-based work; a couple of years ago, these tasks were mostly performed by a establish or senior software engineer, not by junior software engineer.</p><p>This implies that, to some degree, all jobs will be impacted, but more significantly, white-collar jobs. The composition of the white-collar workforce is already changing due to increasing demand for workers with high technical, managerial, analytical, and communication skills, while there is reduced demand for entry-level white-collar roles requiring repetitive administrative and basic knowledge work. Society needs to adapt as AI is being integrated into almost every aspect of everyday life, from how individuals work and interact on social media to how they communicate with chatbots, receive healthcare and educational services, access information, and make financial or personal decisions. These changes will require society to be more AI-literate, education to be transformed to accommodate AI technology, businesses to offer AI training to employees, governments to have stronger privacy protections, transparent AI decision-making, clear accountability standards, and equitable access to AI technologies.</p><p>During the embodied and distributed intelligence phase, similarly to the second phase of the Industrial Revolution, society may experience an intelligence explosion, where AI technologies may evolve into extremely powerful technologies, beyond digital environments, and into an intelligence explosion that will power physical systems and distributed cyber-physical systems such as critical infrastructure. Embodied AI could significantly change how blue-collar workers do their jobs, similar to the white-collar workers in the first phase; they may have to shift from directly performing repetitive, physically strenuous, or dangerous/hazardous tasks to supervising autonomous machines controlled by AIs, operating robotic systems, diagnosing AI/robotic problems, performing AI/robotic maintenance, and coordinating AI/robotic teams. Consequently, the blue-collar roles may shift more toward roles requiring more technical, analytical, operational, and communication skills. The impacts of embedding AI, especially ASI, within distributed cyber-physical systems such as industrial complexes and critical infrastructure are too early to predict with confidence. However, it is a reasonable expectation that the societal effects of ASI would be extreme, as the technology will probably be deeply embedded in every society’s physical, economic, governmental, and technological systems.</p><p><strong>Figure 1<br></strong><em>The ANI-AGI-ASI Train</em></p><figure><img alt="The image illustrates the transition from Artificial Narrow Intelligence (ANI) to Artificial General Intelligence (AGI) and to Artificial Super Intelligence (ASI)." src="https://cdn-images-1.medium.com/max/1024/1*5VI0QpyoI7EYus1mwgjWZA.png" /></figure><p><em>Note:</em> the image illustrates the transition from Artificial Narrow Intelligence (ANI) to Artificial General Intelligence (AGI) and to Artificial Super Intelligence (ASI). The image is a modified illustration of a “The AI Revolution: Our Immortality or Extinction” cartoon by Urban, T. (2015, January 27). Wait But Why. <a href="https://waitbutwhy.com/2015/01/artificial-intelligence-revolution-2.html">https://waitbutwhy.com/2015/01/artificial-intelligence-revolution-2.html</a></p><p>Daniel Kokotajlo (former OpenAI super-alignment researcher) and its team have developed a predictive model where superintelligence could emerge before 2030, driven by recursive self-improvement (Kokotajlo et al, 2025). Google DeepMind CEO Demis Hassabis (2026) stated:</p><p>“The magnitude of this [AI] technology’s impact will be unprecedented, perhaps 10x of the Industrial Revolution at 10x the speed. It will help us solve some of the biggest problems society faces, from accelerating drug discovery to developing new clean energy sources to creating novel advanced materials.”</p><p>In other words, AI is a research accelerator that allows scientists to analyze enormous quantities of information, generate and evaluate hypotheses, design experiments, discover patterns, and explore solutions at a speed and scale that would be impossible for any human research team. Moreover, AI’s recursive self-improvement could enable AI systems to improve their own design, accelerating the speed at which research is done and technology advances, resulting not only in an intelligence explosion but also in an unprecedented scientific and technological revolution.</p><p>The aspect of AI technology integration into businesses that will most significantly impact the nature of jobs and the composition of the workforce is the speed at which this transformation may occur. During previous technological revolutions, workers, educational institutions, businesses, and governments often had decades to adapt to new technologies. In contrast, this AI revolution’s speed may profoundly change the nature of many jobs and the composition of the workforce. Consequently, society may have to face serious issues such as displaced workers having nowhere to go, outdated educational programs, and ineffective regulations that will affect negatively everyday life. Thus, it is essential for society not only to adopt AI technologies but also to adapt to the speed at which these technologies are developing and being integrated into workplaces. Governments, businesses, and educational institutions must anticipate these changes, continuously update workforce training and academic programs, and establish flexible regulations capable of responding to rapidly evolving AI systems.</p><p>The AI revolution, fueled by an intelligence explosion, may become one of the most transformative events in human history. Its digital-intelligence phase is already beginning to reshape knowledge work, communication, education, research, and decision-making, and its embodied and distributed intelligence phase may transform physical labor, infrastructure, industry, and government, bringing profound and far-reaching changes to everyday life. Ultimately, the outcome, positive or negative, of this intelligence explosion will depend on whether governments, businesses, educational institutions, and individuals can adapt responsibly to the speed of its development. AI is extraordinary powerful technology that, if managed wisely, may take us to the stars; if managed recklessly, it may ensure that we never reach them.</p><p><strong>References:</strong></p><p>Hassabis, D. [@demishassabis]. (2026, July 14). <em>AI is already starting to deliver real-world benefits but to realise its immense promise, we have to navigate this critical</em> [Post]. X. <a href="https://x.com/demishassabis/status/2076957440109625718">https://x.com/demishassabis/status/2076957440109625718</a></p><p>Kokotajlo, D., Alexander, S., Larsen, T., Lifland, E., &amp; Dean, R. (2025, April 3). <em>AI 2027</em>. AI Futures Project. <a href="https://ai-2027.com/race">https://ai-2027.com/race</a></p><p>Kordas, A., Lynch, R. J., Nelson, B., &amp; Tatlock, J. (2022). 9.1 The Second Industrial Revolution. <em>World history volume 2, from 1400</em>. OpenStax. <a href="https://openstax.org/books/world-history-volume-2/pages/9-1-the-second-industrial-revolution">https://openstax.org/books/world-history-volume-2/pages/9-1-the-second-industrial-revolution</a></p><p>Library of Congress. (n.d.). <em>The Industrial Revolution in the United States</em>. U.S. Government. <a href="https://www.loc.gov/classroom-materials/industrial-revolution-in-the-united-states/">https://www.loc.gov/classroom-materials/industrial-revolution-in-the-united-states/</a></p><p>Majumdar, S. K. (2012). Industrial revolutions. In <em>India’s late, late industrial revolution</em>. Cambridge University Press. <a href="https://www.cambridge.org/core/books/abs/indias-late-late-industrial-revolution/industrial-revolutions/60FDB79FC74F5B6238F36865AB87D86F?utm_source=chatgpt.com">https://www.cambridge.org/core/books/abs/indias-late-late-industrial-revolution/industrial-revolutions/60FDB79FC74F5B6238F36865AB87D86F?utm_source</a></p><p>Mucci, T., &amp; Stryker, C. (2023, December 14). <em>What is artificial superintelligence?</em> IBM. <a href="https://www.ibm.com/think/topics/artificial-superintelligence">https://www.ibm.com/think/topics/artificial-superintelligence</a></p><p>Stanford Institute for Human-Centered Artificial Intelligence. (n.d<strong>.). </strong><em>What is AGI (artificial general intelligence)?</em> <a href="https://hai.stanford.edu/ai-definitions/what-is-agi-artificial-general-intelligence">https://hai.stanford.edu/ai-definitions/what-is-agi-artificial-general-intelligence</a></p><p><em>Originally published at </em><a href="https://www.alexomegapy.com/post/understanding-short-circuit-in-python-s-compound-conditional-expressions"><em>https://www.alexomegapy.com</em></a><em> on July 21, 2026.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3a42e9fd446d" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/the-two-phases-of-the-ai-revolution-3a42e9fd446d">The Two Phases of the AI Revolution</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ethical Responsibility in Data Processing]]></title>
            <link>https://levelup.gitconnected.com/ethical-responsibility-in-data-processing-775ffa165f59?source=rss-ad07757dbf8a------2</link>
            <guid isPermaLink="false">https://medium.com/p/775ffa165f59</guid>
            <category><![CDATA[ethics]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[data-management]]></category>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[data-processing]]></category>
            <dc:creator><![CDATA[Alexander S. Ricciardi]]></dc:creator>
            <pubDate>Mon, 26 Jan 2026 04:57:44 GMT</pubDate>
            <atom:updated>2026-01-26T04:57:44.127Z</atom:updated>
            <content:encoded><![CDATA[<p>The article describes data processing as a curatorial process rather than a neutral technical task, and argues that values and biases are encoded at every stage of the data lifecycle. To safeguard against ethical failures like those seen at OkCupid and Amazon, the article proposes implementing within data processing a framework centered on dignity, autonomy, necessity, and the common good. Finally, the article encourages data practitioners to interrogate the “why” behind every technical decision to ensure that data systems serve to empower individuals and society rather than becoming instruments of exploitation, bias, and harm.</p><figure><img alt="A person in a blue hoodie points at a data processing lifecycle diagram on a board. Text discusses ethical implications and biases." src="https://cdn-images-1.medium.com/max/1024/1*rhOG0TVN_Z_IdGhpaeUw-Q.png" /></figure><p>The goal of data processing is to convert raw data into useful information that can be utilized for analysis, modeling, and operational action. This process follows a lifecycle that includes six stages: Collection, Preparation, Input, Processing, Output, and Storage (UAGC Staff Member, 2024). These stages are often referred to as “janitorial” and purely technical processes. However, this view is dangerously reductive, as the process is far from a neutral activity or a purely harmless technical exercise. Decision-making is an integral part of data processing, where subjective values can be intentionally encoded at every stage of processing. Boyd, a partner researcher at Microsoft Research and the founder/president of Data &amp; Society, stated, “<em>There is nothing about doing data analysis that is neutral… what and how data is collected, how the data is cleaned and stored… all of this is political</em>” (Boyd, 2017, p.1). This suggests that data processing is not just a purely neutral, janitorial, and technical task but rather a curatorial process with ethical implications. This paper argues that data processing is the primary locus where abstract values can be transformed into concrete outcomes. Consequently, this process must be encapsulated in an ethical framework from planning to implementation to prevent the encoding of harmful biases and the violation of human rights principles: Dignity, Autonomy, Necessity, and the Common Good.</p><p><strong>The Neutral Tool Fallacy</strong></p><p>A common misconception is the assumption that technology is ethically neutral, that its morality depends not on its design, but on how the technology is used. This is analogous to the argument that “guns don’t kill people, people do,” a logic that ignores why a tool is designed the way it is. This “why” defines the intent behind the design, embedding specific features into the tool’s functionality before it is ever used. In data processing, decision-making is an integral part of the process during the design and implementation phases, meaning that the choices made during the data lifecycle are not just technical; they are curatorial. For example, when a data architect decides which attributes to gather or which outliers to discard, they are making decisions that dictate what counts as a data signal; in other words, whose perspective is deemed eligible and whose is dismissed as noise or treated as an exception. These curatorial decisions intervene within each stage of the data processing lifecycle, raising ethical concerns or questions such as:</p><ul><li>In the collection stage, when gathering raw data from sources (sensors, surveys), what is being measured, what is being ignored, and why?</li><li>In the preparation stage, when cleaning or wrangling the collected data to remove errors. Who defines what an error or an outlier is, and why it is defined as an outlier or an error?</li><li>In the input stage, when converting the cleaned data into machine-readable formats for a machine learning application. Why are these formats being used? Do they accurately reflect the context, identities, and constraints that the cleaned data represent, or do they diminish the true complexity of it within misleading and simplified categories?</li><li>In the processing stage, when running algorithms (AI/ML) on the formatted data to uncover patterns. Why have these algorithms been selected? Do the algorithms prioritize efficiency over accuracy and transparency?</li><li>In the output stage, when transmitting or analyzing the final results from processed datasets and models using reports, graphs, or dashboards. Why have these methods been chosen? How is the final results data framed, displayed, or delivered to the decision-maker or the public?</li><li>In the storage stage, when recording data and metadata. Who can access the data, why, how long it is retained, and whether it can be repurposed beyond the original consent?</li></ul><p>This set of questions demonstrates that when wrapped in a framework of ethical questions, specifically the “why,” the rationale behind each technical choice, the data processing lifecycle is not a neutral tool, as the perspective and intentionality of use are integral to its design and implementation. By interrogating the “why” of each technical decision, a data processing professional can practice ethical responsibility, and failing to ask these questions may inject biases hidden behind technical requirements and arguments.</p><p><strong>Ethical Framework for Data Practitioners</strong></p><p>To practice ethical responsibility associated with data processing, practitioners must adopt an ethical framework grounded in the preservation of human rights, which is an approach that ethically evaluates every technical data processing decision against four ethical questions:</p><ol><li>Does it preserve or enhance human dignity?</li><li>Does it preserve the autonomy of the human?</li><li>Is the processing necessary and proportionate?</li><li>Does it uphold the common good?</li></ol><p>(O’Keefe &amp; Brien, 2023, p.35)</p><p>This set of questions can be used to encapsulate an ethical framework that evaluates each data processing decision against four principles of human rights: Dignity, Autonomy, Necessity, and the Common Good. Dignity asks whether the processing respects the worth of individuals or reduces them to a simple data point. Autonomy asks whether the processing preserves the freedom and agency of individuals through controls such as consent and privacy protection, allowing individuals to have agency over their personal data, choosing how their data can be processed, if at all. Necessity asks whether the processing can be justified as necessary and proportionate, meaning the processing’s benefits outweigh the risks of harm or exploitation. Finally, the Common Good asks whether the processing design and implementation genuinely serve the public interest. In practical terms, this ethical framework questions the intent of data processing decisions by evaluating their outcome, allowing data processing practitioners to evaluate the ethicality of each of their technical choices against their expected outcomes. In other words, the framework asks whether the rationale, the “why”, behind each decision preserves human rights. Moreover, applying this framework could prevent ethical failures such as the OkCupid data release and Amazon recruiting tool bias, which have tarnished both organizations’ public trust.</p><p><strong>OkCupid Release Case Study</strong></p><p>In 2016, researchers at OkCupid, a popular dating app, scraped 70,000 online dating profiles (including usernames, demographics, and intimate questionnaire answers) and released the dataset publicly to the Open Science Framework for psychological research without asking users or the company for permission (Woollacott, 2016). The researchers justified making the data publicly available on a technicality, arguing that the nature of the data was public as the user profiles were viewable to other users on the OKCupid site. However, this argument is not ethically viable as it violates the Autonomy principle. Although the data was technically, to some extent, publicly accessible, the users had shared their data in the context of a platform for dating services; they never consented to their personal data being used or reprocessed for research or public distribution. This was a violation of both the Association of Internet Researchers and the American Psychological Association, stating that participants have a right to informed consent, which includes understanding how their data will be used (Franzke et al., 2020; APA, 2014). By labeling the processing of the dataset as a neutral technicality and prioritizing it over the autonomy of the individuals, the researchers violate the fundamental human right to control one’s own digital identity. It was a clear ethical failure.</p><p><strong>Amazon’s Recruiting Tool Bias Case Study</strong></p><p>In 2014, Amazon engineers started to build an automated hiring software to facilitate the search for top talent by reviewing job applicants’ resumes using a supervised machine-learning résumé screening and ranking AI model (Dastin, 2018). However, a couple of years later, the project was scrapped as the AI model was found, by Amazon’s own machine-learning specialists, to be very biased against women. Specialists traced the cause of the bias to the training dataset, which consisted of résumés from Amazon tech applicants mirroring the historical male-dominated U.S. tech industry. This introduced a male gender implicit bias within the training of the AI model, resulting in the AI tool penalizing résumés that included the word “women’s,” in terms like “women’s chess club captain.” Such oversight from the Amazon engineers may be attributed to treating the data processing lifecycle’s collection and preparation stages as a neutral technical process rather than a curatorial process with ethical implications. In other words, the engineers failed to adequately clean the data and rebalance the dataset to account for the historical underrepresentation of women. Furthermore, when analyzed through an ethical framework, the engineering team failed to apply the Dignity and the Common Good principles, and by analyzing the “whys” behind their technical decisions. They fail to apply these principles by choosing technical processes reflecting historically beneficial and successful raw statistical patterns, over ensuring that the tool’s résumés vetting processes were equitable and fair. Moreover, if the tool had been implemented as it was, it could have resulted in major lawsuits and a loss of reputation for Amazon. For its part, Amazon has failed, for this particular project, to implement a framework within its software development process that implements ethical principles and guardrails. As Kemell et al. (2019) argue, the mere presence of ethical tools and considerations in the design and implementation of software can increase a sense of ethical responsibility within software engineers.</p><p><strong>In Conclusion</strong></p><p>These case studies demonstrate that data processing is often viewed as a neutral technical process rather than a curatorial process needing to be designed and implemented within an ethical framework. This view is dangerously reductive, as data processing is far from a neutral activity or a purely harmless technical exercise. Specifically, the failure to recognize the ethical implications of every technical decision within the data processing lifecycle allows subjective values and biases to be encoded into the process, often at the expense of preserving human rights. To prevent these ethical failures and biases, data practitioners must move beyond the fallacy that data processing is just a neutral tool by recognizing that every decision to include, exclude, or transform data is an ethical choice. This can be accomplished by encapsulating the design and implementation of each data processing stage within an ethical framework that upholds human rights by asking the “why” behind every technical decision and evaluating them against the four principles of human rights: Dignity, Autonomy, Necessity, and the Common Good. Ultimately, by shifting from a view that labels data processing as a purely neutral, janitorial, and technical process to a view that labels it as a curatorial process with ethical implications, data practitioners can ensure that the systems they build serve to empower individuals and society rather than becoming instruments of exploitation, bias, and harm.</p><p><strong>References:</strong></p><p>APA. (2014, June 4). APA: Psychologists should obtain informed consent from research participants [Press release]. American Psychological Association. <a href="https://www.apa.org/news/press/releases/2014/06/informed-consent">https://www.apa.org/news/press/releases/2014/06/informed-consent</a></p><p>Boyd, D. (2017, April 12). Toward accountability: Data, fairness, algorithms, consequences. Data &amp; Society: Points. Medium. <a href="https://medium.com/datasociety-points/toward-accountability-6096e38878f0">https://medium.com/datasociety-points/toward-accountability-6096e38878f0</a></p><p>Dastin, J. (2018, October 11). Amazon scraps secret AI recruiting tool that showed bias against women. Reuters. <a href="https://www.reuters.com/article/us-amazon-com-jobs-automation-insight/amazon-scraps-secret-ai-recruiting-tool-that-showed-bias-against-women-idUSKCN1MK08G/">https://www.reuters.com/article/us-amazon-com-jobs-automation-insight/amazon-scraps-secret-ai-recruiting-tool-that-showed-bias-against-women-idUSKCN1MK08G/</a></p><p>Franzke, A. S., Bechmann, A., Zimmer, M., Ess, C., &amp; Association of Internet Researchers. (2020). Internet research: Ethical guidelines 3.0 [PDF]. Association of Internet Researchers. <a href="https://aoir.org/reports/ethics3.pdf">https://aoir.org/reports/ethics3.pdf</a></p><p>O’Keefe, K., &amp; Brien, D. O. (2023). Data ethics: Practical strategies for implementing ethical information management and governance. Kogan Page.</p><p>UAGC Staff Member. (2024, June 18). What is data processing? University of Arizona Global Campus. <a href="https://www.uagc.edu/blog/what-data-processing">https://www.uagc.edu/blog/what-data-processing</a></p><p>Vakkuri, V., Kemell, K.-K., &amp; Abrahamsson, P. (2019). Ethically aligned design: An empirical evaluation of the RESOLVEDD-strategy in software and systems development context (arXiv:1905.06417) [PDF]. arXiv. <a href="http://arxiv.org/pdf/1905.06417">http://arxiv.org/pdf/1905.06417</a></p><p>Woollacott, E. (2016, May 13). 70,000 OkCupid profiles leaked, intimate details and all. Forbes. <a href="https://www.forbes.com/sites/emmawoollacott/2016/05/13/intimate-data-of-70000-okcupid-users-released/">https://www.forbes.com/sites/emmawoollacott/2016/05/13/intimate-data-of-70000-okcupid-users-released/</a></p><p><em>Originally published at </em><a href="https://www.alexomegapy.com/post/understanding-short-circuit-in-python-s-compound-conditional-expressions"><em>https://www.alexomegapy.com</em></a><em> on January 23, 2025.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=775ffa165f59" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/ethical-responsibility-in-data-processing-775ffa165f59">Ethical Responsibility in Data Processing</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Short-Circuit Evaluation in Programming]]></title>
            <link>https://medium.com/codex/short-circuit-evaluation-in-programming-f922c5f0eec8?source=rss-ad07757dbf8a------2</link>
            <guid isPermaLink="false">https://medium.com/p/f922c5f0eec8</guid>
            <category><![CDATA[short-circuit-evaluation]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[short-circuiting]]></category>
            <category><![CDATA[python-programming]]></category>
            <dc:creator><![CDATA[Alexander S. Ricciardi]]></dc:creator>
            <pubDate>Sat, 20 Sep 2025 16:24:35 GMT</pubDate>
            <atom:updated>2026-01-26T07:13:03.766Z</atom:updated>
            <content:encoded><![CDATA[<p>This article explains the programming concept of short-circuit evaluation, starting with the conditional logic and compound expressions features. Then, it explains how the process improves code efficiency and helps prevent runtime errors, using both pseudocode and specific Python examples.</p><figure><img alt="Man explaining code at a board about short-circuit evaluation in Python; laptop on a table. Casual setting, technical focus." src="https://cdn-images-1.medium.com/max/1024/0*hqP15LrcQ46KTsIu.png" /></figure><p>In computer programming, writing efficient and robust code is essential for developing stable and performant applications. To help with this goal, modern programming languages like Python have incorporated features such as short-circuit evaluation. Short-circuit evaluation is the process of evaluating compound logical expressions from left to right and stopping as soon as the final outcome is determined. This means that not all parts of the expression are necessarily checked. This provides efficiency and can be used as a safeguard against runtime errors, such as division by zero or attempting to access attributes of a null object. To understand the short-circuit process in programming, it is important first to understand what compound conditional expressions are. This article explains the mechanics of the short-circuit evaluation process. It begins with the concepts of conditional logic and compound expressions, using illustrations, pseudocode, and Python examples.</p><h3>Comparison Operators</h3><p>In programming, a condition compares the state (the condition) of an object, a variable, or an expression, to some expected value or criteria. This state is compared using Boolean expressions, which are expressions that return true or false. For example, the Boolean expression x == 10, which means “is x equal (‘==’ equality comparison operator) to 10?”, will return true or false depending on the value stored by the variable x. See Table 1 for a list of the different comparison operators</p><p><strong>Table 1<br></strong><em>Comparison Operators</em></p><figure><img alt="Table of comparison operators with symbols, descriptions, and examples in a blue and white design. Includes “Equal to” (==) and more." src="https://cdn-images-1.medium.com/max/1024/0*4_oZIVNhOlR90y5y.jpg" /></figure><p><em>Note</em>: The table provides a list of the various comparison operators used in programming. It also provides a description and a usage example for each operator.</p><h3>Conditional Expression</h3><p>On the other hand, a conditional expression is an expression that uses conditional statements, such as the ones depicted in Figure 1, to execute (or not) a block of code based on a condition.</p><p><strong>Figure 1<br></strong><em>Conditional Statements in Programming</em></p><figure><img alt="Flowchart of conditional statements: “if”, “if-else”, “if-else-if”, and “switch”, illustrating code logic paths. Black text on a white background." src="https://cdn-images-1.medium.com/max/1024/1*Xz7uMNILOng_s92XJd9Yag.jpeg" /></figure><p><em>Note</em>: The diagram depicts the types of conditional statements used in programming.</p><p>Loops in programming are used for iteration. Their iterations are controlled by loop conditions, for example:</p><p>The ‘for loop’ will iterate over a code block for a finite range, until the loop counter meets a condition.</p><p>Code example — Python:</p><pre>counter = 0<br>while counter &lt; 3:<br>    print(counter)<br>    counter = counter + 1</pre><p>Output:</p><pre>0<br>1<br>2</pre><h3>Compound Conditional Expressions</h3><p>Compound conditional expressions, as their name indicates, combine two or more Boolean expressions using logical operators such as AND (&amp;&amp;) or OR (||), for example — Pseudocode:</p><pre>if (x&gt;=0 &amp;&amp; x&lt;=10) then “x ∈ {0,1,…,10}”if ((x&gt;=10 &amp;&amp; x&lt;=20 &amp;&amp; z==x) ||               (y&gt;=40 &amp;&amp; y&lt;=50 &amp;&amp; z==y))<br>         then “z ∈ {10,11,…,20}∪ {40,41,…,50}”</pre><p>True tables are often used to represent the outcomes of logical operators for all possible truth values of their operands (conditions). Table 2 illustrates all possible outcomes of the logical operators AND and OR, comparing two conditions. Also see Figure 2 for an illustration of the operators’ process flows.</p><p><strong>Table 2<br></strong><em>Truth Table for AND and OR</em></p><figure><img alt="Truth table with headings: Condition A, Condition B, A AND B, A OR B. Shows False and True values. Blue and white cells." src="https://cdn-images-1.medium.com/max/1024/1*HfYdHXCJd_FfFQ5oWU2Cag.jpeg" /></figure><p><em>Note</em>: The table provides all possible outcomes of the logical operators AND and OR, comparing two conditions.</p><p>When using a combination of logical operators, the AND operator has precedence over the OR operator. Table 3 illustrates how this present can be applied to different compound conditional expressions.</p><p>The <strong>logical NOT operator </strong>or<strong> </strong>‘<strong>!</strong>’, also called negation, changes the value of the condition results to its opposite, for example — Pseudocode:</p><pre>if A is True, then !A is False.<br>if A is False, then !A is True.</pre><p>Note that ‘!’ operator has precedence over the AND and OR operators. In other words, ! &gt; &amp;&amp; &gt; ||.As with mathematical expressions, ‘()’ can change the precedence, for example: <br>In the following compound conditional expression: A || B &amp;&amp; C, B &amp;&amp; C has precedence over A || B. However, in this expression (A || B) &amp;&amp; C, (A || B)has presence over () &amp;&amp; C.</p><p><strong>Table 3<br></strong><em>Precedence of Logical Operators</em></p><figure><img alt="Two tables comparing boolean expressions and their precedence illustrations, with logical operators, in a clean white layout." src="https://cdn-images-1.medium.com/max/1024/1*xD5Zf6K2DBx7vft-spOFFg.jpeg" /></figure><p><em>Note:</em> The table provides examples that illustrate how logical operator precedence is implemented within compound conditional expressions</p><h3>Short-Circuiting</h3><p>In programming, short-circuit evaluation is a process of evaluating a compound conditional expression based on the precedence of logical operators and stopping as soon as the final outcome is determined. In other words, not all conditions in the expression are necessarily checked at runtime. For example — Pseudocode:</p><pre>x is an integerif (x != 0 &amp;&amp; x%3 == 0)<br>   then “x is an odd number”<br>else “x is an even number”</pre><p>In this example, at runtime the compound conditional expression (x != 0 &amp;&amp; x%3 == 0) is short-circuited at the condition (x != 0) if (x != 0) returns False as the (x != 0 &amp;&amp; x%3 == 0)will also return False, see Figure 2. In other words, the condition (x%3 == 0) will not be checked, as the final outcome is determined by (x != 0) returning False; then the code will output “x is an even number”. See Figure 2 for an illustration of the logical operators AND and OR process flows.</p><p><strong>Figure 2<br></strong><em>AND and OR Logical Operato</em></p><figure><img alt="Flowcharts compare logical operators AND/OR with and without short-circuit evaluation. Arrows indicate decision paths. Labeled boxes." src="https://cdn-images-1.medium.com/max/1024/0*CW1xNpPj0NwR05oS.jpeg" /></figure><p>Note: The diagram illustrates the logical operators AND and OR process flows.</p><p>The short-circuit process obeys the principle of logical operators’ precedence illustrated in Table 3.For example, in the compound conditional expression A || B &amp;&amp; !C or A || (B &amp;&amp; (!C) will Short-Circuit as follows:</p><pre>- Step-0: B is True, A is True, C is True<br>- Step-1: C is True -&gt; !C is False<br>- Step-2: !C is False - Short-Circuit -&gt; skip B, B &amp;&amp; !C is False<br>- Step-3: B &amp;&amp; !C is False -&gt; A is True<br>- Step-4: A || B &amp;&amp; !C is True.</pre><p>To summarize:</p><pre>B is True, A is True, C is True<br>C is True -&gt; !B is False - Short-Circuit -&gt; skip B, B &amp;&amp; !C is False -&gt; A is True -&gt; A || B &amp;&amp; !C is True</pre><p>Python handles the short-circuit process following the principle described previously, as all programming languages do. In addition to having logical operators, Python has the built-in functions any() and all(). They act as compounded OR and compounded AND operations, respectively. As well as using the statements True and False to represent the Boolean values TRUE and FALSE, the integer 0, the statement NONE, and empty strings represent the Boolean value FALSE. <br>Examples of any() and all() usage — Python:</p><pre># OR -&gt; any() - Returns True if ANY element is truthy<br>print(any([0, 1, 2]))  # Output: True (stops after finding 1)<br>print(any([False, &#39;&#39;, None]))  # Output: False (all elements are falsy)<br>print(any([]))  # Output: False (empty iterable)<br>print(any([False, False, True]))  # Output: True<br>print(any([0, 0.0, &quot;&quot;, [], {}]))  # Output: False (all falsy values)<br>print(any(&quot;hello&quot;))  # Output: True (string characters are truthy)<br>print(any(&quot;&quot;))  # Output: False (empty string)<br>print(any([0, &quot;&quot;, &quot;text&quot;]))  # Output: True (stops at &quot;text&quot;)<br>print(any(range(0)))  # Output: False (empty range)<br>print(any(range(1, 5)))  # Output: True (contains 1, 2, 3, 4) <br><br># AND -&gt; all() - Returns True if ALL elements are truthy<br>print(all([1, 2, 3]))  # Output: True (all elements are truthy)<br>print(all([1, 0, 3]))  # Output: False (stops after finding 0)<br>print(all([]))  # Output: True (empty iterable)<br>print(all([True, True, True]))  # Output: True<br>print(all([1, 2, 3, 4]))  # Output: True (all positive numbers)<br>print(all([1, 2, 0, 4]))  # Output: False (stops at 0)<br>print(all(&quot;hello&quot;))  # Output: True (all characters are truthy)<br>print(all([[], {}, &quot;&quot;]))  # Output: False (all are falsy)<br>print(all([[1], {&quot;a&quot;: 1}, &quot;text&quot;]))  # Output: True (all are truthy)<br>print(all(range(1, 5)))  # Output: True (1, 2, 3, 4 all truthy)<br>print(all(range(0, 5)))  # Output: False (starts with 0)</pre><p>Note that the all() function uses short-circuit evaluation and will stop iterating a list as soon as a value returns false.</p><p>In conclusion, the short-circuit evaluation process is built upon the concepts of conditional logic and compound expressions, which are essential to master to fully understand the mechanics of the process. As illustrated with pseudocode and Python examples, the short-circuit evaluation process performs a strict left-to-right evaluation of logical expressions,<strong> </strong>obeys the principle of the precedence of logical operators, and stops as soon as the final outcome is determined. This mechanism provides advantages. First, it saves processing time and resources by avoiding unnecessary computations. More importantly, it adds robustness to the code, as programmers can use short-circuiting as a safeguard to prevent runtime errors, such as dividing by zero or attempting to access attributes from a null value.</p><p><em>Originally published at </em><a href="https://www.alexomegapy.com/post/understanding-short-circuit-in-python-s-compound-conditional-expressions"><em>https://www.alexomegapy.com</em></a><em> on September 17, 2024.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f922c5f0eec8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codex/short-circuit-evaluation-in-programming-f922c5f0eec8">Short-Circuit Evaluation in Programming</a> was originally published in <a href="https://medium.com/codex">CodeX</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MySQL Stored Procedures and Functions: An Overview, Comparison, and Use Cases]]></title>
            <link>https://levelup.gitconnected.com/mysql-stored-procedures-and-functions-an-overview-comparison-and-use-cases-dc6939e02e70?source=rss-ad07757dbf8a------2</link>
            <guid isPermaLink="false">https://medium.com/p/dc6939e02e70</guid>
            <category><![CDATA[data-management]]></category>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[data-manipulation]]></category>
            <category><![CDATA[mysql]]></category>
            <category><![CDATA[rdbms]]></category>
            <dc:creator><![CDATA[Alexander S. Ricciardi]]></dc:creator>
            <pubDate>Mon, 26 May 2025 14:45:08 GMT</pubDate>
            <atom:updated>2025-05-26T14:45:08.623Z</atom:updated>
            <content:encoded><![CDATA[<p>This article provides an overview of MySQL stored procedures and functions, explaining their syntax, creation, and invocation with examples. It also compares their characteristics, differences, and common use cases.</p><figure><img alt="Gears labeled “PROCEDURE” and “FUNCTION” with dolphins on a MySQL background. Orange and teal tones with circuit patterns." src="https://cdn-images-1.medium.com/max/1024/0*IkS9ke8WYEU0wB-t.jpg" /></figure><p>MySQL supports stored routines (procedures and functions) (MySQL, n.d.). Stored routines are a set of SQL statements that are compiled and stored on the server database, allowing them to be accessed by users. This article provides an overview of MySQL stored procedures and functions, and compares and evaluates their characteristics, differences, and use cases.</p><p><strong>Stored Procedures</strong></p><p>Stored procedures can be defined as a set of SQL statements that can be invoked with the CALL keyword (Musgrave, 2024). Applications that have access to the database can CALL procedures stored on the database server. In other words, a stored procedure is a database object containing procedural SQL code that can be invoked at any time by an application or user to fetch and/or manipulate data. (Murach, 2019).</p><p>Syntax and creation of stored procedures:</p><pre>CREATE PROCEDURE procedure_name (<br>     [parameter_name_1 data_type]<br>    [, parameter_name_2 data_type]...<br>)<br>-- sql_block -- This represents the body of the procedure</pre><p>Example of creating/calling/dropping a procedure: The example provided is from “Chapter 15: How to Create Stored Procedures and Functions. Murach’s MySQL (3rd ed.)” By Murrah (2019). In this example, the procedure updates the credit_total column of the invoices table.</p><pre>-- Change the standard delimiter from semicolon (;) to double slash (//)<br>-- Semicolons are used within the procedure body<br>-- and we need a way to tell MySQL where the entire CREATE PROCEDURE statement ends<br>-- therefore, we need to define a delimiter for the procedure itself<br>DELIMITER //<br><br>-- Create a new stored procedure named &#39;update_invoices_credit_total&#39;<br>-- This procedure takes two input parameters.<br>CREATE PROCEDURE update_invoices_credit_total (<br>    invoice_id_param INT,<br>    credit_total_param DECIMAL(9,2)<br>)<br>-- Start of the procedure&#39;s body<br>BEGIN<br>    -- Declare a local variable to track SQL errors.<br>    -- It&#39;s a TINYINT (often used for boolean flags) and defaults to FALSE (0).<br>    DECLARE sql_error TINYINT DEFAULT FALSE;<br>      SET sql_error = TRUE;<br><br>    -- Start a new transaction. This allows us to group SQL statements together<br>    START TRANSACTION;<br><br>    -- MySQL/SQL statements<br>    UPDATE invoices<br>    SET credit_total = credit_total_param<br>    WHERE invoice_id = invoice_id_param;<br><br>    -- Check if an SQL error occurred during the UPDATE statement<br>    IF sql_error = FALSE THEN<br>        COMMIT;<br>    ELSE<br>        ROLLBACK;<br>    END IF;<br>-- End of the procedure&#39;s body<br>END //<br>-- Reset the delimiter back to the standard semicolon (;)<br>DELIMITER ;</pre><p>Invoking Procedure:</p><pre>CALL update_invoices_credit_total(56, 504);</pre><p>Dropping the procedure:</p><pre>DROP PROCEDURE IF EXISTS update_invoices_credit_total;</pre><p><strong>Stored Functions</strong></p><p>Stored functions can be defined as a block of SQL code that can perform computations or transformations and return a single scalar value (200ok Solutions 2024). MySQL provides its own set of stored functions referred to as built-in functions, such as <em>CONCAT()</em>, <em>NOW()</em>, or <em>SUM()</em>. For a list of all the MySQL built-in functions, see: <a href="https://www.w3schools.com/SQL/sql_ref_mysql.asp">MySQL Functions</a> by W3 School (n.d.). Users can also create their own stored functions, which are referred to as User-defined functions (UDFs).</p><p>Syntax and creation of stored functions:</p><pre>CREATE FUNCTION function_name ( <br> 	[parameter_name_1 data_type]<br>[, parameter_name_2 data_type]...<br> ) <br>RETURNS data_type -- Specifies the data type of the value the function will return <br>-- Indicates if the function always produces the same result for the same input parameters <br>[NOT] DETERMINISTIC <br>-- Specifies the nature of SQL usage within the function  <br>{CONTAINS SQL | NO SQL | READS SQL DATA | MODIFIES SQL DATA} <br>-- sql_block -- This represents the body of the function</pre><p>Example of creating/calling/dropping a UDF function:<br>The example provided is from “Chapter 15: How to Create Stored Procedures and Functions. Murach’s MySQL (3rd ed.)” By Murrah (2019). In this example, the function returns the vendor ID that matches a vendor’s name.</p><pre>-- Change the standard delimiter from semicolon (;) to double slash (//)<br>-- This is necessary because semicolons are used within the function body<br>-- and we need a way to tell MySQL where the entire CREATE FUNCTION statement ends<br>DELIMITER //<br><br>-- Create a new stored function named &#39;get_vendor_id&#39;.<br>CREATE FUNCTION get_vendor_id (<br>    vendor_name_param VARCHAR(50)<br>)<br>-- return an INT (integer) value.<br>RETURNS INT<br>-- DETERMINISTIC: Indicates that this function will always return the same result<br>-- for the same input &#39;vendor_name_param&#39;, if data in the &#39;vendors&#39; table doesn&#39;t change.<br>DETERMINISTIC<br>-- Indicates that the function contains SQL statements that read data<br>READS SQL DATA<br>-- start of the function body<br>BEGIN<br>    DECLARE vendor_id_var INT;<br><br>    SELECT vendor_id<br>    INTO vendor_id_var<br>    FROM vendors<br>    WHERE vendor_name = vendor_name_param;<br><br>    -- Return the value stored in &#39;vendor_id_var&#39;<br>    RETURN(vendor_id_var);<br>-- end of the function&#39;s body<br>END //<br>-- Reset the delimiter back to the standard semicolon (;)<br>DELIMITER ;</pre><p>Invoking Function:</p><p>This was done in the same way MySQL functions are called within MySQL statements, often as part of an expression, for example, in a <em>WHERE</em> clause like.</p><pre>SELECT invoice_number, invoice_total<br>FROM invoices<br>WHERE vendor_id = get_vendor_id(&#39;IBM&#39;); -- Invoke/call/uses the function</pre><p>Dropping the Function:</p><pre>DROP FUNCTION IF EXISTS get_vendor_id;</pre><p><strong>Stored Procedures vs. Functions</strong></p><p>The two stored routines are similar, but they differ in key aspects such as how they are called, what they can return, and how they interact with data. The table below provides a side-by-side comparison of their main differences.</p><p><strong>Table 1<br></strong><em>Stored Procedures and Functions Differences</em></p><figure><img alt="Stored Procedures and Functions Differences Table" src="https://cdn-images-1.medium.com/max/1024/0*xk7UoNw4JKrNrsWC.jpeg" /></figure><p><em>Note: </em>The table provides a side-by-side comparison of the main differences between stored procedures and functions in MySQL.</p><p>Another aspect to consider is when to use one instead of the other; the choice depends heavily on the specific task’s purpose. The table below provides a side-by-side comparison of the common scenarios or use cases for each routine.</p><p><strong>Table 2<br></strong><em>When to Choose a Stored Procedure vs. a Stored UDF Function</em></p><figure><img alt="When to Choose a Stored Procedure vs. a Stored UDF Function Table" src="https://cdn-images-1.medium.com/max/1024/0*Wpvued9LB1q2tXaX.jpeg" /></figure><p><em>Note:</em> The table provides a side-by-side comparison of common scenarios or use cases for stored procedure vs stored UDF function.</p><p>Below is an example of creating and using a simple procedure that gets all products belonging to a specific category, from the <em>copy_my_guitar_shop</em> schema (database).</p><p>In this example, using a stored procedure rather than a stored function is better because the task involves more than just returning a single value; it returns to an application, for example, an entire result set (a table of data) consisting of multiple rows and columns. On the other hand, stored functions cannot return data tables, they can only return a single scalar value, making them unsuitable for this kind of task.</p><p><strong>Figure 1<br></strong><em>Example of a Simple Stored Procedure</em></p><figure><img alt="Example of a Simple Stored Procedure — MySQL Code" src="https://cdn-images-1.medium.com/max/1024/0*1HXw3QQ_kFrAepYI.jpeg" /></figure><p><em>Note:</em> The figure illustrates the MySQL code to create and use a simple stored Procedure that gets product information based on the given category.</p><p>Below is an example of creating and using a simple UDF function that calculates the final price of an order item after applying its discount, from the <em>copy_my_guitar_shop</em> schema (database).</p><p>In this example, using a stored function rather than a stored procedure is better suited as the task performs a computation (calculating the final price) that returns a single value that can be used by the <em>SELECT</em> query, see code below. On the other hand, a stored procedure would be overkill for this task, as its underlying design introduces unnecessary overhead for this particular computation when compared to a stored function.</p><p><strong>Figure 2<br></strong><em>Example of a Simple UDF Function</em></p><figure><img alt="Example of a Simple UDF Function — MySQL code" src="https://cdn-images-1.medium.com/max/1024/0*Rj_XYbwEJEN8lNva.jpeg" /></figure><p><em>Note:</em> The figure illustrates the MySQL code to create and use a simple stored UDF function that calculates the final price of an order item after applying its discount based on the given category.</p><p>Considering the routine differences and complexities as shown in Tables 1 and 2, and in Figures 1 and 2. New database administrators may find stored UDF functions easier to develop. Because they return a single value and have limited data modification capabilities, their development can be more straightforward/simpler, and they are safer to use than stored procedures. In other words, their limited scope and syntax can feel familiar to developers with programming experience, and their limited scope and data modification capacity make them safer to use.</p><p>Stored procedures, on the other hand, can quickly become extremely complex as they have a wider scope than stored functions. They can incorporate control flow, error handling, transaction management, and data modifications. Consequently, for a new database administrator, stored procedures may be more challenging and have a steeper learning curve compared to stored UDF functions. As a new database administrator is best to start with functions and then gradually progress from procedures performing basic operations to procedures with more complex logic.</p><p>To summarize, stored procedures can be defined as a set of SQL statements that can be invoked using the CALL keyword. They are database objects containing procedural SQL code that can be invoked at any time by an application or user to fetch and/or manipulate data. On the other hand, a stored function is a block of SQL code that can perform computations or transformations and return a single scalar value MySQL provides its own set of stored functions, also called built-in functions, such as <em>CONCAT()</em>, <em>NOW(),</em> or <em>SUM()</em>. Users can create their own stored functions, called User-defined functions (UDFs). Although both stored procedures and user-defined functions provide code modularity, improved performance, and encapsulate business logic, their use cases differ. Stored procedures are used for complex data manipulation, transaction control, or when operations need to return multiple values or result sets; on the other hand, stored functions are used for calculations and transformations that return a single scalar value. Therefore, selecting the right routine for a specific task is critical for the performance and functionality of relational databases.</p><p><strong>References:</strong></p><p>200ok Solutions (2024, September 20). MySQL stored procedures vs. functions: When and how to use them. 200ok Solutions. <a href="https://200oksolutions.com/blog/mysql-stored-procedures-vs-functions/">https://200oksolutions.com/blog/mysql-stored-procedures-vs-functions/</a></p><p>Murach, J. (2019). Chapter 15: How to create stored procedures and functions. <em>Murach’s MySQL (3rd ed.)</em>. Murach Books. ISBN: 9781943872367</p><p>Musgrave, Z. (2024, January 17). <em>MySQL stored procedures: How and why with examples</em>. DoltHub Blog. <a href="https://www.dolthub.com/blog/2024-01-17-writing-mysql-procedures/">https://www.dolthub.com/blog/2024-01-17-writing-mysql-procedures/</a></p><p>MySQL (n.d.). 27.2 Using stored routines. <em>MySQL 8.4 reference manual.</em> <a href="https://dev.mysql.com/doc/refman/8.4/en/stored-routines.html">https://dev.mysql.com/doc/refman/8.4/en/stored-routines.html</a></p><p>W3 School (n.d.). MySQL functions. <em>SQL reference</em>. W3 School. <a href="https://www.w3schools.com/SQL/sql_ref_mysql.asp">https://www.w3schools.com/SQL/sql_ref_mysql.asp</a></p><p>Originally published at <a href="https://www.alexomegapy.com/">https://www.alexomegapy.com</a> on May 24, 2025.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dc6939e02e70" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/mysql-stored-procedures-and-functions-an-overview-comparison-and-use-cases-dc6939e02e70">MySQL Stored Procedures and Functions: An Overview, Comparison, and Use Cases</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Data Aggregation in MySQL: Understanding GROUP BY, HAVING, and Alternative Techniques]]></title>
            <link>https://levelup.gitconnected.com/data-aggregation-in-mysql-understanding-group-by-having-and-alternative-techniques-025e83346d24?source=rss-ad07757dbf8a------2</link>
            <guid isPermaLink="false">https://medium.com/p/025e83346d24</guid>
            <category><![CDATA[data-manipulation]]></category>
            <category><![CDATA[data-management]]></category>
            <category><![CDATA[mysql]]></category>
            <category><![CDATA[rdbms]]></category>
            <category><![CDATA[sql]]></category>
            <dc:creator><![CDATA[Alexander S. Ricciardi]]></dc:creator>
            <pubDate>Mon, 19 May 2025 02:44:51 GMT</pubDate>
            <atom:updated>2025-05-19T02:44:51.477Z</atom:updated>
            <content:encoded><![CDATA[<p>This article explains how to use the <strong><em>GROUP BY</em></strong> and <em>HAVING</em> clauses in MySQL for data aggregation and details their syntax with examples. It also explores alternative methods for achieving similar data aggregation and summary, such as using correlated subqueries and window functions.</p><figure><img alt="GROUP BY and HAVING Clauses illustration." src="https://cdn-images-1.medium.com/max/1024/0*_iI4mg8ZgxG0jYCO.jpeg" /></figure><p>Structured Query Language (SQL) is used within Relational Database Management Systems (RDBMS) to create and manipulate databases. MySQL is one of the various RDBMS frameworks that supports <em>the GROUP BY</em> and <em>HAVING</em> clauses for data aggregation. Data aggregation, in the context of RDBMS, is the process of taking multiple rows of data and summarizing them into a single result row, based on certain stated conditions or criteria. The <em>GROUP BY</em> and <em>HAVING</em> clauses are used in conjunction with aggregate functions like <em>COUNT()</em>, <em>SUM()</em>, <em>AVG()</em>, <em>MAX()</em>, and <em>MIN()</em>. This post describes the syntax and usage of the <em>GROUP BY</em> and HAVING clauses and explores alternative approaches to achieve similar data aggregation results using correlated subqueries and window functions.</p><p><strong>The GROUP BY Clause</strong></p><p>The GROUP BY clause is used to partition identical data (records) into groups (DataCamp, n.d.a). It is often used in conjunction with aggregate functions that perform calculations on the groups created by the clause. For example:</p><pre>SELECT product_category, SUM(sale_amount) AS total_sales<br>FROM sales<br>GROUP BY product_category</pre><p><strong>Output Example:</strong></p><figure><img alt="Table ouputs for the GROUP BY Clause example" src="https://cdn-images-1.medium.com/max/422/0*qIFKh_eLL0svEhOZ.jpeg" /></figure><p><strong>Explanation of the Code:</strong></p><p>1. <em>SELECT product_category, SUM(sale_amount) AS total_salesproduct_category</em></p><ul><li><em>product_category </em>column will be included in the results.</li><li><em>SUM(sale_amount) AS total_sales</em>: Aggregate function that calculates the sum of values in the <em>sale_amount </em>column and assigns results to the column with the alias <em>total_sales</em>.</li></ul><p>2. <em>FROM sales</em></p><ul><li>The table from which the data is retrieved.</li></ul><p>3. <em>GROUP BY product_category</em></p><ul><li>Partition the records (rows) with identical <em>product_category</em> values into groups. For example, if there are multiple sales records for “Electronics” (<em>product_category</em> ), all these records will form one group; all sales records for “Books” (<em>product_category</em> ) will form another group, and so on.</li><li>Then the aggregate function <em>SUM(sale_amount)</em> will compute the sum of the <em>sale_amount</em> and the results are stored in the column total_sales (<em>AS total_sales</em>).</li></ul><p><strong>The HAVING Clause</strong></p><p>The <em>HAVING</em> Clause is used to filter identical data partitioned by the<em> GROUP BY</em> clause (DataCamp, n.d.b). Note that the clause after For example:</p><pre>SELECT product_category, SUM(sale_amount) AS total_sales<br>FROM sales<br>GROUP BY product_category<br>HAVING SUM(sale_amount) &gt; 200</pre><p><strong>Output Example:</strong></p><figure><img alt="Table ouputs for the Having Clause example" src="https://cdn-images-1.medium.com/max/474/0*R1Py9JxUwbwrx_pZ.jpeg" /></figure><p><strong>Explanation of the Code:</strong></p><p>1. <em>SELECT product_category, SUM(sale_amount) AS total_salesproduct_category</em></p><ul><li><em>product_category </em>column will be included in the results.</li><li><em>SUM(sale_amount) AS total_sales</em>: Aggregate function that calculates the sum of values in the <em>sale_amount </em>column and assigns results to the column with the alias <em>total_sales</em>.</li></ul><p>2. <em>FROM sales</em></p><ul><li>The table from which the data is retrieved.</li></ul><p>3. <em>GROUP BY product_category</em></p><ul><li>Partition the records (rows) with identical <em>product_category</em> values into groups. For example, if there are multiple sales records for “Electronics” (<em>product_category</em> ), all these records will form one group; all sales records for “Books” (<em>product_category</em> ) will form another group, and so on.</li><li>Then the aggregate function <em>SUM(sale_amount)</em> will compute the sum of the <em>sale_amount</em> and the results are stored in the column total_sales (<em>AS total_sales</em>).</li></ul><p>4. <em>HAVING SUM(sale_amount) &gt; 200</em></p><ul><li>The <em>HAVING</em> clause filters the groups that were created by the <em>GROUP BY</em> clause. The clause is applied after the grouping has occurred and the sum of the sale_amount has been computed for each group.</li><li><em>SUM(sale_amount) &gt; 200</em> is the condition. Only the groups (product_categories) with a total sum (<em>sale_amount</em>) greater than 200 will be included in the final result.</li></ul><p><strong>Rewriting Example</strong></p><p>In this section, the provided example below using the<em> GROUP BY </em>and<em> HAVING</em> clauses is rewritten by utilizing first correlated subqueries and then MySQL window functions to showcase approaches to achieve the same data aggregation, but with different methods.</p><p>On a side note: the <em>ORDER BY</em> clause is a SQL command used to sort query results in either ascending or descending order based on one or more columns (Kartik, 2024). MySQL query statement utilizing <em>GROUP BY</em> clause in conjunction with aggregate functions often uses the <em>ORDER BY</em> to arrange the aggregated results in a more meaningful way, for example, by ranking the groups based on their computed aggregate results (e.g., showing product categories with the highest <em>SUM(sales)</em> first, or customers with the<em> COUNT(orders)</em> in descending order). Below is an example illustrating the combined use of the <em>GROUP BY</em>, <em>HAVING</em>, and <em>ORDER BY </em>clauses. Here we want to identify and rank customers who have multiple orders by the number of orders they have made.</p><pre>SELECT<br>    customer_id,<br>    COUNT(order_id) AS total_orders<br>FROM<br>    orders<br>GROUP BY<br>    customer_id<br>HAVING<br>    COUNT(order_id) &gt; 1<br>ORDER BY<br>    total_orders DESC<br>LIMIT 10;</pre><p><strong>Output Example:</strong></p><figure><img alt="Table ouputs for the ORDER BY Clause example" src="https://cdn-images-1.medium.com/max/424/0*CwaAY15ZP-GpiP32.jpeg" /></figure><p><strong>Explanation of the Code:</strong></p><ol><li><em>SELECT customer_id, COUNT(order_id) AS total_orders</em></li></ol><ul><li>Selects the <em>customer_id </em>column.</li><li><em>COUNT(order_id)</em> counts the number of orders for each customer.</li><li><em>AS total_orders</em> gives an alias to the calculated count column.</li></ul><p>2.<em> FROM orders</em></p><ul><li>The table from which the data is retrieved.</li></ul><p>3.<em> GROUP BY customer_id</em></p><ul><li>Partition the records (rows) with identical <em>customer_id</em> values into groups.</li><li>Then the aggregate function <em>COUNT(order_id)</em> will count the number of rows (records) in the <em>order_id column</em>, including the row with <em>NULL</em> values.</li></ul><p>4. <em>HAVING COUNT(order_id) &gt; 1</em></p><ul><li>The<em> HAVING</em> clause filters the groups that were created by the <em>GROUP BY</em> clause. The clause is applied after grouping has occurred and the count of the <em>total_orders</em> has been computed for each group.</li><li><em>COUNT(order_id) &gt; 1</em> is the condition. Only the groups (<em>total_orders</em>) with a total count superior then <em>1</em> will be included in the final result</li></ul><p>5. <em>ORDER BY total_orders DESC</em></p><ul><li>Sorts the total_orders results in descending order.</li></ul><p><em>6. LIMIT 10</em></p><ul><li>This limits the number of <em>total_orders</em> results output to a maximum of ten rows.</li></ul><p><strong>Rewriting The Query Without the GROUP BY and HAVING Clauses</strong></p><p><strong>By Using Correlated Subqueries</strong></p><p>It is possible to rewrite the last example without using the GROUP BY and HAVING clauses. For example, by using subqueries (subqueries, in MySQL, are queries embedded in other queries):</p><pre>SELECT<br>    customer_id,<br>    total_orders<br>FROM <br>    (   -- Subquery substitute for the GROUP BY clause<br>        SELECT<br>            cust_with_orders.customer_id,<br>            (   -- Sub-subquery-2 counts the total number of orders for each distinct customer id<br>                SELECT COUNT(order_id) <br>                FROM orders  <br>                WHERE customer_id = cust_with_orders.customer_id<br>            ) AS total_orders<br>        FROM<br>            (   -- Sub-subquery-1 queries all unique customer ids that exist in the orders table<br>                SELECT DISTINCT customer_id <br>                FROM orders<br>            ) AS cust_with_orders<br>    ) AS group_orders_by_customer_id  -- output table<br>WHERE -- substitute for the HAVE clause<br>    total_orders &gt; 1<br>ORDER BY<br>    total_orders DESC<br>LIMIT 10;</pre><p><strong>Output Example:</strong></p><figure><img alt="Table ouputs when Using Correlated Subqueries." src="https://cdn-images-1.medium.com/max/374/0*E37badK9hqrIcT2D.jpeg" /></figure><p><strong>Explanation of the Code: (</strong>For the sake of length, the code explanation is summarized)</p><ol><li>Sub-subquery-1, a list (<em>cust_with_orders</em>) of all distinct customer ids from the orders table is created. Note that the created list is a table consisting of one column (<em>customer_id</em>).</li><li>Then, sub-subquery-2, counts for each distinct customer id <em>(cust_with_orders.customer_id</em>), their number of orders from the orders table is counted, and outputs a list of total orders (<em>total_orders</em>). Note that the output is a column.</li><li>These results (<em>total_orders</em>) and their related customer ids (cust_with_orders.customer_id) are merged in a table with the alias <em>group_orders_by_customer_id</em>. Note that the combination of the previous steps simulates the <em>GROUP BY</em> clause functionality.</li><li>Then the values of the<em> group_orders_by_customer_id</em> are filtered using a <em>WHERE</em> clause with the <em>condition total_orders &gt; 1</em>. Note that the <em>WHERE</em> clause is the substitute for the <em>HAVE</em> clause.</li></ol><p>Although the query using the<em> GROUP BY</em> and <em>HAVING</em> clauses can be written by using correlated subqueries is more verbose, making it more difficult to read, and is more often than not less performant for aggregation operations than the <em>GROUP BY</em> clause. Another alternative is to use window functions, which are supported by MySQL.</p><p><strong>Using Window Functions to Rewrite the Query</strong></p><p>Window functions can perform aggregations, rankings, distributions, and more without collapsing the entire result set down to a single row (PlanetScale, 2025). It is possible to rewrite the query example without using the <em>GROUP BY</em> and <em>HAVING</em> clauses. For example:</p><pre>-- Window function<br>-- The function counts the number of orders per customer id in the order table<br>-- it outputs a table where each original row (containing a customer_id)<br>-- also contains the total number of orders for that specific customer_id<br>WITH customer_order_counts AS (  <br>    SELECT<br>        customer_id,  <br>        -- The &#39;orders&#39; table&#39;s data is partitioned by customer_id<br>        -- and each occurrence of the customer_id is associated with <br>        --  the total number of orders for that specific customer_id<br>        -- computed by the COUNT(order_id) clause<br>        COUNT(order_id) OVER (PARTITION BY customer_id) AS total_orders  <br>    FROM<br>        orders                  <br>)<br>-- -------------------------------------------------------------------<br>-- This is the Main query<br>SELECT DISTINCT<br>    customer_id, -- Only select distinct customer_id           <br>    total_orders                 <br>FROM<br>    customer_order_counts       <br>WHERE<br>    total_orders &gt; 1<br>ORDER BY<br>    total_orders DESC<br>LIMIT 10;</pre><p><strong>Output Example:</strong></p><figure><img alt="Table ouputs when Using window function." src="https://cdn-images-1.medium.com/max/424/0*E2ikbMeTSvzVsojb.jpeg" /></figure><p>Explanation of the Code: (For the sake of length, the code explanation is summarized)</p><ol><li>The query first calculates the total number of orders for every customer ids from the orders table and attaches the respective totals to each occurrent <em>customer_id</em> using the <em>customer_order_counts</em> window function. Not that this function creates duplicate rows</li><li>Then, it filters distinct customer ids (<em>from the customer_order_counts table</em>) with their total order counts, then filters out customers who have only made <em>1</em> order, sorts the remaining customers by their total order count (highest first), and finally, it only returns the top 10 row results.</li></ol><p>Similarly to using the correlated subqueries, the query can be rewritten using window functions. The query is more verbose than the one using the<em> GROUP BY</em> clause, making it less readable and concise. It is also less performant, as it computes the total order count for every individual row of the orders table, creating duplicates. Window functions should be used in scenarios like calculating per-row values like ranks, running totals, or lead/lag comparisons, and where keeping the individual row context is needed.</p><p>To summarize, the <em>GROUP BY</em> and <em>HAVING</em> clauses in MySQL are essential for data aggregation tasks. They are often used in conjunction with aggregate functions like <em>SUM()</em> and <em>COUNT()</em>, allowing for powerful data summarization. Although it is possible to summarize data through aggregation without using the <em>GROUP BY</em> and <em>HAVING</em> clauses by utilizing correlated queries or window functions. However, these alternative methods often result in more verbose queries and less performance, making <em>GROUP BY and HAVING</em> generally the more direct, concise, and often more efficient for standard aggregation tasks.</p><p><strong>References:</strong></p><p>DataCamp (n.d.a). <em>MySQL GROUP BY clause.</em> DataCamp. <a href="https://www.datacamp.com/doc/mysql/mysql-group-by">https://www.datacamp.com/doc/mysql/mysql-group-by</a></p><p>DataCamp (n.d.b). <em>MySQL HAVING clause.</em> DataCamp. <a href="https://www.datacamp.com/doc/mysql/mysql-having">https://www.datacamp.com/doc/mysql/mysql-having</a></p><p>PlanetScale (2025). 3.15 Window functions.<em> MySQL for developers</em>. PlanetScale. <a href="https://planetscale.com/learn/courses/mysql-for-developers/queries/window-functions?autoplay=1">https://planetscale.com/learn/courses/mysql-for-developers/queries/window-functions?autoplay=1</a></p><p>Originally published at <a href="https://www.alexomegapy.com/">https://www.alexomegapy.com</a> on May 14, 2025.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=025e83346d24" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/data-aggregation-in-mysql-understanding-group-by-having-and-alternative-techniques-025e83346d24">Data Aggregation in MySQL: Understanding GROUP BY, HAVING, and Alternative Techniques</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MySQL Best Practices for Safe DML and DDL Operations]]></title>
            <link>https://levelup.gitconnected.com/mysql-best-practices-for-safe-dml-and-ddl-operations-a647ed5e3425?source=rss-ad07757dbf8a------2</link>
            <guid isPermaLink="false">https://medium.com/p/a647ed5e3425</guid>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[data-manipulation]]></category>
            <category><![CDATA[rdbms]]></category>
            <category><![CDATA[mysql]]></category>
            <category><![CDATA[data-management]]></category>
            <dc:creator><![CDATA[Alexander S. Ricciardi]]></dc:creator>
            <pubDate>Fri, 09 May 2025 16:17:39 GMT</pubDate>
            <atom:updated>2025-05-09T23:45:00.006Z</atom:updated>
            <content:encoded><![CDATA[<p>This article outlines best practices for secure data and schema manipulation in MySQL using DML and DDL commands. These best practices include applying the Principle of Least Privilege for permissions, utilizing MySQL features like <em>SQL_SAFE_UPDATES</em> and transactions for DML, and implementing planning and backups for DDL changes.</p><figure><img alt="DML and DDL Best Practices" src="https://cdn-images-1.medium.com/max/1024/0*2VoeP3pvJAlz_Gey.jpeg" /></figure><p>Structured Query Language (SQL) is a standard language that is used within Relational Database Management Systems (RDBMS) to create and manipulate databases and the data they store. Within SQL, manipulating records (data values) is handled by Data Manipulation Language (DML), a subset of SQL. The manipulation of the databases themselves, also called schemas, is handled by the Data Definition Language (DDL). This article explores MySQL best practices for handling data manipulation safely when using DML and DDL operations.</p><p><strong>MySQL and the Principle of Least Privilege</strong></p><p>MySQL, an RDBMS based on SQL, provides a privilege system that manages applications’ and users’ access to database servers, including the ability to drop (delete) databases, modify any data (records), and change user permissions. This system is based on the Principle of Least Privilege (PoLP) where users and applications are granted only the exact permissions required to perform their intended tasks, and no more. These permissions are managed by a <em>root</em> account, which is usually used only for that purpose. The permissions are based on the users/applications’ scopes and needed functionality; additionally, these permissions are not static or a one-time based configuration, as the permissions should be revoked or modified as soon as they are no longer needed or the users/applications’ scopes change.</p><p><strong>Permission Setting and Description</strong></p><p>In MySQL, the permissions are set using the <em>GRANT</em> statement, which is used to assign (grant) privileges, operations allowed, and the scope (such as global, database, table, or column) to the target user. The following tables showcase various permissions for DML and DDL operations.</p><p><strong>Table 1</strong> <br><em>MySQL User Permissions for DML Operations</em></p><figure><img alt="MySQL User Permissions for DML Operations Table" src="https://cdn-images-1.medium.com/max/1024/0*a9CER4pSY9dQZdDw.jpeg" /></figure><p><em>Note: </em>The table lists the MySQL permission scopes for DML operations, describes them, and what actions the user is permitted to do.</p><p><strong>Table 2<br></strong><em>MySQL User Permissions for DDL Operations</em></p><figure><img alt="MySQL User Permissions for DDL Operations Table" src="https://cdn-images-1.medium.com/max/1018/0*CrbkmAqAop7JNs73.jpeg" /></figure><p><em>Note:</em> The table lists the MySQL permission scopes for DDL operations, describes them, and what actions the user is permitted to do.</p><p><strong>MySQL Best Practices for Manipulating Records</strong></p><p>As shown in Table 1, to insert new records, update or modify existing records, and delete records, DML provides three core commands: INSERT, UPDATE, and DELETE. These commands are powerful tools that need to be used with meticulous care, as they can result in accidental and permanent record/data loss or corruption. In addition to managing permissions, MySQL provides commands such as <em>SQL_SAFE_UPDATES</em> and START TRANSACTION that add a layer of protection against accidental data modifications or loss, as they allow for some control and to reverse changes, notably when using the command UPDATE and DELETE.</p><p>The <em>SQL_SAFE_UPDATES </em>is a server system variable that helps prevent accidental mass updates or deletions. When enabled (<em>SET SQL_SAFE_UPDATES = 1;</em>), MySQL will reject <em>UPDATE</em> and <em>DELETE</em> statements unless they include a <em>WHERE</em> clause (selecting specifies rows using). Note that if you are using MySQL Workbench, you can disable Safe Mode by going to:</p><p><em>Edit -&gt; Preferences, selecting the SQL Editor tab, and unchecking the “Safe Updates” box.</em></p><p>The <em>START TRANSACTION</em> command allows multiple SQL statements to be treated as a single, atomic unit of work, a module, providing the option to rollback any modifications (done by the SQL statements that are part of the transaction module) before permanently committing them. The MySQL documentation provides the following syntax for it:</p><pre>START TRANSACTION<br>    [transaction_characteristic [, transaction_characteristic] ...]transaction_characteristic: {<br>    WITH CONSISTENT SNAPSHOT<br>  | READ WRITE<br>  | READ ONLY<br>}BEGIN [WORK]<br>COMMIT [WORK] [AND [NO] CHAIN] [[NO] RELEASE]<br>ROLLBACK [WORK] [AND [NO] CHAIN] [[NO] RELEASE]<br>SET autocommit = {0 | 1}</pre><p>Note: from “15.3.1 START TRANSACTION, COMMIT, and ROLLBACK Statements” by MySQL Documentation (n.d.)</p><ul><li><em>START TRANSACTION</em> or <em>BEGIN</em> starts a new transaction.</li><li><em>COMMIT</em> commits the current transaction, making its changes permanent.</li><li><em>ROLLBACK</em> rolls back the current transaction, canceling its changes.</li><li><em>SET</em> autocommit disables or enables the default autocommit mode for the current session.</li></ul><p>Note that by default autocommit mode is turned ON (<em>SET autocommit = 1</em>), and, SQL statement you execute that modifies data (like <em>INSERT</em>, <em>UPDATE</em>, <em>DELETE</em>) is treated as its own independent transaction, meaning that when the statement finishes successfully, MySQL automatically performs a <em>COMMIT</em> -&gt; the changes are immediately saved and you cannot use <em>ROLLBACK</em> to undo.</p><p>So it is essential to explicitly set autocommit = 0. That is, if you are planning to use <em>ROLLBACK</em>.</p><p>Here is an example:</p><pre>-- Step 0: Verify the row that need to be change<br>SELECT product_id, product_name, discount_percent<br>FROM products<br>WHERE category_id = 1;<br><br>-- Step 1: Start the transaction<br>START TRANSACTION;<br><br>-- Step 2: Apply temporary changes<br>UPDATE products<br>SET discount_percent = 50.00<br>WHERE category_id = 1;<br><br>-- Step 3: Check the temporary change within the transaction<br>SELECT product_id, product_name, discount_percent<br>FROM products<br>WHERE category_id = 1;<br><br>-- Step 4: Decide not to proceed and undo the changes<br>ROLLBACK;<br><br>--  Step 5: Verify that the changes were undone<br>SELECT product_id, product_name, discount_percent<br>FROM products<br>WHERE category_id = 1;</pre><p><strong>MySQL Best Practices for Manipulating Schema Data</strong></p><p>Similar to DML, DDL provides three core commands to manipulate database schemas and tables: <em>CREATE</em>, <em>ALTER</em>, and <em>DROP</em>. These commands are even more powerful than DML commands, and they need to be used with meticulous care, as they can result in accidental and permanent vast data loss. Some best practices are in addition to managing permissions, follow best practices such as planning the change, creating backups, and decoupling (separating the schema change from the application deployment or release process).</p><p>To summarize, manipulating data improperly within RDBNS can result in accidental loss of data that can be significant to catastrophic. To mitigate these risks, MySQL provides a permissions framework and tools (e.g., <em>GRANT</em>), based on the Principle of Least Privilege (PoLP), that, when combined with best practice such as using transactions (including <em>START TRANSACTION</em> with <em>ROLLBACK</em>) and safe update modes (like <em>SQL_SAFE_UPDATES</em>) for DML operations, alongside planning, creating backups, and decoupling changes for DDL operations — greatly reduces the risk of accidental data loss or corruption.</p><p><strong>References:</strong></p><p>MySQL Documentation (n.d.). <em>15.3.1 START TRANSACTION, COMMIT, and ROLLBACK statement. </em>MySQL. <a href="https://dev.mysql.com/doc/refman/8.4/en/commit.html">https://dev.mysql.com/doc/refman/8.4/en/commit.html</a></p><p>Originally published at <a href="https://www.alexomegapy.com/">https://www.alexomegapy.com</a> on May 8, 2025.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a647ed5e3425" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/mysql-best-practices-for-safe-dml-and-ddl-operations-a647ed5e3425">MySQL Best Practices for Safe DML and DDL Operations</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MySQL Data Manipulation: Using INSERT, UPDATE, and DELETE Commands]]></title>
            <link>https://levelup.gitconnected.com/mysql-data-manipulation-using-insert-update-and-delete-commands-de8a9abb9a7e?source=rss-ad07757dbf8a------2</link>
            <guid isPermaLink="false">https://medium.com/p/de8a9abb9a7e</guid>
            <category><![CDATA[mysql]]></category>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[relational-databases]]></category>
            <category><![CDATA[data-manipulation]]></category>
            <category><![CDATA[data-management]]></category>
            <dc:creator><![CDATA[Alexander S. Ricciardi]]></dc:creator>
            <pubDate>Fri, 02 May 2025 00:44:19 GMT</pubDate>
            <atom:updated>2025-05-05T16:08:17.000Z</atom:updated>
            <content:encoded><![CDATA[<p>This article explains how to manipulate data using MySQL tables and the Data Manipulation Language (DML) commands: INSERT to add new rows, UPDATE to modify existing rows, and DELETE to remove rows, providing syntax and illustrated examples for each.</p><figure><img alt="Typing SQL code" src="https://cdn-images-1.medium.com/max/1024/0*OnrqVRYZtRG5i28h.png" /></figure><p>One of the core functions of a Relational Database Management System (RDBMS) is to allow users to manipulate data, such as inserting data into a table, modifying that data, and then deleting whatever data they no longer want to store. These RDBMS functions are handled by the Data Manipulation Language (DML), a subset of the Structured Query Language (SQL), and implementations of SQL like MySQL (Murach, 2019). Note that the Data Definition Language (DDL) is also a subset of SQL, which handles the definition or modification of the structure of database objects (schemas) like tables and indexes. In other words, DML is used to manipulate the data within schemas, and DDL is used to manipulate the schemas. This article focuses on the DML operations (<em>INSERT</em>, <em>UPDATE</em>, and <em>DELETE</em>) used to manipulate data within MySQL tables, providing examples.</p><p><strong>DML Operations</strong></p><p>The DML operations for modifying data in MySQL tables are handled by the statements (also referred to as commands): <em>INSERT,</em> <em>UPDATE</em>, and <em>DELETE</em>.</p><ul><li>The <em>INSERT</em> command adds new rows of data.\</li><li>The <em>UPDATE</em> command modifies data in existing rows.</li><li>The <em>DELETE</em> command removes rows entirely.</li></ul><p>Note that these commands manipulate rows, not columns. However, the command <em>SELECT</em> is used for querying and retrieving data from a table based on the table column (Watt &amp; Eng, 2014).</p><p>These commands <em>(INSERT</em>,<em> UPDATE</em>, <em>DELETE</em>) are often used in combination with the <em>SELECT</em> command and the <em>WHERE</em> clause to manipulate data by querying the table columns and selecting rows based on a specific condition(s). Note that the <em>WHERE </em>clause is responsible for filtering rows, also called records, based on specific conditions (Kathuria, 2021).</p><p><strong>Data Manipulation Examples</strong></p><p>To illustrate the examples on how to use the INSERT, UPDATE, and DELETE commands, the following products table is going to be used.</p><p><strong>Figure 1</strong><br><em>Products Table</em></p><figure><img alt="Products Table" src="https://cdn-images-1.medium.com/max/1024/0*VdtdmCwWLgChC7gX.jpeg" /></figure><p><em>Note:</em> The figure table illustrates a product table of various types of guitars.</p><p><strong>The <em>INSERT</em> Commands</strong></p><p>The <em>INSERT</em> command is used to insert rows/records (to store new data) in tables. Different syntax variations of the<em> INSERT </em>command exist in MySQL:</p><p>Using <em>VALUES</em></p><pre>NSERT INTO table_name<br>  (column1, column2, ...) -- the columns list <br>VALUES<br>  (value1a, value2a, ...), -- Values for the first row<br>  (value1b, value2b, ...), -- Values for the second row<br>  (value1c, value2c, ...), -- Values for the third row<br>  ...                       <br>  (value1n, value2n, ...); -- Values for the last row</pre><p>Using <em>SET</em></p><pre>INSERT INTO table_name<br>SET column1 = value1,<br>    column2 = value2,<br>   ... ;</pre><p>With the <em>SET</em> command, only one value can be inserted by column.</p><p>Using <em>SELECT</em></p><pre>INSERT INTO table_name (column1, column2,...)<br>SELECT source_column1, source_column2,...<br>FROM source_table<br>WHERE condition;</pre><p>Here, <em>SELECT</em> is used to insert columns from a source table column where a condition is met.</p><p><em>INSERT</em> Example using the products table:</p><p><strong>Figure 2<br></strong><em>INSERT Example</em></p><figure><img alt="INSERT Example" src="https://cdn-images-1.medium.com/max/1024/0*GCyipBai3_nN2lmy.jpeg" /></figure><p><em>Note:</em> The figure illustrates the SQL code for inserting a new guitar item in the products table.</p><p><strong>The <em>UPDATE</em> Commands</strong></p><p>The <em>UPDATE</em> command is used to update existing rows/records’ values (to modify existing data) in tables. Syntax:</p><pre>UPDATE table_name<br>SET column1 = new_value1,<br>    column2 = new_value2<br>WHERE ‘condition’;  -- The condition determines which rows are updated</pre><p>The <em>WHERE</em> clause is used to update specific records’ values based on a specific condition.</p><p><em>UPDATE</em> Example using the products table:</p><p><strong>Figure 3<br></strong><em>UPDATE Example</em></p><figure><img alt="UPDATE Example" src="https://cdn-images-1.medium.com/max/1024/0*PfINdFvbqiNHI8Zv.jpeg" /></figure><p><em>Note:</em> The figure illustrates the SQL code for adding +10 to the <em>discount_percent</em> for all items with a <em>category_id = 1.</em></p><p><strong>The <em>DELETE </em>Commands</strong></p><p>The <em>DELETE</em> command is used to delete rows/records (to delete existing data) in tables. Syntax:</p><pre>DELETE FROM table_name<br>WHERE ‘condition’; -- Specifies row(s) to delete</pre><p><em>Note:</em> The figure illustrates the SQL code for deleting all items with a <em>category_id = 1</em></p><p><em>DELETE</em> Example using the products table:</p><p><strong>Figure 4<br></strong><em>DELETE Example</em></p><figure><img alt="DELETE Example" src="https://cdn-images-1.medium.com/max/1024/0*wTNCs32wQ_GbIECZ.jpeg" /></figure><p><em>Note:</em> The figure illustrates the SQL code for deleting all items with a <em>category_id = 1.</em></p><p><strong>Hazards of Using<em> UPDATE</em> and <em>DELETE</em></strong></p><p>When using the <em>UPDATE</em> and <em>DELETE</em> commands, users need to be extremely careful, as these commands are very powerful and consequently come with significant risks. Accidentally misusing these commands can result in widespread data corruption or data loss. Some of these hazards include</p><ul><li>Missing or incorrect WHERE clause resulting in the<em> UPDATE</em> or <em>DELETE</em> commands being intentionally applied to all rows.</li><li>Data loss caused by incorrect logic or use of the <em>WHERE</em> clause condition and the <em>UPDATE</em> command, which may be potentially fixed, and the <em>DELETE</em> command, which often results in irreversible loss of data.</li></ul><p>To summarize, the<em> INSERT</em>, <em>UPDATE</em>, and <em>DELETE </em>commands are DML operations in MySQL for adding, modifying, and removing data within tables. The <em>INSERT</em> syntax can take various forms. The<em> UPDATE</em> and<em> DELETE</em> commands require particular attention due to their potential to modify or destroy existing data on a large scale.</p><p><strong>References:</strong></p><p>Kathuria, H. (2021, November 9). <em>How to write a WHERE clause in SQL</em>. Learn SQL. <a href="https://learnsql.com/blog/where-clause-in-sql/">https://learnsql.com/blog/where-clause-in-sql/</a></p><p>Murach, J. (2019). Chapter 1: An introduction to relational databases. <em>Murach’s MySQL (3rd ed.).</em> Murach Books. ISBN: 9781943872367</p><p>Watt, A., &amp; Eng, N. (2014). Chapter 16 SQL Data Manipulation Language. <em>Database Design — 2nd Edition</em>. Open textbooks, British Columbia University Open Campus. <a href="https://opentextbc.ca/dbdesign01/chapter/chapter-sql-dml/">https://opentextbc.ca/dbdesign01/chapter/chapter-sql-dml/</a></p><p>Originally published at <a href="https://www.alexomegapy.com/">https://www.alexomegapy.com</a> on April 30, 2025.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=de8a9abb9a7e" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/mysql-data-manipulation-using-insert-update-and-delete-commands-de8a9abb9a7e">MySQL Data Manipulation: Using INSERT, UPDATE, and DELETE Commands</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Choosing the Right MySQL Data Type]]></title>
            <link>https://levelup.gitconnected.com/choosing-the-right-mysql-data-type-7f202bfbd08c?source=rss-ad07757dbf8a------2</link>
            <guid isPermaLink="false">https://medium.com/p/7f202bfbd08c</guid>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[data-manipulation]]></category>
            <category><![CDATA[mysql]]></category>
            <category><![CDATA[data-type]]></category>
            <category><![CDATA[data-management]]></category>
            <dc:creator><![CDATA[Alexander S. Ricciardi]]></dc:creator>
            <pubDate>Wed, 30 Apr 2025 16:28:18 GMT</pubDate>
            <atom:updated>2025-04-30T16:28:18.821Z</atom:updated>
            <content:encoded><![CDATA[<p>This article explores MySQL data types, like integers, decimals, strings, and dates, used to define the information stored in table columns. Selecting the correct data type is crucial for ensuring data integrity, optimizing storage and performance, and performing calculations and comparisons.</p><figure><img alt="A figure pushing a square button named DECIMAL" src="https://cdn-images-1.medium.com/max/1024/0*8pJTwJetvB4EO-nJ.jpeg" /></figure><p>In relational databases, information is organized in tables referred to as schemas, the table rows act as records, and the columns act as attributes. To manage and manipulate these tables, developers use Structured Query Language (SQL), with MySQL being the most popular relational database management system (RDBMS). In the context of MySQL, selecting the appropriate data types for table columns, in other words, the data attributes, is essential for the RDBMS and the applications relying on it, as it directly impacts data integrity, storage efficiency, query performance, and the accuracy of data operations like calculations and comparisons. This article explores the data types available in MySQL, discusses their uses, and illustrates the importance of choosing the correct type.</p><p><strong>MySQL Data Types</strong></p><p>In the context of MySQL, data types define the nature of the information that can be accepted and stored within each specific column of a table. MySQL provides a wide range of data types, each designed to fit a specific kind of data characteristics, such as storage space and allowed values. See the table below for more information.</p><p><strong>Table 1<br></strong><em>MySQL Data Type</em></p><figure><img alt="MySQL Data Type Table" src="https://cdn-images-1.medium.com/max/1024/0*WzwAwxLL8Rt3MAvK.png" /></figure><p><em>Note:</em> The table lists the different MySQL. Data from “An introduction to MySQL data types” by Ellingwood (n.d.).</p><p><strong>The Importance of Data Type Selection</strong></p><p>Selecting the right data type in RDBMS is very important as it ensures that the data is stored efficiently and accurately (Sakshijain1, 2025). It impacts several aspects of RDBMS functionality, such as data integrity, storage, and query, as well as operations such as SUM and AVG calculation performed on numeric types, or DATEDIFF and DATE_ADD operations performed on temporal data types.</p><p>The following examples illustrate the impact of selecting appropriate data types versus inappropriate ones.</p><p>MySQL script below creates an events table to store concert dates:</p><pre>CREATE TABLE Events (<br>    event_id INT AUTO_INCREMENT PRIMARY KEY,<br>    event_name VARCHAR(100),<br>    event_start DATETIME,     -- Using DATETIME type<br>    ticket_price DECIMAL(8, 2) -- Using DECIMAL for currency<br>);<br><br>INSERT INTO Events (event_name, event_start, ticket_price) VALUES <br>(&#39;Spring Gala&#39;, &#39;2025-05-15 19:00:00&#39;, 75.50),<br>(&#39;Summer Concert&#39;, &#39;2025-07-20 20:30:00&#39;, 45.00),<br>(&#39;Autumn Workshop&#39;, &#39;2025-10-10 09:00:00&#39;, 120.00);</pre><p>Note that the column event_start was defined having a <em>DATETIME</em> data type, which allows performing temporal operations, for example, finding events happening in the next 90 days.</p><p>The following code snippet queries/retrieves the name and start date/time for all events listed in the <em>Events</em> table where the events are scheduled to start on or after today’s date and on or before the date 90 days from today. This logic works because the <em>event_start</em> column was defined as a <em>DATETIME </em>data type.</p><pre>SELECT event_name, event_start<br>FROM Events<br>WHERE event_start BETWEEN CURDATE() AND DATE_ADD(CURDATE(), INTERVAL 90 DAY)</pre><p>Another example of properly using data types is defining <em>DECIMAL(8, 2)</em> for <em>ticket_price</em>. This allows calculating the average ticket price without potential floating-point rounding errors:</p><pre>SELECT AVG(ticket_price) FROM Events;</pre><p>Now, if <em>event_start</em> were stored as<em> VARCHAR(20)</em> (e.g., ‘May 15, 2025 7PM’), using a function similar to <em>DATE_ADD</em> would be very difficult and prone to errors due to the text formats. Similarly, storing <em>ticket_price</em> as <em>VARCHAR </em>(e.g., ‘$75.50’, ‘$40.25’) and when using functions like <em>AVG()</em> or <em>SUM()</em>.</p><p>Although MySQL implicitly converts the <em>VARCHAR</em> to the <em>DOUBLE</em> type, the output of the conversion is not always what is expected, as <em>AVG(ticket_price)</em> (calculating ticket price average) will compute as <em>0.0</em>. This happens because MySQL will read the first character for the values, ‘<em>$</em>’ (which is not a number), and interpret the entire expression as not being numeric and translate <em>VARCHAR</em> data type values to the <em>DOUBLE </em>data type value of <em>0.0</em>.</p><p>For example, when using a column:</p><pre>score_text VARCHAR(20),</pre><p>Storing the folowing data:</p><pre>‘100&#39;<br>&#39;p85&#39;<br>&#39;Failed&#39;<br>&#39;90 points&#39;<br>&#39;70&#39;</pre><p>and performing the following operation on the column (Computing scores average):</p><pre>SELECT AVG(score_text)</pre><p>The MYSQL code line above will first convert the <em>VARCHAR </em>data to <em>DOUBLE</em> data, resulting in the following:</p><pre>100.0  -- ‘100’<br>0.0   -- ‘p85’<br>0.0    -- ‘Failed’<br>90.0   --’90 Points’<br>70.0   -- ‘70’</pre><p>Note that MySQL will generate warnings for the rows containing ‘Failed’ and ’90 points’.<br>And then it will performed the following calculation (100.0 + 0.0 + 0.0 + 90.0 + 70.0) / 5 = 345.0 / 5 = 52.0</p><p>This average output is probably not what was expected, or it is meaningful, because the non-numeric value ‘<em>Failed</em>’ was converted to 0, lowering the calculated average compared to the average of only the actual numerical scores.</p><p>Another example, in scientific measurements where precision is crucial, <em>DECIMAL</em> is preferred over approximate numeric data types like <em>FLOAT</em>.</p><p>Let’s say we add reagents with masses like 1.1250g, 0.0750g, and 2.5000g.</p><p>When using the FLOAT data type to compute <em>ExperimentComponents_Approx,</em> these values will be stored as close approximations, not the exact numbers, as <em>1.1250</em>, <em>0.0750</em>, and <em>2.5000</em> are defined as <em>FLOAT</em>; each value is rounded to the nearest representable binary fraction. Then, when calculating the total mass:</p><pre>SELECT SUM(mass_grams) FROM ExperimentComponents_Approx;</pre><p>The computation output will be slightly off due to the “accumulated representation errors” (binary rounding error), resulting in <em>3.7000000000000002</em> or<em> 3.6999999999999997</em> instead of exactly <em>3.7000</em>. For instance, in laboratories or manufacturing quality control settings, this discrepancy could result in incorrect solution concentrations, failed reactions, or items not meeting specifications</p><p>However, when using DECIMAL(10, 4) in ExperimentComponents_Exact guarantees that 1.1250, 0.0750, and 2.5000 are stored precisely, as the computations are performed in base-10 with no hidden representation error. Then, when calculating the sum:</p><pre>SELECT SUM(mass_grams) FROM ExperimentComponents_Exact;</pre><p>This computation outputs an exact result of <em>3.7000 </em>with an exact decimal precision of 4. This precision and accuracy in scientific calculations are essential for meeting a correct product quality standard or scientific specification.</p><p>Note that the numeric <em>DOUBLE</em> data type (8 bytes) outperforms the<em> FLOAT</em> data type (4 bytes) by offering roughly twice the bit-width, about 15 to 17 decimal digits versus 7 for the <em>FLOAT</em>. However, the <em>DOUBLE</em> type still has some inexact precision issues when compared to the DECIMAL type, which has exact precision.</p><p>Therefore:</p><ul><li>Use <em>DECIMAL</em> whenever exact decimal precision is needed (e.g., important financial calculations with a high volume of transactions or calculations, quality-control measurements, laboratory concentrations).</li><li>Use <em>DOUBLE</em> when precision matters, but it does not have to be exact.</li><li>Use <em>FLOAT</em> when a slight rounding error is acceptable.</li></ul><p>In summary, MySQL provides a set of data types that can be used to store various kinds of information, from numbers and text to dates and spatial data. Selecting the most appropriate data type is crucial, as it significantly impacts data integrity, storage usage, query speed, and the accuracy of operations.</p><p>References:</p><p>Ellingwood, J. (n.d.). <em>An introduction to MySQL data types.</em> <a href="https://www.prisma.io/dataguide/mysql/introduction-to-data-types">https://www.prisma.io/dataguide/mysql/introduction-to-data-types</a></p><p>Sakshijain1 (2025, January 30). <em>SQL data types.</em> GeeksForGeeks. <a href="https://www.geeksforgeeks.org/sql-data-types/">https://www.geeksforgeeks.org/sql-data-types/</a></p><p>Originally published at <a href="https://www.alexomegapy.com/">https://www.alexomegapy.com</a> on April 29, 2025.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7f202bfbd08c" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/choosing-the-right-mysql-data-type-7f202bfbd08c">Choosing the Right MySQL Data Type</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SQL Server to MySQL Migration: A Four-Step Guide]]></title>
            <link>https://levelup.gitconnected.com/sql-server-to-mysql-migration-a-four-step-guide-bd737074a20b?source=rss-ad07757dbf8a------2</link>
            <guid isPermaLink="false">https://medium.com/p/bd737074a20b</guid>
            <category><![CDATA[rdbms]]></category>
            <category><![CDATA[mysql]]></category>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[sql-server]]></category>
            <category><![CDATA[relational-databases]]></category>
            <dc:creator><![CDATA[Alexander S. Ricciardi]]></dc:creator>
            <pubDate>Wed, 23 Apr 2025 16:31:11 GMT</pubDate>
            <atom:updated>2025-04-29T21:25:54.500Z</atom:updated>
            <content:encoded><![CDATA[<p>This article explains the process of migrating a relational database from Microsoft SQL Server to MySQL, noting key differences between the platforms. It details the four essential steps for a successful migration: assessment and planning, schema conversion, data migration, and subsequent application modification.</p><figure><img alt="SOL Server vc MySQL diagrams" src="https://cdn-images-1.medium.com/max/1024/0*eL8I1TbnZe1tMYI2.jpeg" /></figure><p>Often, a business decision to migrate their Relational Database Management System (RDBMS) from Microsoft SQL Server (SQL Server) to MySQL is driven by Information Technology (IT) cost savings. SQL Server comes with licensing costs that can be substantial, particularly for businesses with a large number of machines (H, 2024). On the other hand, while owned by Oracle, MySQL is distributed under an open-source (GPL) license. It offers a free community edition and an optional commercial license. This post gives a brief overview of the difference between SQL Server and MySQL, and explores, as the database administrator for a database investments business, four steps required to implement a migration from SQL Server to MySQL.</p><p>Before migrating an RDBMS from SQL Server to MySQL is important to understand the difference between the two database systems. For example, MySQL runs comfortably on Windows, Linux, macOS, and other Unix systems, while SQL Server is primarily optimized for Microsoft/.NET technology stack and has recently expanded, since 2016, to run on Linux systems (H, 2024). The table below lists the main differences between the two RDBMSs.</p><p><strong>Table 1<br></strong><em>MySQL vs. SQL Server</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Wh8FwpeHLoC8RxKo.jpeg" /></figure><p><em>Note:</em> The table lists the main differences between SQL Server and MySQL. From “MySQL vs SQL Server: Which is the Right Database For You?” by Richman (2023).</p><p>For our investment business example, the RDBMS is migrating from SQL Server to MySQL, and with the fact that MySQL is compatible with Windows and Linux operating systems (OSs), the primary OSs that SQL Server also runs on, means that the operating system used by the business is not an issue. Nonetheless, as listed in Table 1, substantial differences exist between the two database systems; therefore, it is essential to assess the complexity of the existing RDBMS to plan the migration, translate the schema from SQL Server’s T-SQL dialect to MySQL’s SQL dialect, migrate the data from SQL Server schema to newly created (translated) MySQL schema, and once the schema migration is completed is essential that the application that use SQL Server is modified to function correctly with the new MySQL RDBMS.</p><p><strong>Assessment and Migration Planning</strong></p><p>Assessing the existing SQL Server RDBMS is the first step in migrating the system. This includes discovering and inventorying the system by identifying all SQL Server instances, these instances’ versions (e.g., 2012, 2016, 2019), and editions (e.g., Standard, Enterprise, Express) (GoReplay, 2024; Rifai, 2024). It is also essential to document the database sizes and configuration settings (collation, compatibility level) as well as the server hardware used (CPU, RAM). This will help to mitigate T-SQL conversion to MySQL’s SQL problems, identify unsupported SQL Server features in MySQL, and identify potential hardware performance issues when using MySQL.</p><p>Then, based on the information gathered during the assessment process, formulate a migration strategy, such as a trickle migration strategy and a Big Bang migration strategy. The trickle strategy migrates databases and applications in groups, starting with the less complex and low-risk databases and application groups to the more complex and high-risk ones (Kutay, n.d.). This wave approach to migration reduces risks and allows the migration team to troubleshoot and refine the migration process before migrating to the more complex or most critical databases and application groups. The Big Bang strategy. On the other hand, migrate databases and applications simultaneously over a single period. This approach is simpler to manage than the trickle strategy but comes with higher risks, as a failure could jeopardize the entire migration project and may necessitate the entire process to be rolled back.</p><p>Note that for our example of an investment business migrating its SQL server to MySQL, the schema and procedural code are complex because the system must process complicated and sophisticated financial transactions. Therefore, the trickle migration strategy is best suited for this example as its phased group approach reduces the risks associated with migrating complex schema and procedural code.</p><p>When using the trickle migration approach, the following steps are performed in stages (or waves), starting with low-risk databases and application groups and progressing to the more complex and high-risk ones.</p><p><strong>Schema Conversion</strong></p><p>This step involves translating SQL Server’s T-SQL dialect to MySQL’s SQL dialect. That is, translating the T-SQL table structures, views, indexes, and procedural code (Islam &amp; Thiagarajan, 2017). There are two primary approaches to this process, which are manual conversion and automated conversion. As its name indicates, the manual conversion approach requires developers to manually rewrite the SQL Server schema definitions and procedural code to MySQL syntax and definitions. On the other hand, the automated approach uses software tools that automatically convert SQL Server schema definitions and procedural code to MySQL syntax and definitions. Although much faster than the manual conversion approach, this approach is less accurate. Often, migration teams opt for a combined strategy that uses automated conversion software for the bulk of the schema and simpler procedural code, followed by a manual conversion of the more complex procedural code and a review and testing of the procedural code and schema output by the automated conversion.</p><p>For our investment business example, the hybrid approach is acceptable and advisable due to the substantial system complexity and size, as a manual-only conversion will be extremely time-consuming, and an automated one will not be suitable for complex procedural code involving complicated financial transactions.</p><p><strong>Data Migration</strong></p><p>The schema conversion is followed by migrating the data. The most important aspect of this phase is choosing the right data migration technique based on the database size and acceptable downtime. The two primary data transfer methods are offline and online. The offline data migration implies taking the source database (SQL Server database) offline or stopping application ‘updates’ and ‘adds’ referred to as writes, performing a bulk data transfer (using export/import, backup/restore adaptations), and once the data and application functionality is transferred bringing the new database online (MySQL Database). This approach is simpler than online but requires potentially significant downtime, which may not be suitable for applications that require high availability (GoReplay, 2024). Online data migration, on the other hand, uses Change Data Capture (CDC) and replication tools (like AWS DMS, Azure DMS if supported, Estuary Flow, Striim) to transfer an initial data bulk load while capturing ongoing changes from the SQL Server and applying these changes in near real-time the MySQL system minimizing downtime but introduces substantial complexity to the migration process.</p><p>For our example, due to the financial nature of the business, continuous operation and minimal disruption are essential. The online data migration utilizing Change Data Capture (CDC) tools is the best choice.</p><p><strong>Application Modification</strong></p><p>This step is often implemented in coordination with the data migration step. The applications that previously used the SQL Server must be modified to use correctly the new MySQL RDBMS. This requires implementing application changes that adapt the application logic to the new database environment and testing the application functionality against the MySQL database. These changes imply modifying connection strings, updating drivers, reconfiguring Object-Relational Mappers (ORMs), and rewriting application-embedded T-SQL (Rubin, 2016; Nisnevich, 2020). These changes are not optional clean-up tasks; they are crucial for a successful migration.</p><p>This step, for our investment business example, is complex and requires significant effort and time, especially when rewriting application-embedded T-SQL, reconfiguring ORMs, and testing the modifications to ensure that the application logic correctly accesses the data and handles the financial transactions.</p><p><strong>Summary</strong></p><p>Migrating a database from SQL Server to MySQL is a lengthy and complex process that requires a good understanding of the differences between the two RDBMS. The migration follows four crucial steps: assessment and strategic planning (including choosing between trickle and big bang approaches), schema translation (often employing a hybrid manual/automated technique), data migration (selecting offline or online methods based on downtime needs), and application modification. As illustrated with the investment business example, implementing a successful migration is often business-specific; in other words, it depends on the specific context.</p><p>For our investment business example, the OS(s) used by the business will not affect migration, as MySQL is compatible with them. The trickle migration strategy is best suited given the system’s complexity and size. The hybrid schema conversion approach is acceptable and advisable due to the system’s substantial complexity and size. The online data migration utilizing CDC tools is the best choice as it minimizes downtime and makes changes in near real-time. Time and resources should be allocated to modifying the application(s) used by the business to ensure that its business logic correctly accesses the data and handles the financial transactions as expected.</p><p><strong>References:</strong></p><p>GoReplay (2024, November 24). <em>Your comprehensive SQL Server migration checklist: tools, steps, and load testing insights. </em>GoReplay. <a href="https://goreplay.org/blog/demystifying-sql-server-migrations-tools-steps-and-best-practices/">https://goreplay.org/blog/demystifying-sql-server-migrations-tools-steps-and-best-practices/</a></p><p>H, J. (2024, July 8). <em>MySQL vs MS SQL server: Key similarities and differences.</em> Dreamfactory.<a href="https://blog.dreamfactory.com/ms-sql-server-vs-mysql">https://blog.dreamfactory.com/ms-sql-server-vs-mysql</a></p><p>Islam, A., R, &amp; Thiagarajan, A. (2017, October 5). <em>Migrating a SQL Server database to a MySQL-compatible database engine. </em>AWS. <a href="https://aws.amazon.com/blogs/database/migrating-a-sql-server-database-to-a-mysql-compatible-database-engine/">https://aws.amazon.com/blogs/database/migrating-a-sql-server-database-to-a-mysql-compatible-database-engine/</a></p><p>Kutay, J. (n.d.). <em>An introduction to database migration strategy and best practices.</em> Stiim. <a href="https://www.striim.com/blog/an-introduction-to-database-migration-strategy-and-best-practices/">https://www.striim.com/blog/an-introduction-to-database-migration-strategy-and-best-practices/</a></p><p>Nisnevich, A. (2020, April 18)<em> Migrating a ASP.NET application from SQL Server to MySQL.</em> AlexNisnevich Blog. <a href="https://alex.nisnevich.com/blog/2020/04/18/migrating_asp_net_mysql.html">https://alex.nisnevich.com/blog/2020/04/18/migrating_asp_net_mysql.html</a></p><p>Richman, J. (2023, April 5). <em>MySQL vs SQL Server: Which is the right Database for you? </em>Estuary. <a href="https://estuary.dev/blog/mysql-vs-sql-server/">https://estuary.dev/blog/mysql-vs-sql-server/</a></p><p>Rifai, B. (2024, April 3). <em>Automate SQL Server discovery and assessment to accelerate migration to AWS.</em> AWS. <a href="https://aws.amazon.com/blogs/database/automate-sql-server-discovery-and-assessment-to-accelerate-migration-to-aws/">https://aws.amazon.com/blogs/database/automate-sql-server-discovery-and-assessment-to-accelerate-migration-to-aws/</a></p><p>Rubin, A. (2016, June 23). <em>Migrate from MS SQL Server to MySQL.</em> Percona. <a href="https://www.percona.com/blog/migrate-from-ms-sql-server-to-mysql/">https://www.percona.com/blog/migrate-from-ms-sql-server-to-mysql/</a></p><p>Originally published at <a href="https://www.alexomegapy.com/">https://www.alexomegapy.com</a> on April 19, 2025.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bd737074a20b" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/sql-server-to-mysql-migration-a-four-step-guide-bd737074a20b">SQL Server to MySQL Migration: A Four-Step Guide</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Overview of Android App Testing Types]]></title>
            <link>https://levelup.gitconnected.com/overview-of-android-app-testing-types-604870a951bf?source=rss-ad07757dbf8a------2</link>
            <guid isPermaLink="false">https://medium.com/p/604870a951bf</guid>
            <category><![CDATA[android-app-deployment]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[android-app-testing]]></category>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[Alexander S. Ricciardi]]></dc:creator>
            <pubDate>Tue, 15 Apr 2025 16:00:39 GMT</pubDate>
            <atom:updated>2025-04-15T16:00:39.344Z</atom:updated>
            <content:encoded><![CDATA[<p>This article provides an overview of testing types necessary before releasing an Android app, detailing functional tests like unit, integration, UI, and end-to-end to ensure correct behavior. It also briefly touches upon non-functional testing, which assesses aspects like performance and usability, highlighting the importance of both for a high-quality release.</p><figure><img alt="Android phones and a tablet displaying test results." src="https://cdn-images-1.medium.com/max/1024/0*mg3lZLyfCHc_8M7u.jpeg" /></figure><p>Before releasing your Android app to the public, it is important to test your app’s consistency by verifying its correctness, functional behavior, and usability before you release it publicly (Android Developers n.d.). It is two major types of testing, functional and non-functional. This post focuses on functional testing types by providing an overview of them and briefly explores non-functional types.</p><p><strong>Functional Testing Types</strong></p><p><strong>Unit Testing</strong></p><p>Unit testing is one of the prevalent functional texting types, they should make up approximately 70% of your total number of tests. Unit testing involves testing individual units or components of your app in isolation (GAT Staff Writers, 2024). In other words, they verify small portions of the code app like individual methods or classes. They do not require an Android emulator or device as they are executed on the developer’s PC or workstation using Java Virtual Machine (JVM) (BrowserStack, 2025a). This makes the test ideal for testing business logic. The most comely used tool for unit testing is JUnit, other tools are Mockito and Truth.</p><p><strong>Integration Testing</strong></p><p>Integration testing is implemented on components or modules that have been unit tested (Singh, 2024). The goal of the test is to observe data flow and identify defects in it. In other words, it examines how unit tested components work together to identify defects (BrowserStack, 2025a). The most common tools used for integration testing are Robolectric, JUnit, Mockito, and Truth.</p><p><strong>UI Testing</strong></p><p>User Interface (UI) testing is used to verify both the appearance and functionality of the UI by evaluating the visual elements, layout, responsiveness, and overall user experience (BrowserStack, 2025a). This involves behavior testing which examines how the UI responds to user actions and screenshot testing which is used to validate the visual accuracy of the UI across different devices (screen sizes and resolutions). The most commonly used tools used for UI testing are Espresso and UIAutomator.</p><p><strong>End-to-End Testing</strong></p><p>End-to-end (E2E) is used to verify an application’s entire workflow from start to finish by simulating real-world scenarios. It verifies that all components of the application, including the user interface, business logic, data persistence, and external connection (API), function correctly together (BrowserStack, 2024b).</p><p>The most common tools used for E2E Espresso and UIAutomator. Other tools are Appium which has cross-platform capabilities; and BrowserStack and LambdaTest which are cloud based testing platforms that offer a wide range of real device testing.</p><p><strong>Non-Functional Testing Type</strong>s</p><p>Non-functional testing is used to verify aspects of a software application that are not directly related to its specific functions or features, but rather how well the system operates overall (GAT Staff Writers, 2024). In other words, it focuses on the quality of the software, such as performance, security, usability, and reliability. Non-functional testing is composed of a set of tests that includes performance testing that evaluates the speed, responsiveness, and stability of the app under different conditions; usability testing which is used to assess how easy is the app to use; compatibility testing which is used to verifies consistent functionality of the app across different devices and OS versions; accessibility testing which is used to access if the app is usable for users with disabilities; regression testing is used to test updates for bugs; and smoke testing is used to quickly check of the app’s functionalities after a build.</p><p><strong>Summary</strong></p><p>Before successfully releasing an Android app, rigorous testing is required. Testing such as functional testing (unit, integration, UI, end-to-end), which checks what the app does, ensuring correct functionality at all levels; non-functional testing (performance, security, usability, etc.), which focuses on how well the app performs. Combining both approaches ensures that the app is free of bugs, that it is user-friendly, and secure.</p><p><strong>References:</strong></p><p>Android developer (n.d.). <em>Fundamentals of testing Android apps.</em> Android. <a href="https://developer.android.com/training/testing/fundamentals">https://developer.android.com/training/testing/fundamentals</a></p><p>BowserStack (2025a, March 18).<em> What is Android unit testing?</em> BowserStack. <a href="https://www.browserstack.com/guide/android-unit-testing">https://www.browserstack.com/guide/android-unit-testing</a></p><p>BowserStack (2024b, June 28).<em> End To End testing: Tools, types, &amp; best practices.</em> BowserStack. <a href="https://www.browserstack.com/guide/end-to-end-testing">https://www.browserstack.com/guide/end-to-end-testing</a></p><p>GAT Staff Writers (2024, May). <em>What is Android testing — Types, tools and best practices. </em>Global App testing. <a href="https://www.globalapptesting.com/blog/what-is-android-testing">https://www.globalapptesting.com/blog/what-is-android-testing</a></p><p>Singh, R. (2024, June 13).<em> 12 mobile app testing types: A thorough exploration for QA professionals.</em> Headspine. <a href="https://www.headspin.io/blog/types-of-mobile-app-testing">https://www.headspin.io/blog/types-of-mobile-app-testing</a></p><p>Originally published at <a href="https://www.alexomegapy.com/">https://www.alexomegapy.com</a> on April 16, 2025.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=604870a951bf" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/overview-of-android-app-testing-types-604870a951bf">Overview of Android App Testing Types</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>