Life of Loco

Warm welcome to Loco Blog.
"Life of Loco" is nothing but a gradual process of me moving towards death.

  • Home
  • About

 



Hello hello hello....
Welcome back my useless blog again. Welcome back to our exciting journey exploring the platypus, one of the most mind-blowing creatures on the planet. If you missed the first part of this blog series, I highly recommend checking it out here to catch up on the basics—like how I stumbled upon this quirky animal while scrolling through Facebook, and why it’s such a wild mix of mammal, reptile, and bird traits. In Part 1, we covered the platypus’s classification, its egg-laying habits, that crazy milk-without-nipples thing. But trust me, there’s so much more to this little guy that’ll leave you amazed! In this second part, we’re diving deeper into its super cool hunting skills, food habits, and some other wild features that make the platypus a true standout in the animal kingdom. Let’s get started!

3. Venomous Spurs

One of the platypus’s most surprising and dramatic features is the venomous spurs found on the hind legs of males, a trait that makes it one of the few venomous mammals in the world, alongside the slow loris, certain shrews, and the Cuban solenodon. These spurs—sharp, hollow, keratinized structures about 15 mm long—are located just above the heel and are connected to crural glands, which produce a complex venom. The venom is delivered through a duct system when the platypus drives the spur into a target, typically during aggressive encounters. While not lethal to humans, the venom causes excruciating pain, swelling, and hyperalgesia (heightened sensitivity to pain), with symptoms that can persist for days or even weeks.

The venom is a cocktail of over 80 bioactive compounds, including defensins, natriuretic peptides, and nerve growth factors, many of which are unique to the platypus. Proteomic analysis reveals that some venom proteins share structural similarities with those found in snakes, suggesting convergent evolution—where unrelated species develop similar traits to solve similar problems. Unlike snake venom, which often targets blood or nervous systems to immobilize prey, platypus venom appears designed to incapacitate rivals or deter predators. In humans, the venom triggers intense localized pain and systemic effects like nausea, but no fatalities have been recorded. In smaller animals, such as dogs, the venom can be lethal, highlighting its potency.

The venom’s production is seasonal, peaking during the breeding season (late winter to early spring), when males become more territorial and aggressive. During this period, males use their spurs in intraspecific combat, sparring with other males to establish dominance or secure mating opportunities. Observations of male platypuses in the wild show them grappling with their hind legs, attempting to jab opponents with their spurs. The increased venom potency during breeding suggests a dual role: deterring rivals and signaling fitness to females. Females, in contrast, are born with rudimentary spur sheaths that regress by adulthood, indicating that venom is primarily a male-specific trait.

The evolutionary origins of platypus venom are as fascinating as its effects. Genomic studies reveal that venom genes in platypuses likely arose from duplications of genes involved in immune defense and pain modulation, a process also seen in venomous reptiles. This suggests that the platypus’s venom system evolved independently from a shared genetic toolkit, adapting to its semi-aquatic lifestyle and social behaviors. The crural glands themselves are modified sweat glands, further linking venom production to the platypus’s primitive mammalian traits.

Ecologically, the venomous spurs serve as a defense mechanism against predators like birds of prey, snakes, or introduced species such as foxes. However, their primary role appears to be social, mediating competition in a species where males are solitary and territorial. The rarity of venom among mammals underscores the platypus’s exceptional status, as most venomous vertebrates (e.g., snakes, spiders) use venom for predation rather than defense or competition. Research into platypus venom also has medical implications: some venom peptides show potential for developing new painkillers or anti-inflammatory drugs, given their ability to target pain pathways without causing tissue damage.

The venomous spurs add a layer of intrigue to the platypus’s already bizarre biology, reinforcing its reputation as a creature that defies conventional categorization. They also highlight the complexity of its social and ecological interactions, where even a small, unassuming mammal can wield a formidable weapon.

4. Electroreception and Hunting

The platypus’s bill is far more than a quirky physical trait—it’s a marvel of evolutionary engineering, functioning as a highly specialized sensory organ that sets the platypus apart from nearly all other mammals. Unlike the rigid beak of a bird, the platypus’s bill is soft, flexible, and covered in a smooth, moist skin layer that resembles rubber. This bill is packed with approximately 40,000 electroreceptors and 60,000 mechanoreceptors, organized in a series of stripe-like patterns across its surface. These receptors make the bill a dual-purpose sensory tool, capable of detecting both faint electric fields and mechanical disturbances in the water, enabling the platypus to hunt with extraordinary precision in murky, low-visibility environments.

Electroreception, the ability to detect electric fields, is a rare trait among vertebrates, shared primarily with echidnas, certain fish (like sharks, rays, and electric eels), and a few amphibians. In the platypus, electroreceptors pick up the minute electrical impulses generated by the muscle contractions of prey, such as crustaceans, worms, and small fish. These impulses, often as weak as a few microvolts, are produced during movements like swimming or heartbeat. Simultaneously, mechanoreceptors detect pressure changes and vibrations caused by water displacement, such as the ripples created by a fleeing shrimp. The integration of these sensory inputs allows the platypus to construct a detailed “map” of its underwater environment, pinpointing prey with remarkable accuracy.

When hunting, the platypus employs a unique and highly specialized strategy. It dives underwater for 30–60 seconds, closing its eyes, ears, and nostrils to streamline its body and prevent water ingress. In this sensory blackout, the bill becomes the sole means of navigation and prey detection. The platypus sweeps its bill side to side in a rhythmic motion, scanning the riverbed or water column for signals. This behavior, known as bill dipping, maximizes the bill’s exposure to potential stimuli. When a signal is detected, the platypus uses its dexterous, partially webbed front feet to scoop up prey or dig into the sediment, where invertebrates like yabbies (freshwater crayfish) or insect larvae may hide. The prey is then stored in cheek pouches, specialized folds of skin inside the mouth, allowing the platypus to collect multiple items during a dive.

Once the platypus surfaces, it floats on the water and uses a grinding motion to process its catch. Adult platypuses lack teeth, relying instead on horny pads in their jaws—hardened, keratinized structures that replace the temporary teeth present in juveniles. These pads are highly effective for crushing the exoskeletons of crustaceans and the soft bodies of worms. The absence of true teeth is another adaptation to its aquatic lifestyle, reducing drag and simplifying the feeding process.

The platypus’s electroreceptive system is a testament to its evolutionary adaptation to a semi-aquatic niche. Studies suggest that electroreception evolved in monotremes as a response to their murky, freshwater habitats, where vision is often unreliable. The bill’s sensory stripes are arranged to optimize detection in three-dimensional space, with the highest density of receptors at the bill’s edges, enhancing sensitivity to lateral movements. Neuroscientific research has shown that the platypus’s brain devotes a significant portion of its somatosensory cortex to processing bill inputs, creating a neural map that integrates electrical and mechanical signals. This neural specialization rivals the sensory acuity of echolocating bats or dolphins, underscoring the platypus’s status as a sensory specialist.

Ecologically, electroreception gives the platypus a competitive edge as a predator, allowing it to exploit food resources in environments inaccessible to other mammals. However, this reliance on a finely tuned sensory system makes the platypus vulnerable to environmental disturbances, such as water pollution or electromagnetic interference from human activities, which can disrupt its ability to hunt. The platypus’s hunting strategy, combining electroreception, mechanoreception, and precise motor control, highlights its role as a master of its aquatic domain and a living example of evolutionary innovation.

5. Food Habits

The platypus is a voracious carnivore with a metabolism so high that it must consume 20–30% of its body weight daily—equivalent to a 70-kg human eating 14–21 kg of food every day. This extraordinary energy demand stems from its active lifestyle, which involves prolonged foraging, frequent diving, and the maintenance of a warm-blooded body temperature (around 32°C) in cold freshwater environments. To meet these needs, the platypus spends 10–12 hours a day foraging, primarily at dawn, dusk, or night, when its prey is most active and light levels are low.

The platypus’s diet is exclusively carnivorous, focusing on aquatic invertebrates and occasional small vertebrates. Its primary food sources include yabbies (freshwater crayfish), insect larvae (such as those of caddisflies, mayflies, and dragonflies), shrimp, annelid worms, and mollusks like snails and mussels. It also consumes small fish, fish eggs, and tadpoles when available, particularly in nutrient-rich waters. The platypus’s preference for small, high-protein prey reflects its need for energy-dense foods to fuel its metabolism. Seasonal variations in prey availability influence its diet, with yabbies dominating in warmer months and insect larvae becoming more prominent in cooler seasons.

Foraging is a physically demanding process, centered around repeated dives that last 30–60 seconds, with brief surface intervals of 10–20 seconds to breathe. During a single foraging session, a platypus may complete hundreds of dives, covering large stretches of river or lakebed. Each dive targets the benthic zone (the riverbed or lake bottom), where most of its prey resides. The platypus uses its sensitive bill to probe sediments, riffle through gravel, or sweep through aquatic vegetation, detecting prey via electroreception and mechanoreception. Its partially webbed front feet are adept at digging or grasping, allowing it to extract buried invertebrates or capture free-swimming prey.

The platypus’s foraging efficiency is enhanced by its ability to store prey in cheek pouches, a feature that maximizes the yield of each dive. These pouches, formed by muscular folds in the mouth, can hold multiple small items, such as shrimp or larvae, until the platypus surfaces to eat. This strategy reduces the need for frequent surfacing and conserves energy during long foraging bouts. The platypus’s high metabolic rate also necessitates a rapid digestive system, with food passing through its gut in as little as 12–24 hours, ensuring a constant supply of nutrients.

Ecologically, the platypus is a top predator in its freshwater ecosystem, regulating populations of aquatic invertebrates and small vertebrates. Its foraging activity aerates riverbed sediments, contributing to nutrient cycling and habitat health. However, its reliance on abundant, high-quality prey makes it sensitive to environmental changes, such as pollution, sedimentation, or drought, which can reduce prey availability. For example, agricultural runoff can deplete insect larvae populations, while dam construction can alter river flows, disrupting yabby habitats. Conservation efforts in Australia often monitor platypus populations as indicators of ecosystem health, given their dependence on pristine waterways.

The platypus’s food habits also reveal its evolutionary adaptations. Its carnivorous diet and high energy demands are consistent with those of early mammals, which were likely small, insectivorous predators. The loss of adult teeth, replaced by horny pads, parallels similar adaptations in other aquatic vertebrates, like baleen whales, where specialized feeding structures enhance efficiency. By consuming a diverse array of prey, the platypus maintains a flexible diet that buffers it against seasonal or environmental fluctuations, reinforcing its role as a resilient yet specialized predator in its aquatic niche.

6. Eyes and Sensory Adaptations

The platypus’s small, beady eyes, positioned high on the sides of its head, are adapted for a semi-aquatic lifestyle, offering a wide field of vision above water to detect predators or monitor its surroundings. Each eye, about 5 mm in diameter, is protected by a nictitating membrane, a translucent third eyelid that provides additional shielding during dives. However, the platypus’s reliance on electroreception and mechanoreception underwater renders its eyes secondary during hunting, as it closes them tightly to streamline its body and prevent water entry. This sensory shift highlights the platypus’s unique balance of terrestrial and aquatic adaptations.

Unlike most mammals, which possess trichromatic or dichromatic vision for perceiving color, the platypus has a monochromatic vision system, lacking the cone cells required for color discrimination. Its retina is dominated by rod cells, optimized for low-light conditions, such as the dim environments of dawn, dusk, or murky rivers where the platypus is most active. This adaptation enhances its ability to detect movement and contrast above water, such as the silhouette of a predator against the sky. However, the absence of color vision suggests that visual cues play a limited role in its behavior, with the bill’s sensory systems taking precedence in most contexts.

Intriguingly, the platypus’s eyes exhibit ultraviolet (UV) light reflection, a trait discovered in recent studies and rare among mammals. When exposed to UV light, the cornea and surrounding tissues reflect a faint glow, which may enhance the platypus’s ability to detect subtle environmental cues in low-light conditions. For example, UV reflection could help it distinguish between water surfaces and vegetation or detect UV-absorbing compounds in prey or mates. Alternatively, it may serve a communicative function, as some animals use UV signals for mate attraction or territorial displays. The exact purpose of this trait remains speculative, but it aligns with similar adaptations in nocturnal or crepuscular species, such as certain rodents and marsupials.

The platypus’s sensory adaptations extend beyond its eyes. Its ears, small slits located behind the eyes, are covered by folds of skin during dives, relying on mechanoreceptors in the bill to detect waterborne vibrations. The platypus also possesses a keen sense of touch through its fur and skin, with trigeminal nerve endings in the bill amplifying its sensitivity to tactile stimuli. These adaptations create a sensory profile that prioritizes non-visual cues, reflecting the platypus’s evolutionary divergence from other mammals, which often rely heavily on vision or olfaction.

