In Chapter 7, through flashbacks interwoven with Stanley's digging, we learn the story of Elya Yelnats and the origin of the Yelnats family curse. In this historical flashback, Elya Yelnats is a fifteen-year-old Latvian boy who falls in love with a beautiful but shallow girl named Myra Menke. Myra's father demands that both of Myra's suitors - Elya and a fifty-something pig farmer - bring him their best pig, and declares that Myra's future husband will be determined by which pig weighs more on the day of Myra's fifteenth birthday.
Poor, young Elya despairs at first, but receives an unexpected chance at success thanks to his strange friend, old Madame Zeroni. She tells him that if he carries the runt of her own pig's litter up the mountain every day, lets it drink at a special spring, and sings it a lullaby, that it will grow strong and heavy by the morning of Myra's birthday - and Elya will become stronger, too. In return, Madame Zeroni requests that Elya carry her up the mountain and let her drink, too, once he is strong enough to do it. If he does not follow through on this promise, he and his descendants will be cursed.
Elya readily agrees to this, and enthusiastically follows Madame Zeroni's instructions - until the final morning, when he does not take the pig up the mountain one last time. It is found to be exactly equal in weight to his rival's pig. When Myra is unable to decide between her two suitors, Elya becomes disgusted, and realizes she is truly shallow. He buys a ticket for a ship to America, and leaves as soon as possible, forgetting to fulfill his promise to Madame Zeroni. Although he finds a wonderful wife in America, Elya is followed by bad luck due to the curse; the bad luck trails the Yelnats family all the way down to Stanley Yelnats IV, who blames his troubles on his great-great-grandfather.
Stanley begins to settle into the routine of life at Camp Green Lake. In Chapter 7, he digs his first hole, and discovers the difficulty of the task. The physical labor of digging huge holes every day exhausts him, but he learns that he is surprisingly resilient. Furthermore, he becomes accepted by the group of boys in D tent, receiving the nickname "Caveman" because of his large size. The knowledge that he is making friends - the kind of friends he never had in school - helps him push through the tough days.
Stanley writes letters home to his mother in which he pretends that he is having a fantastic time playing water sports on the lake - he doesn't want to worry her, he tells Zero, who annoys Stanley by looking over his shoulder as he writes the letters. When Mr. Pendanski asks all the boys what they want to do in the future, Stanley has a hard time thinking of a job he'd like to do, and he makes all the other boys laugh when he tells them about his "no-good-dirty-rotten-pig-stealing-great-great-grandfather" (57). After being mocked by Mr. Pendanski about being "not completely worthless," Zero answers that all he likes to do is to dig holes (58).
Out on the lake bed, Stanley finds a fossil in a hole while digging, and eagerly shows it to Mr. Pendanski, hoping to get the rest of the day off as a reward. He is told that the Warden is not interested in fossils, but if he finds anything more interesting, he should make it known. X-Ray asks Stanley to give any future finds to him - he has been at Camp Green Lake the longest, and is most deserving of a day off. Stanley acquiesces to this demand.
Stanley does find something more interesting than fossils when they're out digging in the lake bed: a gold cylinder, which the boys think might be a bullet casing, but is actually a lipstick tube belonging to the outlaw Kissin' Kate Barlow. As promised, Stanley gives the object to X-Ray, and counsels him to hand it over the next morning, so that he can get a full day off from digging instead of just half an afternoon. X-Ray responds appreciatively to this advice, and Stanley's status in the camp increases: he moves up one place in the water line.
The structure of Chapter 7 consists of short scenes from the present, in which Stanley struggles to finish digging his first hole, and narrative flashbacks to the life of Elya Yelnats, Stanley's great-great-grandfather from Latvia. The constant switching back and forth between present and past serves to underline the strength of the connection between family history and an individual's present condition. Laura Nicosia writes on this subject that "[t]he two storylines alternate in narrative counterpoint throughout the chapter with no segues, no transitions. Rather than constructing connections between the story lines to ease the reader from the present to the distant past, Sachar fosters a sense of rushing urgency that propels the reader from the present, to the past, and back again. He does this by incrementally shortening the duration of each vignette over the course of the chapter."
This narrative technique essentially links Stanley's frustration and pain with the mistakes of Elya Yelnats. In this way, it can be said to follow Stanley's own train of thought, since he blames his bad luck on his great-great-grandfather. There is an interesting narrative question here, since the flashbacks are narrated by an omniscient third-person narrator, and yet their placement seems subjective in that it reflects Stanley's feelings about his past and present. When the truth of the Elya and Madame Zeroni story is called into question later in the novel, readers might think back to this chapter. Does its existence, coupled with the omniscient (and therefore objective) narration, prove that the history is true and really did happen?
The source of the song which first came up in Chapter 3 - the one that starts with the wistfully plaintive refrain "If only, if only" - is revealed in Chapter 7 to have come from Latvia, brought over to America and translated by Elya Yelnats and his America wife, Sarah Miller. This song is central to the identity of the Yelnats family, since it has been passed down from generation to generation: it is their link to their past, and it also seems to have a magic aura instilled in it by the magical Madame Zeroni. The lyrics also seem to capture a sense of regret that is part of the Yelnats family sensibility: they are always wishing, like Elya, that things could have gone differently, and that the past could be rewritten and set right.
Chapter 8 is a strange, short interlude from the daily life at Camp Green Lake. Less than a page in length, it draws an analogy between yellow-spotted lizards - the deadliest threat to anyone exploring the lake bed - and "curses" (41). The lizards have loomed large in the reader's imagination, as well as the psyche of the boys at the camp, since the first chapter. Readers are warned that "[i]f you get bitten by a yellow-spotted lizard," you will "die a slow and painful death" (4). It is "the worst thing that can happen to you" (4). In introducing the setting of Camp Green Lake, Louis Sachar focuses on these lizards, since they seem to encapsulate all that is dangerous and threatening about the place.
But why link the yellow-spotted lizards to the Yelnats family curse that has been outlined in Chapter 7? Curses are important for the novel because they symbolize how a person or a family's past can infect and spoil the present, and how bad luck can follow people from generation to generation. Some people use curses, as we learn later, to explain away failures and bad luck. In general, modern-day society doesn't believe in magic or the power of curses, and this is why Sachar compares a curse to a yellow-spotted lizard: both can be extremely dangerous, but neither is believed in by "a lot of people" (41).