Evolutionary studies suggest that the platypus’s sensory systems are a legacy of its aquatic ancestors, which likely inhabited similar murky environments millions of years ago. The loss of color vision and the emphasis on electroreception parallel adaptations in other aquatic vertebrates, such as paddlefish or lungfish, which also prioritize non-visual senses. The platypus’s brain reflects this sensory specialization, with an enlarged somatosensory cortex dedicated to processing bill inputs, while visual processing areas are relatively reduced. This neural architecture underscores the platypus’s reliance on its bill as a “sixth sense,” capable of navigating complex underwater environments.

Ecologically, the platypus’s sensory adaptations make it a highly effective predator but also vulnerable to disruptions. Artificial light pollution, for example, can interfere with its low-light vision, while electromagnetic noise from underwater cables or machinery may disrupt electroreception. Conservation strategies often focus on preserving dark, quiet river systems to support the platypus’s sensory ecology. By studying its eyes and sensory adaptations, researchers gain insights into the evolutionary trade-offs that have shaped this extraordinary creature, revealing a mammal that thrives by redefining the role of vision in its world

-------------------------------------------------

I know you will get bored if I continue from here.. So...

That’s a wrap for Part 2, but but but.... we’re not done yet! The platypus still has more surprises up its sleeve, and I can’t wait to share them with you. In the final part of this blog series, Part 3, we’ll explore the rest of its special traits—like its glow-in-the-dark fur, weird DNA, and how it plays a big role in keeping its ecosystem healthy. Plus, we’ll talk about why we need to protect this amazing creature. Stay tuned for the last chapter of our platypus adventure—you won’t want to miss it!

To be Continued....


 


So, a few days ago, I was chilling on my couch, scrolling through Facebook like it’s my part-time job. You know how it goes—funny dog clips, random food pics, and ads for stuff you’d never buy. Then, bam! A short video (one of those reels) pops up, and it’s about the platypus, this super weird animal that looks like someone glued a duck’s bill onto a furry otter with a beaver’s tail. I was totally hooked. The video was quick, maybe a minute, but it showed this quirky creature swimming, hunting, and just being its odd, awesome self. I couldn’t look away!

I had to know more. So, I started googling, jumping from one website to another, watching videos and reading cool facts. Turns out, the platypus isn’t just strange—it’s like nature’s ultimate weirdo, a mammal that lays eggs, has venom, and hunts like it’s got superpowers. I got so excited that I decided to write this blog to share all the wild stuff I learned. Get ready, because we’re diving into why the platypus is the most epic, head-scratching animal out there!

Before starting, I want to thank GROK.com for helping in organizing my whole findings. This is really a cool LLM I think. Anyway.....

The platypus (Ornithorhynchus anatinus) is a creature that defies expectations, blending features from mammals, reptiles, and birds in a way that feels almost otherworldly. Found only in the freshwater systems of eastern Australia and Tasmania, this small, semi-aquatic mammal has puzzled scientists and captivated imaginations since its discovery by European naturalists in the late 18th century. In this blog, we’ll explore the platypus’s classification, its unique mammalian status, and the extraordinary exceptions that make it one of nature’s most remarkable creations.

Classification and Introduction

The platypus belongs to the order Monotremata, a rare and ancient group of mammals that includes only five living species: the platypus and four species of echidnas. Within Monotremata, the platypus is the sole member of the family Ornithorhynchidae and the genus Ornithorhynchus. Its scientific name, Ornithorhynchus anatinus, translates roughly to “bird-like snout” and “duck-like,” a nod to its distinctive bill. Monotremes are considered the most primitive group of mammals, diverging from other mammalian lineages around 166–220 million years ago, making the platypus a living relic of evolutionary history.

Physically, the platypus is small, averaging 40–50 cm in length and weighing 1–2.4 kg, with males slightly larger than females. Its streamlined body, covered in dense, waterproof fur, is adapted for an aquatic lifestyle. The platypus has a flat, rubbery bill, webbed feet, and a broad, beaver-like tail, giving it an appearance that seems cobbled together from unrelated animals. But it’s the platypus’s biology, not just its appearance, that sets it apart.

A Mammal, But Different

At first glance, the platypus fits the mammalian mold: it has fur, produces milk to nurse its young, and is warm-blooded. However, it deviates from the typical mammalian blueprint in profound ways. Most mammals fall into two groups: placentals (like humans, with long gestation periods and live births) and marsupials (like kangaroos, with short gestation and external pouches for offspring). The platypus, as a monotreme, belongs to neither. Its reproductive and physiological traits are so unusual that early scientists questioned whether it was even a mammal.

Unlike placental and marsupial mammals, the platypus lays eggs—a trait shared with reptiles and birds. This egg-laying habit, combined with other reptilian-like features, makes the platypus a bridge between evolutionary lineages. Its genome, sequenced in 2008, further reveals this mosaic: it contains genes typical of mammals, but also shares genetic similarities with reptiles and birds, reflecting its ancient origins. The platypus’s blend of characteristics challenges our understanding of what it means to be a mammal and highlights the complexity of evolutionary divergence.

Exceptional Traits of the Platypus

The platypus’s quirks extend far beyond its classification. Below, we dive into the specific features that make this creature a biological marvel.

1. Egg-Laying Mammal

Perhaps the most famous exception in the platypus’s biology is its ability to lay eggs, a trait that places it in an exclusive club among mammals, shared only with the four species of echidnas in the order Monotremata. This characteristic is so remarkable that when platypus specimens were first sent to Europe in the late 18th century, scientists suspected they were hoaxes, stitched together from parts of different animals. Unlike the hard-shelled eggs of birds, platypus eggs are small (about 11–15 mm in diameter), soft, and leathery, resembling those of reptiles like turtles or snakes. Females typically lay one to three eggs, though clutches of two are most common, which they deposit in a specially constructed nesting burrow along riverbanks.

The reproductive process begins after mating, which occurs in late winter to early spring (August to October in Australia). Following a gestation period of about 15–21 days, the female seals herself inside the burrow, which can be up to 20 meters long and feature multiple chambers for insulation and protection. She curls her body around the eggs to incubate them for approximately 10–14 days, maintaining a stable temperature through her body heat and the burrow’s humid environment. This incubation strategy is strikingly similar to that of reptiles, highlighting the platypus’s ancient evolutionary roots.

When the eggs hatch, the young, affectionately called puggles, emerge in a highly underdeveloped state, a condition known as altricial. Measuring just 1–2 cm long, puggles are blind, hairless, and entirely dependent on their mother. Their limbs are rudimentary, and they lack the strength to move far from the nest. For the next 3–4 months, the mother nurses them in the burrow, leaving only briefly to forage. The puggles’ development is slow, with fur appearing around 6 weeks and eyes opening around 10 weeks. By the time they leave the burrow at 4–5 months, they are miniature versions of adults, capable of swimming and foraging independently.

This egg-laying reproductive strategy is a window into the platypus’s evolutionary history. Monotremes diverged from other mammals around 166–220 million years ago, before the rise of placental and marsupial mammals. Genetic studies reveal that platypus egg-laying is governed by a suite of genes shared with reptiles and birds, including those for yolk production (a nutrient source absent in most mammals). Unlike placental mammals, which nourish embryos via a placenta, or marsupials, which rely on pouches, the platypus’s reliance on eggs and prolonged maternal care in a burrow reflects a transitional stage in mammalian evolution. This reproductive divergence not only sets the platypus apart but also underscores its role as a living link to the Mesozoic era, when early mammals coexisted with dinosaurs.

2. Milk Without Nipples

Like all mammals, the platypus produces milk to nourish its young, but its method of lactation is one of the most primitive among living mammals. Unlike placental and marsupial mammals, which deliver milk through well-defined nipples or teats, the platypus lacks these structures entirely. Instead, milk is secreted through specialized mammary gland patches—areas of skin on the female’s abdomen that resemble sweat glands more than traditional mammary systems. These patches, located on either side of the belly, ooze milk that collects in grooves or folds of skin, where puggles lap it up or suckle directly from the surface.

This unusual lactation system is a hallmark of monotremes and reflects their evolutionary position as a basal mammalian group. The mammary patches consist of numerous tiny ducts that release milk, which is rich in proteins, fats, and sugars tailored to the rapid growth needs of puggles. Studies of platypus milk composition reveal unique antimicrobial proteins, such as monotreme lactation protein (MLP), which protect vulnerable puggles from infections in the humid, microbe-rich environment of the nesting burrow. These proteins are distinct from those found in other mammals, suggesting that monotreme lactation evolved independently, possibly from a common ancestor with reptilian-like skin glands.

The process of nursing is labor-intensive for the mother. Puggles, born without teeth or the ability to chew solid food, rely exclusively on milk for the first 3–4 months of life. The mother positions herself to allow puggles to access the mammary patches, often lying on her side or back in the burrow. Because milk is not delivered through a nipple, puggles use a suckling motion to draw milk from the skin, a behavior that requires significant energy and coordination. This prolonged nursing period places high energetic demands on the mother, who must forage extensively to maintain her milk supply while ensuring her own survival.

The absence of nipples in platypuses has evolutionary implications. In most mammals, nipples are thought to have evolved to improve the efficiency of milk delivery, particularly for offspring born in more developed states (precocial). Monotremes, however, retain a more ancestral form of lactation, likely inherited from early mammals or their synapsid ancestors. Fossil evidence of early mammals, such as Morganucodon from 200 million years ago, suggests that primitive lactation involved glandular secretions rather than structured teats. The platypus’s mammary patches thus offer a glimpse into the origins of one of mammals’ defining traits.

Interestingly, the platypus’s lactation system also has ecological significance. The burrow environment, where nursing occurs, is carefully maintained to prevent flooding or temperature fluctuations, ensuring puggles have constant access to milk. This reliance on a stable microhabitat underscores the platypus’s sensitivity to environmental changes, such as river degradation, which can disrupt breeding success. By studying platypus lactation, researchers gain insights not only into mammalian evolution but also into the delicate balance of their aquatic ecosystems.


To be Continued....

Before the Beginning

First off, congratulations! You’re about to learn something that’s not only useful but also surprisingly simple. The good news? You don’t need to be a tech genius, a coding prodigy, or even someone who knows what “hypertext” means (seriously, who came up with that word?). HTML—short for HyperText Markup Language—is basically the skeleton of every webpage. It’s the stuff that holds everything together, like the frame of a house or the bones in your body (except less creepy).

Think of it this way: if a website were a pizza, HTML would be the dough. It’s not the flashy toppings or the gooey cheese, but without it, you’d just have a pile of ingredients on a plate. And nobody wants that. HTML is here to make sure your text, images, and buttons don’t end up looking like a digital dumpster fire.

Now, I know what you’re thinking: “But I’m not a coder! I can barely set up my Wi-Fi!” Relax. HTML is so beginner-friendly that even your grandma could probably learn it (and she still calls the computer “the typing box”). It’s all about using simple tags—little pieces of code that tell your browser what to do. Tags are like sticky notes for your website: “Put this here,” “Make that bold,” “Add a picture of a cat right there.” Easy, right?

So, grab a cup of coffee (or tea, or whatever fuels your brain), and let’s break this down into bite-sized, non-scary chunks. By the end of this, you’ll be slinging HTML tags like a pro, and who knows? You might even impress your friends. Or at least your dog. Let’s get started! 

The Basic Structure of an HTML Document

Every HTML document follows a specific structure. Think of it as the skeleton of a webpage—without it, your content would be a chaotic mess. Here’s what every HTML file must include:

1. The Doctype Declaration

The very first line in an HTML document is:

<!DOCTYPE html>

This tells the browser, “Hey, this is an HTML5 document.” It ensures that your code is interpreted correctly.

2. The <html> Tag

The <html> tag wraps all the content on your page.

<html>

  <!-- All content goes here -->

</html>

3. The <head> Section

The <head> tag contains metadata—information about your page that isn’t directly displayed to users but is essential.

<head> <title>My First Webpage</title> <meta charset="UTF-8"> <link rel="stylesheet" href="styles.css"> </head>
  • <title> sets the title of the webpage (shown on the browser tab).

  • <meta charset="UTF-8"> ensures proper character encoding.

  • <link> connects external stylesheets (CSS) to style your page.

4. The <body> Section

The <body> tag contains everything visible on your webpage—text, images, videos, and more.

<body> <h1>Welcome to My Website</h1> <p>This is my first webpage.</p> </body>

Text Formatting in HTML

HTML provides tags to structure and format text.

Headings: Organizing Content

HTML has six heading tags, from <h1> (largest) to <h6> (smallest).

<h1>Main Heading</h1> <h2>Subheading</h2> <h3>Smaller Subheading</h3>

Use headings to create a logical structure. <h1> should be the main title, followed by <h2>, <h3>, and so on.

Paragraphs: Structuring Text

Use <p> to create paragraphs.

<p>This is a paragraph. It wraps text neatly.</p>

Bold and Italics: Emphasizing Text

  • <strong> makes text bold and conveys importance.

  • <em> italicizes text and adds emphasis.

<p>This is <strong>bold</strong> text.</p> <p>This is <em>italic</em> text.</p>

Line Breaks and Horizontal Rules

  • <br> adds a line break.

  • <hr> inserts a horizontal line, useful for separating sections.

<p>First line.<br>Second line.</p> <hr> <p>Next section.</p>

Adding Links and Images

Hyperlinks: Connecting Pages

Use the <a> tag to create links.

<a href="https://www.example.com">Visit Example</a>

The href attribute defines the URL.

Images: Displaying Pictures

Use the <img> tag to add images.

<img src="image.jpg" alt="Description of the image">
  • src specifies the image file.

  • alt provides alternative text in case the image doesn’t load.


Lists: Organizing Information

Unordered Lists (Bullets)

Use <ul> for unordered lists and <li> for list items.

<ul> <li>Item 1</li> <li>Item 2</li> </ul>

Ordered Lists (Numbered)

Use <ol> for ordered lists.

<ol>
  <li>First item</li>
  <li>Second item</li>
</ol>

Tables: Displaying Data

Tables organize content in rows and columns.

<table> <tr> <th>Name</th> <th>Age</th> </tr> <tr> <td>John</td> <td>25</td> </tr> </table>
  • <tr> creates a row.

  • <th> defines a header cell.

  • <td> represents a data cell.


Forms: Getting User Input

Forms allow users to enter information.

<form>
  <label for="name">Name:</label>
  <input type="text" id="name" name="name">
  <button type="submit">Submit</button>
</form>
  • <label> improves accessibility.

  • <input> is used for text fields, checkboxes, and more.

  • <button> creates a clickable button.


Semantic HTML: Structuring Your Page Correctly

Semantic HTML improves readability and SEO by using meaningful tags.

<header> <h1>Welcome</h1> </header> <section> <p>This is a section of content.</p> </section> <footer> <p>&copy; 2025 My Website</p> </footer>
  • <header> represents the top section of a page.

  • <section> divides content into logical sections.

  • <footer> contains information like copyrights or links


Task

Here's a task for you to practice your HTML skills. This task will help you apply the basic structure, text formatting, links, images, lists, and semantic HTML concepts in a hands-on way. Let’s keep it simple and fun! The solution will be provided later.

Task: Create a Personal Homepage

Your goal is to create a basic HTML webpage that serves as your personal homepage. Imagine it’s a digital “About Me” card you could share with friends or family. You’ll use the key elements from the blog to build it.

Instructions:

  1. Set Up the Basic Structure: Use the correct doctype declaration and include the <html>, <head>, and <body> tags.
  2. Add a Title: In the <head> section, set the page title to “My Personal Homepage” (this will show in the browser tab).
  3. Create a Header: Use a semantic <header> tag with an <h1> heading that says “Welcome to [Your Name]’s Homepage” (replace [Your Name] with your actual name).
  4. Write an Introduction: Add a paragraph <p> in a <section> tag introducing yourself. For example, “Hi, I’m [Your Name]! I’m learning HTML and this is my first webpage.”
  5. Format Some Text: Make one word in your paragraph bold (using <strong>) and another word italicized (using <em>).
  6. Add a Fun Link: Include a hyperlink <a> to a website you like (e.g., a favorite blog, game, or social media page). For example, “Check out my favorite site!”
  7. List Your Interests: Create an unordered list <ul> with 3-5 things you enjoy (e.g., hobbies, favorite foods, or movies).
  8. Finish with a Footer: Use a semantic <footer> tag with a small note, like “© 2025 [Your Name] - Built with HTML.”

Tips:

  • Use a plain text editor (like Notepad, VS Code, or any code editor you have).
  • Save your file with a .html extension (e.g., homepage.html).
  • Open it in a web browser to see your creation!
  • Don’t worry about styling (CSS)—focus only on the HTML structure and content.

Example to Inspire You (Don’t Copy This Exactly!):

<!DOCTYPE html>
<html>
<head>
  <title>My Personal Homepage</title>
</head>
<body>
  <header>
    <h1>Welcome to Alex’s Homepage</h1>
  </header>
  <section>
    <p>Hi, I’m Alex! I’m <strong>learning</strong> HTML and this is my <em>first</em> webpage.</p>
    <p>Visit my favorite site: <a href="https://www.example.com">Example.com</a></p>
    <ul>
      <li>Playing video games</li>
      <li>Eating pizza</li>
      <li>Watching sci-fi movies</li>
    </ul>
  </section>
  <footer>
    <p>© 2025 Alex - Built with HTML</p>
  </footer>
</body>
</html>



Final Thoughts

HTML is the backbone of the web, and now you understand its basics. You don’t need to memorize everything—just grasp how elements work and practice using them. The more you build, the more confident you’ll become.

So, open a text editor and start coding. Who knows? Your first simple page could be the start of something big.



Alert: Most of this content is written by an LLM. :'

হঠাত করে আজকে সকালে ইমন এসে শিক্ষক দিবসের শুভেচ্ছা জানালো। আমি অবাক হয়ে জিজ্ঞাস করলাম যে কয়েকদিন আগেই না শিক্ষক দিবস গেলো? ও বললো, "কই না তো! আজকেই তো ৫ তারিখ। আর আজকেই শিক্ষক দিবস।" আমি একটু অবাকই হইসি। কিভাবে জানি জীবন থেকে আরো ১ টা বছর চলে গেলো। গত বছরই তো ইমন কত সুন্দর করে একটা ম্যাসেজ দিয়েছিলো আমাকে। এবছরও উইশ করতে ভুললো না।



আচ্ছা শিক্ষক দিবস কি বিশেষ কিছু? হয়তো বিশেষ। কিন্ত সত্যি বলতে আমি আমার এই জীবনে মোটামুটি সব শিক্ষক থেকে লাইফ রিলেটেড প্রচুর জিনিস শিখেছি যা বলে শেষ করার মতো না। ক্লাস পার্ফম্যান্স বাজে থাকলেও আমি কখনোই নন-একাডেমিক কিছু শিখতে মিস করি না। এটা শুধু আমার শিক্ষকদের ক্ষেত্রে না। আবার আশেপাশে থাকা সকলের থেকেই আমি চেষ্টা করি কিছু না কিছু শিখতে। কবি যে বলেছে, "বিশ্বজোড়া পাঠশালা মো্র, সবার আমি ছাত্র" - এটা আমি অনেক আগে থেকেই মেনে চলে আসছি। তাই আমার পরিচিত এবং আমার চেনা সবাইকে জানাই শিক্ষক দিবসের শুভেচ্ছা। তোরা, তোমরা এবং আপনারা ছিলেন বলেই আজ আমি অল্প কিছু হলেও জানি।
You all are really very important, precious to me. You all have too many impacts to my life. You all have contributed a lot to my life.


ব্যাক্তিজীবনে আমার স্কুল, কলেজের সব শিক্ষককে স্মরণ করার সাথে সাথে আমি আমার বিশ্ববিদ্যালয় জীবনের ২টা শিক্ষককে স্পেসিফিকালি স্মরণ করতে চাই। একটা সময় ছিলো যখন আমি আমার ধরেই নিয়েছি যে এই পৃথিবীতে আমি আসলে ভুলে জন্ম নিয়ে নিসি। আমি আসলে মানুষ হওয়ার যোগ্য না। আমার মধ্যে না আছে কোনো ট্যালেন্ট, না আছে কোনো ইচ্ছা, না আছে কোনো স্বপ্ন। আমি শুধু প্রতিদিন অক্সিজেন নষ্ট করতেসি বলে মনে হচ্ছিলো। ঠিক তখনই আমার জীবনে ২টা শিক্ষক আসে যারা আমার লাইফ পুরো চেঞ্জ করে দেয়। নিজেকে Reinvent কিভাবে করা যায় তা আমাকে এই ২জন শিক্ষকই শিখিয়েছে। এই ২টা মানুষের এত বিশ্বাস আমার উপর যা আমাকে মাঝে মাঝে নিজেকে প্রশ্ন করতে বাধ্য করে যে আমি কি আসলেই যোগ্য কিনা বা আমি কি পারবো কিনা এই বিশ্বাস ধরে রাখতে। ফাহিম স্যার, যে আমাকে বুঝিয়েছে যে আমার আসলে কিভাবে লাইফ ঘুরানো উচিত, আর রুদ্র স্যার যে আমাকে বুঝিয়েছে যে সবকিছু আমার ভুল না, এবং চেষ্টা কিভাবে করা উচিত। আমি আসলে প্রতিদিনই মনে হয় একবার করে ভাবি যে এই দুইজন স্যার আমার লাইফে না আসলে আমার কি হতো। আমার মোটিভেশন থেকে শুরু আমার লাইফে চলার মতো শক্তি সব আমি এই দুইজন থেকে পেয়েছি। আমার অসীম কৃতজ্ঞতা এই ২টা মানুষের প্রতি।


শিক্ষক দিবসে বাবা-মা, আমার সকল শিক্ষক, সকল বন্ধুদের নতুন করে শুভেচ্ছা জানানো হয়তো একটু মেলোড্রামাটিক লাগবে। কারণ আমি সবসময়ই সবাইকেে ছোট ছোট কিছুর জন্য হলেও এপ্রিসিয়েশনের উপর রাখি। কিন্ত আরো একটা গ্রুপ আছে যাদের আমি শুভেচ্ছা জানাতে চাই।


এরা ঠিক আমার হেটার্স না। তবে এদের ইম্প্যাক্ট অনেক আমার লাইফে। আমি শুভেচ্ছা জানাই সেইসকল মানুষদের যারা আমার লাইফ থেকে চলে গিয়েছো, যারা আমাকে অনেক অনেক ঘৃণার চোখে দেখো/দেখেছো, যারা আমাকে বুঝিয়ে দিয়েছো যে আমি তোমাদের লাইফে থাকার যোগ্যতা অর্জন করতে পারি নাই, যাদের সাথে একটা সময় অনেক অনেক কথা হতো কিন্ত এখন কোনো এক বিশেষ কারণে কথা হয় না, যারা অন্যের জন্য আমাকে দূরে সরিয়েছো, আমাকে ছোট ফিল করিয়েছো, যারা আমার এত কাছের হওয়া সত্ত্বেও এত এত কষ্ট দিয়েছো যা আমার কল্পনাতীত ছিলো, যারা হার্ট করতে করতে আমাকে শক্ত হওয়া শিখিয়েছো, আমাকে পেইন হ্যান্ডেলিং শিখিয়েছো, আমাকে আরো শক্ত বানিয়েছো। তোমরা সবাই আমার লাইফে আমাকে ইনভেন্ট করতে সাহায্য করেছো। তোমরা হয়তো জানোও না যে আমি এখনো তোমাদের কথা ভেবে কতটা কান্না করি এবং ঠিক এরপরই তোমাদের প্রতি কতটা শুক্রিয়াবোধ করি। আমি তন্ময়, আজ ৫ অক্টোবর, বিশ্ব শিক্ষক দিবসে তোমাদের জানাই শিক্ষক দিবসের শুভেচ্ছা।
Thank you for being into my life once and leaving me forever.

 সর্বোপরি আমি শুভেচ্ছা জানাই নাম না জানা অসংখ্য মানুষদের যাদের ব্লগ, কোড, রিপোসিটরি থেকে আমি অনেক অনেক কিছু শিখেছি। আমি ধন্যবাদ জানাই Stack Overflow, Github, Youtube, Coursera সহ সকল কমিউনিটি থেকে যাদের থেকে আমি অনেক অনেক জ্ঞ্যান অর্জন করেছি।

আমি আশা করবো এই পৃথিবীর সকলেই তাদের চেনা সবার জীবনে পজিটিভ শিক্ষক হয় উঠবে।

The English language is nobody’s special property. It is the property of the imagination: it is the property of the language itself. — Derek Walcott

বাংলাকে মাতৃভাষা হিসেবে পাওয়া আমাদের দেশের একটা বিশাল জনগোষ্ঠী মনে করে ইংরেজি বলা মানে ভাব নেয়া। এরা ধরেই নেয় ইংরেজীতে দুএকটা কথা বলা মানে কুল সাজতে চাওয়া, কিংবা অন্যকে ছোটকে করার ইচ্ছা পোষণ করা। এদের কারণে ইংরেজি শিখতে চাওয়া একটা শিক্ষার্থী স্পিকিং/রিডিং প্র‍্যাক্টিস করতে লজ্জাবোধ করে। এরপিছনে অবশ্য আমাদের শিক্ষক সমাজ ও শিক্ষাব্যাবস্থা অনেকাংশেই দায়ী। তবে সেইসব নেগেটিভিটিতে আপাতত আজকে যাওয়ার ইচ্ছা নেই। আজকে শুধু একটু ছোটখাটো পজিটিভ আলাপ।

একটু আগে যে বললাম, সেই লজ্জাবোধটা কাটাতে আমি বেশ কয়েকমাস ধরেই একটা কাজ করে আসতেসি যেটা আমি মনে করি অনেক বেশি উপকার করেছে আমাকে। আর সেই ছোট্ট ট্রিক্সটা নিয়েই আজকের এই লেখা। চলেন, বকবক স্টার্ট করি।

ফেসবুকে কতটা ভয়াবহ রকমের এডিক্টিভ - তা  আমরা সবাই জানি। ভালো লাগলেও, কিংবা না লাগলেও ফেসবুক স্ক্রল করার রোগ আমার মধ্যে অনেক আগে থেকেই আছে। তো, আমার সেই ট্রিক্সটার জন্য এই ফেসবুককেই একটু কাজে লাগানোর ছোট চেষ্টা করেছি আমি।

কাজটা খুব সিম্পল। আমার খুব কাছের বন্ধু না হলে আমি চেষ্টা করি ফেসবুক বা মোবাইলের ম্যাসেজ ইংরেজিতে লিখার। যতই নর্মাল দরকার হোক না কেনো, আমি চেষ্টা করি যা লিখার তা ইংরেজিতে লিখার। ফর্মালি কথাগুলা লিখলে ভালো, আর না হলে হাবিজাবি হলেও কোনোভাবে ইংরেজিতেই লিখি। এতে কত বড় একটা বিশাল উপকার পাইসি তা আমি এখন টের পাচ্ছি। কি উপকার?

 If you talk to a man in a language he understands, that goes to his head. If you talk to him in his own language, that goes to his heart. — Nelson Mandela.

আচ্ছা ধরুন আপনার যদি ইংরেজিতে কিছু বলা লাগে, তাহলে কি করবেন? আগে বাংলাটা ভাববেন, তারপর মনে মনে সেটাকে লুকিয়ে লুকিয়ে ইংরেজিতে ট্রান্সলেট মানে অনুবাদ করে এরপর বলবেন। আর বলে দেখবেন এত কিছুর পরও ২/৩টা গ্রামার ভুল রয়ে গেছে। ঠিক এখানেই আমাদের সমস্যা। আমরা আসলে ইংরেজি শিখতে গেলেও বাংলায় চিন্তা করি। যার কারণে ইংরেজি আর ভাষা হিসেবে শিখা হয় না। ইংরেজিটা সেই কিছু মুখস্ত বিদ্যার বিষয়ে পরিণত হয় যেখানে আমরা রুলস মুখস্ত করে পরীক্ষার খাতায় বমি করে আসতাম। 

আমি মূলত যা বলতে চাচ্ছি সেটা হলো, Think in English. এর মানে হলো আমি যদি কিছু বলতে চাই তাহলে যেনো ইংরেজিতেই সেটা আগে ভাবি। ট্রান্সলেশন এর কথা যেনো মাথায় একবারের জন্যও না আসে। এটা অবশ্যই একদিনে হবে না। তবে একদিন না একদিন ঠিকই হবে। এই যেমন এখন আমি অধিকাংশ সময়ে শব্দচয়ন করতে গেলে ইংরেজি শব্দটাই আগে মাথায় আসে। কোনো ফর্মাল ম্যাসেজ /ইমেইল লিখার সময় ইংরেজিতেই আগে ভাবি যে কিভাবে কি সাজিয়ে লেখবো। আর এতে করে আমি নিজেই এখন বুঝতে পারি যে কয়েক মাস আগের আমার ইংরেজি স্কিল, আর এখনকার ইংরেজি স্কিল - দুটোর মধ্যে অন্তত ২টা প্রশান্ত মহাসাগরীয় দূরত্ব। আমি ইংরেজিতে খুব দক্ষ না হলেও এই একটা ছোট অভ্যাসের কারণে আমার যেই পরিমাণ ইংরেজি দক্ষতা বেড়েছে তা নিয়ে আমি আসলেই সন্তুষ্ট। আমি চাই ঠিক এই একটা ছোট্ট ট্রিক্সই সবাই নিজের ক্ষেত্রেও এপ্লাই করুক যারা আমার মতো ভাংগা ভাংগা ইংরেজী পারে কিংবা ইংরেজী শিখার প্রবল ইচ্ছাতে ভুগছে।

তাহলে এই পোস্টের সারাংশ কি? এই পোস্টের মূল উদ্দেশ্য হলো এটা বুঝানো যে আমরা যুগের সাথে তাল মিলাতে যুগকেই ব্যাবহার করতে পারি। আগের দিনে ফেসবুক না থাকাকালীন সময়ে মানুষ শুধু বই পড়ে পড়ে ইংরেজি শিখতো। প্র‍্যাক্টিস এর সুযোগ কম। কিন্তু এখন যেহেতু ফেসবুক ব্যাবহার করিই, তাহলে এটাকে কেনো কাজে লাগাচ্ছি নাহ আমরা! কেনো এটাকেই আমি ইংরেজি শিখার প্রথম ধাপ হিসেবে কাউন্ট করতে পারতেসি নাহ? কারণ আমরা আসলে এইভাবে কাজের কথা ভেবে দেখিই নাহ।

যাই হোক, আমি আশা করবো, এই কথাগুলা পড়ার পর লজ্জা ভুলে গিয়ে মাঝে মাঝে আপনিও এই Think in English এর জন্য প্রথম ধাপ অনুসরণ করবেন এবং আমাকে ইংরেজিতেই একদিন ম্যাসেজ দিয়ে জানাবেন আপনার সফলতা সম্পর্কে।

What is the shortest word in the English language that contains the letters: abcdef? Answer: feedback. Don’t forget that feedback is one of the essential elements of good communication.  - Unknown

বোনাস: ইংরেজি শিখার পাশাপাশি বাংলাটাও ভালোভাবে শিখেন। দুটোই দরকার। মাঝে মাঝে এখন এমন হয় যে বাংলাটা খুজে পাই না, কিন্তু ইংরেজি শব্দ মাথায় বারাবার ঘুরপাক খায়। 



The Alchemist বই এর কথা কমবেশি আমরা সবাই জানি। আমি আমার জীবনে হাতেগোনা সর্বোচ্চ ৫/১০ টা বই পড়েছি। কিন্তু তারপরও এই বইটার প্রতি আমার ভালোবাসা কোনোদিনও কমে না। আমার বই পড়ার অভ্যাস অনেক কম থাকলেও এই বইটা বারবার পড়তে ইচ্ছা করে কেনো জানি। তো আজকে এই বইটা নিয়েই কিছু বলতে চাচ্ছি। 

The Alchemist বই তে একটা কথা ছিলো, 

“And, when you want something, all the universe conspires in helping you to achieve it.”

কথাটার গভীরতা বুঝানোর সাধ্য নেই আমার। এর প্রমাণ আমি নিজে অনেক পেয়েছি। সেটা হোক নিজেকে নিয়ে, অথবা অন্যকারো জীবনকে দেখে। কিন্তু এতদিন পর, আজকে জানতে পারলাম আরেক অদ্ভুত ঘটনা যা থেকে আবারো এই কথাটার প্রমাণ পেলাম।

বইটার লেখক কোয়েলহো যখন বইটা নিয়ে প্রথম ব্রাজিলিয়ান এক পাবলিশারের কাছে যায়, তখন মাত্র ৯০০ কপি ছাপান ওই প্রকাশক। সেই প্রকাশক বিশ্বাস করতো যে এই টাইটেল এর বই ৯০০ কপির বেশি বিক্রি হবে না। এবং সত্যিই তাই হয়। প্রকাশকের বিশ্বাস ছিলো অতি দৃঢ়।

অপরদিকে কোয়েলহোরও বিশ্বাস ছিলো যে তার এই বই পৃথিবীতে সাড়া জাগানো বই হবে। তাই সেও পরবর্তীতে আবার বইটির রাইটস/সত্ত্বা কিনে নেয় প্রকাশক থেকে। এবং এরপর তিনি আরেক ব্রাজিলিয়ান প্রকাশকের কাছে যান এবং খুব নম্রতার সাথেই বলেন, "আমি আপনাকে নিশ্চয়তা দিতে পারবো না এই বইয়ের বিক্রির ব্যাপারে, তবে আমার দৃঢ় বিশ্বাস এই বই একদিন পৃথিবীর বেস্ট সেলার বই হবে"। সেই প্রকাশক খুব একটা কথা না বাড়িয়ে অচিরেই উত্তর দেন, "Let's give it a try."। এবার বইটির কয়েক হাজার কপি বিক্রি হয়। এবং পুরো ব্রাজিলে এই বইয়ের নাম ছড়িয়ে পড়ে। তবে এবারো কিন্তু এটি পৃথিবীর বেস্ট সেলার বই হয়নি।

২০০৯ সালে কোয়েলহো এক ইন্টারভিউতে বলেন, 

"I was 41 and desperate. But I never lost faith in the book or ever wavered in my vision. Why? Because it was me in there, all of me, heart and soul. I was living my own metaphor."

দ্বিতীয়বার প্রকাশনার আটমাস পর একজন আমেরিকান টুরিস্ট বইটি পড়ে কোয়েলহোকে আমেরিকান প্রকাশকের দারস্ত হওয়ার জন্য বলেন। তিনি বলেন এ কাজে তিনি নিজেই সহায়তা করবেন। এরপর কোয়েলহো জানান, "বইটি ১১৯টি দেশে পৌছানো সম্ভব হতো না যদি না এই বইয়ের ইংরেজী অনুবাদ প্রকাশ করা হতো।"। এবং এরপরের ইতিহাস আমরা কম বেশি সবাই জানি। এই বইটি এখন পর্যন্ত ১৫০ মিলিয়ন কপি বিক্রি হয়।

কোয়েলহো মনে প্রাণে বিশ্বাস করতেন তার এই বই পুরো পৃথীবিতে বেস্ট সেলার হবে, এবং তাই হয়েছে। প্রথম প্রকাশক মনে প্রাণে বিশ্বাস করেছিলো এই বই ৯০০ কপির বেশি বিক্রি হবে না, এবং তাই হয়েছে। দুজনেই দুজনের বিশ্বাসকে বাস্তবে রুপ দিয়েছেন তাদের চেষ্টার মাধ্যমে। 

মজার বিষয় হলো, ২০১১ সালে The New York Times এর এক ইন্টারভিউতে কোয়েলহো জানান তিনি আসলে নিজেও বুঝেননি এত মিলিয়ন মিলিয়ন কপি বিক্রি হতে পারে তার এই ছোট্ট বইটার। তিনি বলেন, 

"It’s difficult to explain why. I think you can have 10,000 explanations for failure, but no good explanation for success"

বোনাসঃ কোয়েলহো এই বইটি মাত্র ২ সপ্তাহে লিখেছিলেন। এত কম সময়ে কিভাবে এরকম একটা বই লিখলেন তা জানতে চাইলে তিনি বলেন, 

"The book was already written in my soul."। 

 



Introduction

A thread is a small unit of execution within a process. It is a light-weight process that allows multiple tasks to be executed concurrently within a single process. Threads share the same address space as the parent process and are often used to achieve parallel processing, improved performance, and better resource utilization.

Threads in Operating Systems

In operating systems, threads are a way to provide concurrency and parallelism within a single process. They allow multiple tasks to be executed simultaneously, providing an efficient way to manage multiple operations. Threads are used to perform several tasks concurrently and to achieve parallel processing.

A single process can contain multiple threads, which can run independently and concurrently. Each thread has its own stack and set of register values, but shares the same address space as the parent process. This shared address space allows threads to communicate with each other and to share data.

Implementing Threads in C

Threads can be implemented in C using the POSIX threads library, also known as Pthreads. The Pthreads library provides a set of functions for creating and manipulating threads in C. The following is a basic example of creating a new thread in C using Pthreads:

 #include <pthread.h>  
 #include <stdio.h>  
 #include <stdlib.h>  
 void *print_message_function(void *ptr)  
 {  
  char *message;  
  message = (char *) ptr;  
  printf("%s \n", message);  
 }  
 int main()  
 {  
  pthread_t thread1, thread2;  
  char *message1 = "Thread 1";  
  char *message2 = "Thread 2";  
  int iret1, iret2;  
  /* Create independent threads each of which will execute function */  
  iret1 = pthread_create( &thread1, NULL, print_message_function, (void*) message1);  
  iret2 = pthread_create( &thread2, NULL, print_message_function, (void*) message2);  
  /* Wait till threads are complete before main continues. Unless we */  
  /* wait we run the risk of executing an exit which will terminate  */  
  /* the process and all threads before the threads have completed.  */  
  pthread_join( thread1, NULL);  
  pthread_join( thread2, NULL);   
  printf("Thread 1 returns: %d\n",iret1);  
  printf("Thread 2 returns: %d\n",iret2);  
  exit(0);  
 }  

In the above example, two threads are created using the pthread_create() function. The first argument to this function is a pointer to a pthread_t data type, which is used to store the thread identifier. The second argument is used to specify the attributes of the thread, and the third argument is a pointer to the function that the thread will execute. The fourth argument is a pointer to any data that needs to be passed to the thread.

Once the threads are created, the pthread_join() function is used to wait for the threads to complete before the main process continues.

Limitations of Threads

Despite their advantages, threads also have some limitations. The following are some of the most commonly encountered limitations of threads:

Synchronization:

One of the biggest challenges with threads is synchronization. Threads can access shared data structures concurrently, which can lead to race conditions and other synchronization problems. To avoid these problems, proper synchronization mechanisms such as mutexes and semaphores must be used.

Deadlocks:

Deadlocks can occur when two or more threads are waiting for each other to complete and are unable to proceed. Deadlocks can cause significant performance problems and must be avoided.

Context Switching Overhead:

Context switching between threads involves saving and restoring the state of the CPU and memory, which can be a time-consuming process. In a system with a large number of threads, the overhead of context switching can become a significant performance bottleneck.

Scheduling:

The scheduling of threads by the operating system can affect their performance. Threads with different priorities may be scheduled differently, which can impact the performance of the system. The operating system must provide an efficient scheduling algorithm to ensure that all threads are executed in a timely and fair manner.

Libraries for Implementing Threads

In addition to the POSIX threads library, there are several other libraries that can be used to implement threads in C. Some of the most commonly used libraries include:

Windows API:

The Windows API provides support for threads on the Windows platform. The API includes a set of functions for creating, managing, and synchronizing threads.

Boost Threads:

Boost is a popular C++ library that provides support for threads on a variety of platforms. The Boost threads library provides a portable and easy-to-use interface for creating and managing threads.

Intel Threading Building Blocks (TBB):

TBB is a C++ library developed by Intel that provides a set of tools for writing parallel programs. The TBB library includes support for threads, task scheduling, and other parallel programming concepts.

Conclusion


Threads are an important concept in operating systems and are widely used to achieve parallel processing and improved performance. In C, threads can be implemented using the POSIX threads library or other libraries such as Boost or TBB. Despite their advantages, threads also have some limitations, including synchronization problems, deadlocks, context switching overhead, and scheduling issues. To effectively use threads in C, it is important to understand these limitations and to use appropriate synchronization mechanisms to avoid race conditions and other problems.



So finally, I am starting it. I have always wanted to write some formal blogs. But couldn't manage my time so. Today I started somehow and here it is. In this blog I will tell you about Database. By the end of reading this blog you will be known the answers of these questions:

  1. What is Database?
  2. History of Database.
  3. What are the types of database?
  4. What are the real life examples of database?
  5. Database elements/Database Sections.
You must know, I took a lots of help from Google and ChatGPT. Anyway, let's get started. 

Introduction to Databases

A database is an organized collection of data that is stored in a structured manner and can be easily accessed and retrieved. The purpose of a database is to manage large amounts of information in a way that makes it accessible, accurate, and consistent.

History of Databases

The first computer databases were developed in the 1960s and were designed to store and manage large amounts of scientific and engineering data. The first commercial relational database was developed in the 1970s by IBM, and it marked a major milestone in the evolution of databases.

Relational databases became the dominant type of database in the 1980s and 1990s, and they have since been used in a wide range of applications, including online shopping, financial management, and customer relationship management. With the rise of big data and the internet, NoSQL databases have become increasingly popular in recent years.

Types of Databases

There are several types of databases, each with its own unique features and advantages. The most common types of databases include:

  • Relational Databases: These are based on the relational model and are designed to store data in tables and relationships between them. Relational databases are widely used and are well suited for applications that require structured data. Examples of relational databases include Microsoft SQL Server, Oracle, and MySQL.

  • NoSQL Databases: NoSQL databases are designed to handle large amounts of unstructured or semi-structured data. They are highly scalable and can handle large amounts of data without slowing down. NoSQL databases are often used in big data and real-time applications. Examples of NoSQL databases include MongoDB, Cassandra, and CouchDB.

  • Object-Oriented Databases: Object-oriented databases are designed to store and manage data in an object-oriented format. This makes them well suited for applications that require complex data relationships. Examples of object-oriented databases include MongoDB and Cassandra.

  • Graph Databases: Graph databases are designed to store and manage data in a graph format. This makes them well suited for applications that require complex data relationships, such as social networks. Examples of graph databases include Neo4j and OrientDB.

  • Columnar Databases: Columnar databases are designed to store data in columns rather than rows. This makes them well suited for applications that require fast data retrieval, such as data warehousing and business intelligence. Examples of columnar databases include Apache Cassandra and Amazon SimpleDB.


Sections of a Database

A database is made up of several sections, including:

  1. Tables: Tables are the basic structure of a relational database and are used to store data. Each table consists of rows and columns, and each row represents a single record in the database.

  2. Fields: Fields are the individual components of a table and represent the different pieces of information that make up a single record.

  3. Keys: Keys are used to link tables together and to ensure the accuracy and consistency of data in the database. There are several types of keys, including primary keys, foreign keys, and composite keys.

  4. Views: Views are virtual tables that are based on the data in other tables in the database. They can be used to simplify complex data relationships and to provide a more user-friendly interface for retrieving data.

  5. Stored Procedures: Stored procedures are pre-written pieces of code that are stored in the database and can be used to perform complex tasks. They can be used to automate repetitive processes, to improve the performance of the database, and to simplify the task of retrieving data.


Advantages of Databases

Databases have several advantages, including: 

  • Data Consistency: Databases ensure data consistency by enforcing rules and constraints on the data stored in them. This helps to prevent errors and inconsistencies in the data and ensures that the data is accurate and up-to-date.

  • Data Security: Databases provide mechanisms for protecting the data stored in them from unauthorized access. This helps to ensure the privacy and security of sensitive information.

  • Scalability: Databases can be scaled to meet the needs of growing organizations. They can handle large amounts of data and provide fast and efficient access to that data.

  • Data Backup and Recovery: Databases provide mechanisms for backing up and recovering data in the event of a failure. This helps to ensure that data is not lost in the event of a disaster.

  • Improved Data Access: Databases provide a centralized repository for data and make it easier for users to access and retrieve the data they need. They also provide powerful tools for querying and analyzing data.


Examples of Databases

There are many examples of databases that are widely used in different industries, including:


  • Customer Relationship Management (CRM) Databases: These databases are used by organizations to manage customer information and interactions. They provide a centralized repository for customer data and help organizations to track and manage customer relationships.

  • Inventory Management Databases: These databases are used by organizations to manage inventory levels and to track the movement of goods and materials. They provide a centralized repository for inventory information and help organizations to optimize their supply chain processes.

  • Healthcare Databases: These databases are used by healthcare organizations to manage patient information and medical records. They provide a centralized repository for patient data and help healthcare organizations to provide high-quality patient care.

  • Financial Management Databases: These databases are used by financial organizations to manage financial information and transactions. They provide a centralized repository for financial data and help organizations to track and manage their finances.


Conclusion

Databases play a critical role in modern organizations, providing a centralized repository for data and making it easier for organizations to access and manage their information. With their many advantages, databases are a powerful tool for managing data and improving organizational performance. Whether you are working in a large corporation or a small business, understanding the basics of databases is essential for success in today's data-driven world.


Don't forget to comment if you face any problem in understanding any lines from this blog. 

Take care.


কিছুদিন আগে আমাকে আমার মা বাজারে পাঠিয়েছিলো মাছ কিনতে। তো বাজারে রউনা দিবো এমন সময় মা আমাকে জিজ্ঞাস করলো, "বাজার তো করো নাই কখনো। তাইলে মাছ কিনবা কিভাবে?"। আমি সোজাসাপ্টা উত্তর দিলাম, "বাজারে যাবো। জিজ্ঞাস করবো এই মাছ আছে কিনা। থাকলে এটা আমাকে দিন। শেষ!!"। আমার মা এবার হেসে আবার জিজ্ঞাস করলেন, "মাছতো অনেকই আছে। ভালো মাছ কোনটা আর খারাপ কোনটা তাতো চিনতে হবে তাই নাহ"? ভেবে দেখলাম এটা আসলেই চিন্তার বিষয়। এরপরে আমার মা আমাকে কিছু বৈশিষ্ট্য বললেন যে ভালো মাছ দেখতে কেমন, রং কেমন, সাইজ কত থেকে কত হতে পারে, কেমন নরম, কত দাম থাকবে ইত্যাদি ইত্যাদি। এখন এই ব্যাপারটা একটু কষ্টের। অনেকগুলা শর্ত আছে। এরউপর আবার কিছু শর্ত আছে যেগুলো ঠিক একই রকম নাও মিলতে পারে, তবে কাছাকাছি গেলেও চলবে। ব্যাপারটা নিয়ে একটু চিন্তা করতে করতে খেয়াল হলো, কিছুদিন আগে যখন SQL শিখছিলাম, তখন সেখানেও এমন কিছু করেছিলাম। অর্থাৎ এটা জেনে রাখুন PostgreSQL এ মোটামুটি সবরকমের কুয়েরী করাই সম্ভব। আপনি যেভাবে এবং যেইরকম ও যতরকম শর্তেই কুয়েরী করতে চাননা কেন, আপনি তা করতে পারবেন শুধু মাত্র সিন্ট্যাক্সগুলো একই রাখলে চলবে। আমার ব্লগের মাননীয় দর্শনার্থীবৃন্দ, চলুন আজ PostgreSQL এর শিখার পর্বে একধাপ এগিয়ে যাই। এ পর্বে আমরা কন্ডিশন কুয়েরীর পরের ধাপ সহ এমন কিছু শিখবো যা আমাদের কাছে PostgreSQL কে আরো ইন্টারেস্টিং করে তুলবো। তাহলে চলুন শুরু করা যাক।

খুল যা সিমসিম!!!!!!!!

গত পর্বে আমরা যা শিখেছি তা দিয়ে আপাতত আমরা ব্যাসিক কিছু কুয়েরী করে আমাদের ডেটাবেজ টেবিল থেকে ডেটা দেখতে পারতাম। আমরা এবার সেইগুলোর পরের ধাপে যাওয়ার আগে আপনাকে আরো কিছু কাজ করা লাগবে। কাজ কঠিন কিছু না। আপনি এর আগেই এই কাজ ভালোমতোই করেছেন। আপনার ডেটাবেজ টেবিলে যা ডেটা আছে, তার সাথে আরো কিছু ডেটা যোগ করুন। মানে ইন্সার্ট অপারেশন চালান। একই কোড কিন্তু আলাদা আলাদা ভ্যালুর সাথে বারবার রান করান। শুধু অন্তত একবার যেকোন একটা কিংবা কয়েকটা কলামের ভ্যালু দিন NULL। কোনরকম কোটেশন চিহ্ন দেয়া লাগবে না। শুধু NULL শব্দটা ভ্যালু হিসেবে দিন। এটার মানে কি এবং কেন করলেন, তা একটু পরেই বুঝতে পারবেন।  আর এই ২টা কাজ শেষে একটা SELECT কুয়েরী চালিয়ে দেখে নিন ২০টার মতো অন্তত রেকর্ড আছে কিনা। আর মূলপর্ব শুরু করার আগে আমরা একটু আগের স্ট্রাকচারটা মনে করে নি,

SELECT column_name AS something FROM "Table_name" WHERE condition_is_something

এবার আমরা শিখবো এই WHERE এর সাথে আরো কত ভাবে ও কিভাবে কিভাবে শর্ত যোগ করতে পারি। কিভাবে আরো নিক্ষুত ভাবে আমরা আমাদের কুয়েরী সম্পন্ন করতে পারি। কিভাবে আমরা আমাদের মনমতো ডেটাগুলো আউটপুট আকারে দেখতে পারি এবং আরো অনেক কিছু। বলে রাখা ভালো, আমি অনেক কিছুই কুয়েরী কোড লিখার আগে শর্টকাট দেখিয়েছি। এর দুটো কারণ আছে। একটা হলো যাতে আপনি pgadmin সফটওয়্যারটির ব্যাবহারের সুফল ভোগ করে আপনার কাজ আরো সহজেই করতে পারেন। এতে সময় ও কষ্ট দুইটাই কম লাগে। আরেকটা হলো আপনি কোড আগে থেকে দেখে নিজে নিজে একটু বুঝতে পারেন। যেমন আমরা ইন্সার্ট অপারেশনের জন্য যেই কোড লিখা লাগবে, তা আগে থেকেই পেয়ে যাচ্ছি। আপনি জানেন এই কোডটি ডেটা ইন্সার্ট করার জন্য ব্যাবহার করা হয়। এখন যদি আপনি কোডটি একটু ভাল করে বুঝার চেষ্টা করেন, তাহলে আপনি নিজেই বুঝতে পারবেন কোনটা কেন লিখা হয়েছে। আর এরপরে আপনি স্ট্রাকচারটা নিজেই আবিষ্কার করতে পারবেন। আমরা এইভাবে সামনে আরো অনেক কিছু সহজে শিখার চেষ্টা করবো।

BETWEEN .... AND

মনে আছে, আমরা গত পর্বে একটা কুয়েরী চালিয়েছিলাম, যেখানে আমরা দেখতে চাচ্ছিলাম কাদের স্যালারি ২১০০০। এখন ধরুন আমরা শুধু ২১০০০ না, আমরা দেখতে চাচ্ছি কাদের স্যালারি ১৫০০০ থেকে ২১০০০ এর মধ্যে। অর্থাৎ কলামের ডেটা একটা রেঞ্জের মধ্যে যাদের ডেটার সাথে মিলবে, তাদের সব ডেটা দেখতে চাচ্ছি। খেয়াল করে দেখুন রেঞ্জের ২টা পার্ট। একটা হলো শুরুর ভ্যালু এবং আরেকটা হলো শেষ ভ্যালু। আর আমরা জানতে চাচ্ছি কাদের salary কলামের ভ্যালু এই দুইটা ভ্যালুর রেঞ্জের মধ্যেই। এর জন্য আমরা এইভাবে সাজাতে পারি,

select column_names from table_name where condition_column between first_value and last_value ;

এখানে condition_column এর জায়গায় আমরা নামে দিবো salary আর first_value এবং last_value এর জায়গায় আমরা দিবো ১৫০০০ এবং ২১০০০। তাহলেই আমাদের কাংখিত রেজাল্ট আমরা দেখতে পাবো।

খেয়াল করে দেখবেন আমি কিওয়ার্ডগুলো লোয়ারকেস লেটারে লিখেছি। এর কারণ আমি আগেই বলেছি SQL কেসসেন্সিটিভ না। সেটা মনে করিয়ে দেয়ার জন্যই মূলতঃ এটা লেখা।

AND

একটু আগে আমরা শিখেছি BETWEEN .... AND এ AND এর কাজ রেঞ্জের দুইটা ভ্যালুর ফরমেট করা। কিন্তু শুধু AND কিওয়ার্ডের কাজ আবার ভিন্ন। তবে অনেক উপকারি। ধরুন আপনি চাচ্ছেন আপনার কুয়েরী আরো নির্দিষ্ট করতে। যেমন আপনি জানতে চান আপনার ডেটাবেজে কাদের ডেটা আছে যাদের স্যালারি ২১০০০ এর উপর তবে তাদের র‍্যাঙ্ক "Detective". অর্থাৎ এখানে আসলে দুইটা শর্ত। প্রথমে আমি জানতে চাই ২১০০০ এর উপরে যাদের স্যালারি তাদের ডেটা। এরপরে জানতে চাচ্ছি আমি এদের মধ্যেই কারা Detective। এইরকম একাধিক শর্তের জন্যই আমরা AND কিওয়ার্ডের ব্যাবহার করে থাকি। AND কিওয়ার্ডটি যেহেতু শর্তের মধ্যে সংযোগ স্থাপন করে, তাই আমাদের SELECT স্ট্যাট্মেন্ট এর মূল স্ট্রাকচারে WHERE  এর পরে এটি দিয়ে শর্তগুলোকে একসাথে লিখে কুয়েরী রান করাতে পারি। তাহলে নতুন স্ট্রাকচার হবে,
 
select column_names from table_name where a_condition and b_condition;


এভাবে আপনার যত ইচ্ছা তত কন্ডিশন যুক্ত করতে পারবেন AND দিয়ে।

OR

আগে ভাবুনতো একবার আমরা AND এর ক্ষেত্রে কি করেছি? আমরা এমন ডেটা দেখেছি যারা অনেকগুলো শর্ত পূরণ করে। কিন্তু এবার কোন কারণে আপনি জানতে চাচ্ছেন অনেকগুলো শর্তের মধ্যে অন্তত একটা শর্ত পূরণ করে এমন কেও আছে কিনা। অর্থাৎ কেও যদি সব শর্ত পূরণ করে তাহলেও থাকবে, নতুবা অন্তত একটা শর্তও যদি পূরণ করে তাদের ডেটাও দেখবো আমরা। তবে যারা একটা শর্তও পূরণ করে না তাদের ডেটা দেখবো না আমরা। আমরা জানতে চাচ্ছি আমাদের টেবিলে এমন কারা আছে, যারা হয় Detective নয়তো Actor অথবা যাদের salary ২৫০০০। তাহলে আমরা আগের মতোই পুরো কুয়েরীটা সহযে করতে পারি। কিন্তু এবার যেহেতু অথবা আছে, অর্থাৎ একটা শর্ত পূরণ করলেই আমরা তাদের ডেটা দেখবো, তাই এবার আমরা AND এর জায়গায় OR দিলেই হবে। আমি এই কুয়েরীটা আপনার উপর ছেড়ে দিচ্ছি। 

Hints: কন্ডিশনগুলোর জায়গায় ঠিকমতো আপনার শর্তগুলো লিখুন আর AND এর জায়গায় OR লিখুন। খেয়াল করুন এবার শর্ত যেহেতু ৩টি, তাই আপনার ২বার OR লিখা লাগবে।

IN 

একটু আগে আমরা কুয়েরী করার সময় একই কলামের দুইরকমের ভ্যালুর উপর কন্ডিশন যোগ করেছি। আমরা জানতে চেয়েছি কাদের rank হয় Detective নাহয় Actor। এখানে আমরা মাত্র ২টা ভ্যালু ব্যাবহার করেছি। কিন্তু ধরুন কোন এক অজানা কারণে আমরা চাচ্ছি শুধু Detective বা Actor নয়, সাথে যারা superstaar, folgach বা আরো এরকম কয়েকটা ভ্যালুর সাথে মিলে এমন মানুষের ডেটা দেখতে। খেয়াল করুন, আমরা চাচ্ছি  একটা কলামের ভ্যালুর, একসেট ভ্যালুর মধ্যে যেকোন একটার সাথে যদি মিলবে তাদের ডেটা দেখতে। এক্ষেত্রে আমরা বারবার OR কন্ডিশন ব্যাবহার করতে পারি, তবে সেটা কষ্টসাধ্য ও অনেক সময় এর ব্যাপার। কারণ ১০০০টি ভ্যালুর সাথে যদি মিল রেখে আমি কুয়েরী করতে যাই, তাহলে ৯৯৯ বার আমাদের OR দিয়ে একই কন্ডিশন লিখা লাগবে। এই কষ্টলাগভের জন্যই IN কিওয়ার্ডের ব্যাবহার করা হয়। আমরা একসেট ভ্যালু দিয়ে বলবো যদি কলামের ভ্যালু এই সেটের মধ্যে যেকোন একটা হয়, তাহলে আমরা সেই রেকর্ডের ডেটা দেখব। স্ট্রাকচার দেখলে ব্যাপারটা আরো সহজ হয়ে যাবে।

select column_names from table_name where column_name in (value1 , value2, value3); 

অর্থাৎ প্রথমে আমরা আগের মতোই সব লিখবো তবে এবার একই কলামের অনেকগুলো ভ্যালুর ক্ষেত্রে আমরা in লিখে প্রথম বন্ধনীর মধ্যে সেই ভ্যালুগুলো লিখবো যেগুলোর সাথে মিল রেখে আমরা ডেটা গুলো দেখতে চাই। তাহলে আমরা ফাইনাল কুয়েরীটা হবে অনেকটা এইরকমঃ


খেয়াল করে দেখুন আমাদের এখানে ভ্যালু 'detective' লেখার পরেও আউটপুটে কোন Detective এর রেকর্ড বা রো দেখাচ্ছে না। এর কারণ PostgreSQL কেস সেন্সিটিভ না। তবে এর ভ্যালুগুলো কেস সেন্সিটিভ। তাই ভ্যালুগুলো এক্সাক্টলি বা ঠিক হুবুহু না মিললে আমাদের আউটপুট হিসেবে তা দেখাবে না।

LIKE 

LIKE এর বাংলা অর্থ মতো। অর্থাৎ কোনকিছু হুবুহু একরকম হতেও পারে আবার নাও হতে পারে এমন বুঝাতে LIKE ব্যাবহার করা হয়। এর জন্য ২টা আরো ছোট ছোট জিনিস শিখতে হবে। প্রথমে একটু জেনে নেই, এরপরে কুয়েরী করলে সব পানির মতো পরিষ্কার হয়ে যাবে।
  • '%' - এর মানে হলো শুন্য বা কিছু ক্যারেক্টার। অর্থাৎ কোন ক্যারেক্টার থাকতেও পারে, আবার নাও থাকতে পারে। থাকলে সেটা এক বা একাধিকও হতে পারে।
  • '_' আন্ডারস্কোর দিয়ে বুঝানো হয় শুধু মাত্র একটি ক্যারেক্টার। মানে ঠিক একটা ক্যারেক্টার আছে এমন বুঝাতে আন্ডারস্কোর দেয়া হয়।
এবার আসুন। আমরা বুঝি এগুলোর মানে আসলে কি। ধরুন আমি জানতে চাচ্ছি আমার ডেটাবেজ টেবিলে এমন কারা আছে যাদের rank এর মাঝে কিছু ক্যারেক্টার থাকতেও পারে বা নাও থাকতে পারে তবে শেষ 'r' দিয়ে। অর্থায় rank এর ভ্যালু দেখতে এমন হবে যে প্রথমে শূন্য বা এক বা একাধিক লেটার থাকবে তবে শেষে শুধু 'r' থাকবে। ব্যাপারটাকে SQL  এর মতো করে লিখলে হবে '%r'। একটু বুঝতে কষ্ট হলে উপরের কয়েকটা লাইন আবার পড়ুন। তাহলে বুঝবেন। '%r' - এই অংশটা দিয়ে আমরা বুঝাবো কেমন দেখতে হবে। অর্থাৎ একটা ব্যাসিক বৈশিষ্ট্য বলে দিবো। তারপর শর্তে যোগ করে দিবো যাদের অমুক কলামের ভ্যালু দেখতে এইরকম, তাদের ডেটা আমাকে আউটপুটে দেখাও। স্ট্রাকচারটা হবে অনেকটা এরকমঃ

SELECT column_names FROM table_name WHERE column_name LIKE 'Basic structure';

যদি কুয়েরী করে দেখি তাহলে আউটপুটগুলোতে আমরা দেখতে পাবো ঠিক সেই সকল রেকর্ড দেখতে পাচ্ছি যাদের rank এর শেষে 'r' আছে।


আমরা যদি আরো মডিফাইড ভ্যালু দেখতে চাই, তাহলে তাও দেখতে পারবো। মনে রাখবেন LIKE কিওয়ার্ড দিয়ে আপনি যেইরকম খুশী সেইরকম কুয়েরী করতে পারবেন। এই যেমন ধরেন আপনি চান দেখতে কাদের ফার্স্ট নেম এর দ্বিতীয় লেটার 'a' এবং তৃতীয় ও চতুর্থ লেটার অন্য যেকোন কিছু এবং পঞ্চম লেটার 's' এবং এর পরে কোন লেটার থাকতেও পারে আবার নাও থাকতে পারে। খুব সহজ করে ভাবুন এখানে ব্যাসিক স্ট্রাকচারটা দেখতে কেমন হবে। এর জন্য আমরা ধাপে ধাপে যাই। 
  1. যেহেতু শর্ত শুরুই হয়েছে দ্বিতীয় বর্ণ থেকে, তাই বলা যায় প্রথম লেটার বা বর্ণ যেকোন কিছু  হতে পারে। আর যেহেতু সেকেন্ড লেটারের আগে একটি বর্ণই থাকতে পারে তাহলে আমাদের প্রথম স্ট্রাকচাত হবে এমন দেখতে, '_a'।
  2. তৃতীয় আর চতুর্থ লেটার যেকোন কিছু হতে পারে। তবে পঞ্চম লেটার আবার 's' হবে। এখানে যদি আমরা '_a%' লিখি তাহলে বুঝাবে a এর পরে অনেকগুলো বর্ণ থাকতে পারে। কিন্তু সেটা আমাদের শর্ত নয়। শর্তানুসারে a এর পরে ঠিক ২টি বর্ণ এবং এর পরে s থাকবে। তাই আমরা দুটি আন্ডারস্কোর ব্যাবহার করে এরপরে s লিখলেই হয়ে যাবে। অর্থাৎ এবার আমাদের স্ট্রাকচারটা হবে  '_a__s'
  3. এরপরের শর্ত আশা করি সহজেই ধরতে পারবেন। যেহেতু বলেই দিয়েছে থাকতেও পারে আবার নাও থাকতে পারে, তাই আমরা % সাইন ব্যাবহার করলেই হচ্ছে। অর্থাৎ আমাদের ফাইনাল স্ট্রাকচার দাড়াচ্ছে, '_a__s%'

 ব্যাপারটা সহজ নাহ? এবার আমি একটা চ্যালেঞ্জ ছুড়ে দিচ্ছি। আমি আশাবাদি এই চ্যালেঞ্জে আপনি খুব সহজেই জয়লাভ করবেন। কুয়েরী করে বের করুন তো, ঠিক কারা কারা email হিসবে gmail এর একাউন্ট ব্যাবহার করে।

NOT 

সাধারণত AND এবং OR এর পরেই NOT শিখে ফেলে অনেকে। তবে আমি মনে করি LIKE শিখার পরে NOT শিখলে সবথেকে বেশি বুঝা যায় এর ব্যাবহার। আপনি যদি একটু আগে কারা কারা gmail ব্যাবহার করেছে তা বের করতে পারেন তাহলে এবার যদি আমরা জানতে চাই কারা কারা জিমেইল ব্যাবহার করে না তাদের ডেটা দেখতে? বা আমরা যদি যাই কাদের salary ১৫০০০ থেকে ২১০০০ এর মধ্যে নয়। কিংবা আমরা যদি দেখতে চাই কাদের rank, Detective এবং Actor নয়। আমরা যদি এটা বের করতে পারি যে কারা gmail ব্যাবহার করে, তাহলে আমরা এটাও জানতে পারবো কারা তা ব্যাবহার করে না। এর জন্য শুধু আমাদের সাধারণ ভাষার মতো NOT ব্যাবহার করলেই হবে। ব্যাসিক স্ট্রাকচার সবগুলো কন্ডিশনের মতোই হুবুহু তবে এক্ষেত্রে শুধু মূল কিওয়ার্ডের আগে আমরা একটি NOT যুক্ত করে দিবো। যেমনঃ

SELECT column_names FROM table_name WHERE column_name NOT LIKE 'Basic structure';

select column_names from table_name where condition_column NOT between first_value and last_value ;

select column_names from table_name where column_name NOT in (value1 , value2, value3);

এবার আমি কুয়েরী করে দেখাচ্ছি না। আমি আপনার উপর বিশ্বাস রেখে কুয়েরী করার দায়িত্ব আপনার উপর ছেড়ে দিচ্ছি। আপনি এখন নিজেই সবগুলো কুয়েরী করতে পারবেন।

IS NULL

মনে আছে? আমি প্রথমে যে বলেছিলাম একটি বা কয়েকটি কলামের ভ্যালু NULL রাখতে। এবার আপনি একটু চেক করুন তো কোন কোন রেকর্ডের rank অথবা email অথবা salary এর ভ্যালু NULL। এক্ষেত্রে কলাম নেম  '=' দিয়ে NULL লিখে স্ট্যাট্মেন্ট চালান। রেজাল্টগুলো আপাতত একটা স্ক্রিনশট দিয়ে রাখুন। এবার আপনি '=' জায়গায় IS লিখুন আর কুয়েরী রান করান। কি দেখলেন? অনেক তফাৎ নাহ? এর কারণ জানার দায়ীত্ব আপনার। ইন্টারনেট থেকে বের করুন কেন এরকম হলো। তার আগে আপাতত আমরা একটু NULL  কি তা জেনে নেই।

NULL  মানে অনেকেই মনে করতে পারেন এটি একটি স্ট্রিং ভ্যালু। আবার অনেকে মনে করতে পারেন এটি একটি ব্ল্যাঙ্ক স্পেস। আবার অনেকে মনে করতে পারেন এটির মান মনে হয় শূন্য। কিন্তু আসলে এগুলোর কোনটিই শূন্য নয়। NULL  মানে NULL। এর কোন ভ্যালু নেই। একে অনেক সময় এম্পটি ভ্যালু হিসবে উল্লেখ করা হয়। যদি এমন হয় কোন ফিল্ডের ভ্যালু আপনি ব্ল্যাঙ্ক রাখেন, তাহলে সেখানে NULL ভ্যালু আছে বলে ধরে নেয়া হয়। আর কোন কলামের ভ্যালু NULL কিনা তা চেক করার জন্য আমরা IS NULL ব্যাবহার করি। ব্যাসিক স্ট্রাকচারটা এমন,

select column_names from table_name where column_name IS NULL;

Bonus Part: IS NULL স্থানে IS NOT NULL ব্যাবহার করে দেখুন আউটপুট কি হয়।

Where এর পরে কন্ডিশন হিসবে সাধারণত যেসব কিওয়ার্ড ব্যাবহার করা হয় তা শিখা শেষ। ছোট ছোট কয়েকটা আরো কিওয়ার্ড আছে, যা আমরা পরবর্তীতে শিখবো।

DISTINCT 

আমি জানি না আপনি খেয়াল করেছেন কিনা, আমার ডেটাবেজ টেবিলে আমি 'James' নামে কয়েকজনের ডেটা রেখেছি। এভাবে আমাদের ডেটাবেজ টেবিলে একই নামে বা একই র‍্যাঙ্কের বা একই ভ্যালু অনেকের থাকতে পারে। যেমন অনেকের rank একই। কিন্তু আমরা চাচ্ছি একই নাম বা ভ্যালু বারবার দেখতে না। অর্থাৎ আমরা কোন কলামের ইউনিক ভ্যালুগুলো দেখতে চাচ্ছি। এর জন্য DISTINCT কিওয়ার্ড ব্যাবহার করা হয়। ব্যাসিক স্ট্রাকচারটা খুবই সহজ,

SELECT DISTINCT column_name FROM table_name



ধরুন আমরা জানতে চাচ্ছি কি কি rank এর রেকর্ড আছে আমাদের ডেটাবেজে। তাহলে আমরা কুয়েরী এভাবে চালাতে পারি,
select DISTINCT rank from "Testing";

Bonus Part: আপনি চাইলেই DISTINCT ব্যাবহার করার পর অন্যান্য কলাম বা একই কলামের উপর WHERE  কিওয়ার্ড দিয়ে শর্ত যুক্ত করে দিতে পারেন। 

ARITHMATIC Operators (+, -, *, /)

ধরুন আপনি ডেটা ইন্সার্ট করার সময় স্যালারি বাদেও একটা কলাম রাখলেন যেটা হলো স্যালারির উপর অতিরিক্ত ১০০০ টাকা বোনাস। অর্থাৎ প্রতিবার যখন ইন্সার্ট করতে যাবেন, আপনার স্যালারির সাথে বারবার ১০০০ টাকা যোগ করে তারপর ইন্সার্ট করা হবে। আবার অনেক সময় আরো কিছু জটিল হিসেব করে ভ্যালু এড করা লাগতে পারে। কিন্তু প্রত্যেক রেকর্ডের ক্ষেত্রে সেগুলো বের করে আবার ইডিট করাটা কষ্টসাধ্য। তাই আমরা প্রয়োজন অনুযায়ী ডেটাবেজ থেকে যখন লাগবে তখন হিসেব করে দেখে নিতে চাই। আর হিসবেটাও একবার করতে চাই। এর জন্য আমরা সহজেই এরিথমেটিক অপারেটরের সাহায্য নিতে পারি। এর ফলে আমাদের আরেকটি অতিরিক্ত কলামে আমাদের সেই হিসেব অনুযায়ী ডেটাগুলো দেখাবে। তবে এটি ডেটাবেজে কোন আলাদা কলাম তৈরি করবে না। ধরুন আমি দেখতে চাচ্ছি  প্রত্যেকের স্যালারির সাথে ১০০০ যোগ করার পর কত আসে, তাহলে কুয়েরীটা এইভাবে চালাতে পারি,

আশা করি ব্যাসিক স্ট্রাকচারটা এবার নিজেই পারবেন। খেয়াল করে দেখুন এখানে আমাদের নতুন কলামের নাম নেই বলে দুপাশে দুটি '?' চিহ্ন দিয়ে বুঝিয়ে দিচ্ছে কলামের নাম নেই। আপনার কাজ হলো এই কলামটিকে 'Salary+Bonus ' নামে দেখানো এবং সেখানে salary এবং এর ১০% যোগ করে দেখানো। আশা করি সহজেই করতে পারবেন। এভাবে আপনি চাইলে একসাথে একাধিক অপারেটর ব্যাবহার করতে পারেন।

CONCATE

আমাদের ডেটাবেজে প্রতিটা রেকর্ডের first_name  এবং last_name আছে। আমরা যদি দুটো কলাম আউটুপুটে দেখি তাহলে তা আলাদা আলাদা কলামে থাকে। মাঝে মাঝে ডেটাগুলোকে আরো সুন্দর করে প্রকাশ করার প্রয়োজন হয়। যেমন, আমরা চাই আমাদের এখানে first_name  এবং last_name আলাদা আলাদা কলামে না দেখিয়ে একই কলামে এবং একসাথে দেখাতে। এর জন্য সিন্ট্যাক্স ২ উপায়ে লেখা যায়।
  • ||
  • CONCATE()
প্রথমটা মোটামুটি সব SQL এই একইভাবে ব্যাবহার করা হয়। এর দুই পাশে কলাম নেম লিখা হয়। যদি সহজ ভাষায় বুঝতে চাই, তাহলে || দিয়ে আমরা দুটো ভ্যালু যুক্ত করি একটি কলামে। এখানে আমরা চাইলে নিজেদের মতো ভ্যালুও যুক্ত করতে পারি। কুয়েরী হবে অনেকটা এমন,


এখানে একটা সমস্যা হয়ে দাড়িয়েছে। আমরা চাই first_name এবং last_name এর মাধে গ্যাপ থাকুক। কিন্তু আমি আগেই বলেছি, চাইলে আমি নিজের মনমতোও ভ্যালু দিতে পারবো, তাই নতুন কুয়েরীটি হবে,


মনে রাখবেন, আপনি নম্বর ভ্যালু দিতে চাইলে কোটেশন ছাড়া দিলেও হবে। তবে স্ট্রিং ভ্যালু দিতে চাইলে অবশ্যই কোটেশন দিয়ে এরপর ভ্যালু দিতে হবে। 

অন্যদিকে CONCATE() টি একই কাজ করে। তবে এক্ষেত্রে স্ট্রাকচারটা একটু অন্যরকম, এক্ষেত্রে CONCATE এর পরে যেই প্রথম বন্ধনী আছে, সেখানে কমা দিয়ে দিয়ে ভ্যালুগুলো লিখা লাগবে। একই কুয়েরী CONCATE দিয়ে করলে অনেকটা এমন হবে, 

select CONCAT(first_name,' ',last_name) from "Testing";

এবার আপনার কাজ হলো আপনি একটি কলামেই প্রতেকের র‍্যাঙ্ক এবং র‍্যাংকের ঠিক পরেই তাদের ফুল নেম লিখবেন। যেমনঃ "Detective James Bond"।

ORDER BY

আমরা যখন কুয়েরী করি, আমরা যে সবসময় একই ফরমেটে ডেটা দেখতে চাই এমন নাও হতে পারে। যেমন হঠাত যদি আমরা সবার ডেটা দেখতে চাই তবে সেখানে যার স্যালারি সবথেকে কম সে আগে, এবং এর পরে যার কম সে এবং এইভাবে যার স্যালারি সবথেকে বেশি, সে সবার পরে থাকবে, তাহলে তাও সহজেই PostgreSQL এর সাহায্যে করা যায়। ব্যাপারটাকে বলা হয় সর্টিং বা সাজানো। সাজানো দুইরকম হতে পারে, হয় ছোট থেকে বড়। আর না হয় বড় থেকে ছোট। এখানে বুঝতে হবে আমরা কোন কলামের উপর সর্ট করতে চাচ্ছি। ব্যাসিক স্ট্রাকচারটা হবে এমন,

select column_names from table_name ORDER BY column_name;

কুয়েরীটা আশা করি এবার সহজেই করতে পারবেন।


খেয়াল করুন আমাদের এখানে সর্বনিন্ম স্যালারি ২১০০ তাই ২১০০ সবার উপরে। আবার এখানে ২১০০ অনেকেই আছে। সবাইই পরবর্তী স্যালারির আগেই রয়েছে। অর্থাৎ স্যালারি কম থেকে বেশি অনুযায়ী সাজানো হয়েছে। কিন্তু সবসময় যে আমরা ছোট থেকে বড় আকারে সাজাবো এমনটা নাও হতে পারে। আমরা বড় থেকে ছোট সাজাতে চাইতে পারি। এবং এটাও সম্ভব। বাই ডিফল্ট PostgreSQL ছোট থেকে বড় সাজিয়ে দেয়। কিন্তু আমরা যদি বড় থেকে ছোট সাজাতে চাই, তাহলে কলাম নেমের DESC (ডিসেন্ডিং) লিখলেই তা বড় থেকে ছোট আকারে সাজিয়ে দিবে।

Bonus Part 1: আপনি চাইলে DESC এর জায়গায় ASC লিখে দেখতে পারেন। কি আউটপুট দেখায় তা দেখে নিজেই বুঝতে পারবেন এর মানে কি।

Bonus Part 2: ORDER BY দিয়ে আপনি কেবল  একটি কলামের উপর সর্ট করতে পারবেন, ব্যাপারটি এমন নয়। আপনি চাইলে একসাথে অনেকগুলো কলামের উপর বেস করে সর্ট করতে পারেন। ব্যাপারটা এমন যে অনেকের স্যালারি ২১০০। কিন্তু আমি চাচ্ছি যার সিরিয়াল নম্বর আগে, তার ডেটা আগে দেখাবে। তাহলে আমার প্রথমে লাগবে স্যালারি কলামের উপর সর্ট। এরপর সিরিয়াল কলামের উপর। এইভাবে যখন একাধিক কলামের উপর সর্ট করা লাগবে, তখন ORDER BY প্রত্যেকটা কলামের নাম কমা দিয়ে দিয়ে লিখলেই হবে। এক্ষেত্রে ORDER BY এর পর যেই কলামের নাম আগে আসবে, সে কলামের প্রায়োরিটি আগে পাবে। অর্থাৎ আমরা আগে আগে স্যালারি সর্ট করতে চাচ্ছি, এরপর যদি অনেকের স্যালারি এক হয়, তাহলে তাদের সিরিয়াল নম্বরের উপর ভিত্তি করে সর্ট করে চাচ্ছি। তাই আগে স্যালারি লিখবো এবং এর পরে সিরিয়াল নম্বর।

Bonus Part 3: অনেকগুলো কলামের উপর ভিত্তি যেমন সর্ট করতে পারি, ঠিক তেমনি প্রত্যেকটা কলামের আলাদা আলাদা ছোট থেকে বড় কিংবা বড় থেকে ছোট শর্ত দিয়েও সর্ট করতে পারি। নিচের কুয়েরীটি রান করানোর পর আউটপুট ভালোভাবে লক্ষ করুন।

select serial_no, first_name, salary from "Testing" order by salary DESC, serial_no ASC;

Bonus Part 4: আমরা চাইলে আগে কিছু শর্ত দিয়েও সর্ট করতে পারি। এক্ষেত্রে আগের মতোই WHERE  স্ট্যাট্মেন্ট ব্যাবহার করবো, এবং তারপর order by ব্যাবহার করবো।

SELECT column_names FROM table_name WHERE condition ORDER BY column_name;


Episode Bonus

pgadmin বামপাশের সাইডবার থেকে আমাদের টেবিলনেমের উপর রাইট ক্লিক করলে সবার শেষে Properties এ ক্লিক করলে আমরা আমাদের পুরো টেবিলের সব ইনফোরমেশন পেয়ে যাবো। এবার সেখানে উপর থেকে Columns এ ক্লিক করলে আমাদের কলামগুলোর স্ট্রাকচার বা ইনফরমেশন পেয়ে যাবো। এখান থেকে আমরা চাইলে আমাদের কলামগুলোর ডেটাটাইপ বা বিভিন্ন পরিবর্তনও করতে পারবো। এইযে আমরা টেবিলের ইনফরমেশনগুলো দেখলাম, এটা হলো Table Describing। এইটা দেখার আরো কয়েকটা উপায় আছে, কমান্ড লাইন তার মধ্যে অন্যতম। তবে কমান্ড লাইনের ব্যাপারটা নিয়ে পরের পর্বে আলোচনা করা যাবে। আপাতত একটি কুয়েরীর সাহায্যে এটা সহজে কিভাবে দেখতে পারবে।


আজ এখানেই থাকুক। আপনাদের একটা ছোট কাজ দেই, আপনি স্যালারির উপর সর্ট করে একটি কলামে প্রত্যেকটা ডেটা দেখান যেখানে সবার লাস্টনেমের সেকেন্ড লাস্ট লেটার 's'। কিন্তু কলামে ডেটাগুলো দেখাবে একটা লাইন। লাইনের একটা উদাহরণ হলো এমন,

Detective Sherlock Holmes earns 25000 dollar each month with 2500 dollar bonus from email marketing by sh221b@gmail.com.

এখানেই পর্ব ২ এর সমাপ্তি দিচ্ছি। তবে আপনারা এখানেই থেমে থাকবেন না। ইন্টারনেট থেকে আরো আরো রিসোর্স খুঁজে বের করুন ও বুঝা শুরু করুন। শিখতে থাকুন। আর এই ব্লগের ফিডব্যাক দিতে পারেন কমেন্ট বা ইমেইলের মাধ্যমে।

চাইলে আমার ব্লগটির ইমেইল সাবস্ক্রিবশন করতে পারেন ফ্রি। এতে আমার ব্লগ প্রকাশ পাওয়া মাত্রই আপনি ইমেইল পেয়ে যাবেন। আর এই পর্ব থেকে যদি কিছু শিখতে পারেন এবং আরো অন্য কিছু সম্পর্কে টিউটরিয়াল চান, তাহলে কমেন্ট অথবা ইমেইলে জানাতে ভুলবেন না। 

আর হ্যা, কমেন্টে ফিডব্যাক দিলে খুবই খুশী হবো। কোন একদিন আমি আমার ব্লগের কমেন্টকারীদের নিয়ে আড্ডা দিবো - এটি একটি স্বপ্ন আমার।

যদি Life of Loco সম্পর্কে জানতে চান, তাহলে এই লিঙ্কে গিয়ে জানতে পারেন।

ভালো থাকবেন, ভালো রাখবেন।

প্রথম পর্ব এখান থেকে দেখতে পারেন।

 

পুরাতন পোস্টসমূহ হোম

About Me


I am just an usual living being. Watching people being happy is the most fascinating sight to me.
I believe, life is boring without facing challenges.

Popular Posts

  • Basics of PostgreSQL - বাংলা (Part - 01)
    অন্তত ২০ লাইন ইংরেজীতে লেখার পরে চিন্তা করলাম বাংলায় লেখলেই বোধহয় ব্যাপারগুলো বুঝাতে সহজ হবে। কিন্তু বাংলায় লিখতে গেলে একটা বড় সমস্যা হয়। সে...
  • Basics of PostgreSQL - বাংলা (Part - 02)
    কিছুদিন আগে আমাকে আমার মা বাজারে পাঠিয়েছিলো মাছ কিনতে। তো বাজারে রউনা দিবো এমন সময় মা আমাকে জিজ্ঞাস করলো, "বাজার তো করো নাই কখনো। তাইলে...
© Brainless Loco 2021
. Blogger দ্বারা পরিচালিত.

Featured Post

The Platypus: Nature’s Most Exceptional Creature [Part 2]

  Hello hello hello.... Welcome back my useless blog again.  Welcome back to our exciting journey exploring the platypus, one of the most mi...

Contact Me

নাম

ইমেল *

বার্তা *

Search Something

লেবেল

  • About (1)
  • Facts (3)
  • HTML (1)
  • Knowledge (2)
  • Lifestyle (1)
  • Loco-Thoughts (1)
  • ReactJs (1)
  • Tutorials (5)
  • Web Development (1)

Connect me

  • Facebook
  • LinkedIn
  • Instagram
  • WhatsApp
  • Github
  • Telegram
  • Pinterest

Go To

  • Home
  • About

Important Links

  • Home
  • Contact Me
  • About Me

About Being Loco

This blog was created with a intention to record all of my movements while gradually moving towards death. I humbly request you to give feedbacks on my blogs. Each feedback is really an achievement to me.

Popular Posts

  • Basics of PostgreSQL - বাংলা (Part - 01)
    অন্তত ২০ লাইন ইংরেজীতে লেখার পরে চিন্তা করলাম বাংলায় লেখলেই বোধহয় ব্যাপারগুলো বুঝাতে সহজ হবে। কিন্তু বাংলায় লিখতে গেলে একটা বড় সমস্যা হয়। সে...
  • Basics of PostgreSQL - বাংলা (Part - 02)
    কিছুদিন আগে আমাকে আমার মা বাজারে পাঠিয়েছিলো মাছ কিনতে। তো বাজারে রউনা দিবো এমন সময় মা আমাকে জিজ্ঞাস করলো, "বাজার তো করো নাই কখনো। তাইলে...
  • First step in learning English
    The English language is nobody’s special property. It is the property of the imagination: it is the property of the language itself. —  Dere...
  • An interesting fact about "THE ALCHEMIST"
    The Alchemist বই এর কথা কমবেশি আমরা সবাই জানি। আমি আমার জীবনে হাতেগোনা সর্বোচ্চ ৫/১০ টা বই পড়েছি। কিন্তু তারপরও এই বইটার প্রতি আমার ভালোবাস...
  • React Learning Path - Part 1 [Learning the HTML Basics]
    Before the Beginning First off, congratulations! You’re about to learn something that’s not only useful but also surprisingly simple. The go...
  • The Platypus: Nature’s Most Exceptional Creature [Part 1]
      So, a few days ago, I was chilling on my couch, scrolling through Facebook like it’s my part-time job. You know how it goes—funny dog clip...
  • The Platypus: Nature’s Most Exceptional Creature [Part 2]
      Hello hello hello.... Welcome back my useless blog again.  Welcome back to our exciting journey exploring the platypus, one of the most mi...
  • এবং একটি শিক্ষক দিবস।
    হঠাত করে আজকে সকালে ইমন এসে শিক্ষক দিবসের শুভেচ্ছা জানালো। আমি অবাক হয়ে জিজ্ঞাস করলাম যে কয়েকদিন আগেই না শিক্ষক দিবস গেলো? ও বললো, "কই ...
  • An Introduction to Database
    So finally, I am starting it. I have always wanted to write some formal blogs. But couldn't manage my time so. Today I started somehow a...
  • About 'Life of Loco'
    গুগল ট্রান্সলেটর কিংবা যেকোন ইংরেজি অভিধান থেকে সার্চ দিয়ে পেয়ে যাবেন Loco এর মানে মূলতঃ বিকৃত-মস্তিষ্ক বা পাগল । পাগল শব্দটাকে অপমান করছি...

লেবেল

  • Tutorials (5)
  • Facts (3)
  • Knowledge (2)
  • About (1)
  • HTML (1)
  • Lifestyle (1)
  • Loco-Thoughts (1)
  • ReactJs (1)
  • Web Development (1)
Copyright © 2021 Life of Loco

Created By Brainless_Loco

Created By Brainless_Loco