0% found this document useful (0 votes)
48 views3 pages

SQL Queries for Book and Nobel Data

The document describes 12 SQL queries related to Nobel prize data stored in a nobel relation. The queries include: 1) Counting the total number of prizes awarded and for specific subjects like Physics. 2) Finding minimum years prizes were awarded for each subject and counting prizes by year and subject. 3) Counting distinct winners by subject and years with prizes for each subject. 4) Finding years with 3 Physics prizes and winners who have won more than once or in multiple subjects.

Uploaded by

Ty Sen
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views3 pages

SQL Queries for Book and Nobel Data

The document describes 12 SQL queries related to Nobel prize data stored in a nobel relation. The queries include: 1) Counting the total number of prizes awarded and for specific subjects like Physics. 2) Finding minimum years prizes were awarded for each subject and counting prizes by year and subject. 3) Counting distinct winners by subject and years with prizes for each subject. 4) Finding years with 3 Physics prizes and winners who have won more than once or in multiple subjects.

Uploaded by

Ty Sen
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Assignment – 8

Create the following schema and insert some tuples in these tables shown below.
Author (ID, Name, Birth_Year, Death_Year (NULL in case of Author is alive))
Book (ID, Author_ID, Title, Publish_Year, Publishing_House, Rating))
Adaptation (Book_ID, Type, Title, Release_Year, Rating)

i) Select the title of each book and the name of its author.

SELECT title, name


FROM author join book
ON [Link] = book.author_id

ii) Show the name of each author together with the title of the book they wrote and the year in which
that book was published. Show only books published after 2005.

SELECT name, title, publish_year


FROM author JOIN book
ON [Link] = book.author_id
WHERE publish_year > 2005

iii) For each book, show its title, adaptation title, adaptation year, and publication year.
Consider only books with a rating lower than the rating of their corresponding adaptation.
Additionally, show only those books for which an adaptation was released at most four years after
the book was published. Rename the title column from the book table to book_title, and the title
column from the adaptation table to adaptation_title.

SELECT [Link] AS book_title, [Link] AS adaptation_title, book.publish_year,


adaptation.release_year
FROM book JOIN adaptation
ON [Link] = adaptation.book_id
WHERE [Link] < [Link] AND
(adaptation.release_year - book.publish_year) <= 4

iv) Join the author and book tables using an INNER JOIN.
Show the title of each book together with its rating. Consider only those books that were published
by authors who are still alive.

SELECT title, rating


FROM author INNER JOIN book
ON [Link] = book.author_id
WHERE author.death_year IS null

v) Display the title of each book along with the name of its author. Show all books, even those without
an author. Show all authors, even those who haven't published a book yet. Use a FULL JOIN.

SELECT title, name


FROM book FULL JOIN author
ON book.author_id = [Link]
vi) Generate all possible pairs of book titles and author names. Consider only boooks whose
author's name is Ray Henry.

SELECT title, name


FROM book CROSS JOIN author
WHERE [Link] = 'Chetan Bhagat'

vii) Select each book's title, the name of its publishing house, the title of its adaptation, and the type
of the adaptation.

SELECT [Link], book.publishing_house, [Link], [Link]


FROM book RIGHT JOIN adaptation
ON [Link] = adaptation.book_id
WHERE [Link] = 'movie'

viii) Show the title of each book and the name of its author — but only if the author was born in the
20th century. Otherwise, the author's name field should be NULL.

SELECT [Link], [Link]


FROM book LEFT JOIN author
ON book.author_id = [Link]
AND author.birth_year BETWEEN 1901 AND 2000

Consider the relation nobel (year, subject, winner, country, category) and execute the given
queries(Aggregate/Group By/Having):

i) Show the total number of prizes awarded.

SELECT COUNT(winner) FROM nobel

ii) List each subject - just once

SELECT DISTINCT subject FROM nobel

iii) Show the total number of prizes awarded for Physics.

SELECT COUNT(*) FROM nobel WHERE subject='Physics'

iv) For each subject show the subject and the number of prizes.

SELECT subject, COUNT(*)


FROM nobel
GROUP BY subject

v) For each subject show the first year that the prize was awarded.

SELECT subject,MIN(yr) FROM nobel


GROUP BY subject
vi) For each subject show the number of prizes awarded in the year 2000.

SELECT subject, COUNT(winner)


FROM nobel
WHERE yr=2000
GROUP BY subject

vii) Show the number of different winners for each subject.

SELECT DISTINCT subject, COUNT(DISTINCT winner)


FROM nobel
GROUP BY subject

viii) For each subject show how many years have had prizes awarded.

SELECT subject, COUNT(DISTINCT yr)


FROM nobel
GROUP BY subject

ix) Show the years in which three prizes were given for Physics.

SELECT yr FROM nobel


WHERE subject='Physics'
GROUP BY yr
HAVING COUNT(yr)=3

x) Show winners who have won more than once.

SELECT winner FROM nobel


GROUP BY winner
HAVING COUNT(winner)>1

xi) Show winners who have won more than one subject.

SELECT winner FROM nobel


GROUP BY winner
HAVING COUNT(DISTINCT subject) > 1

xii) Show the year and subject where 3 prizes were given. Show only years 2000 onwards.

SELECT yr, subject FROM nobel


WHERE yr >= 2000
GROUP BY yr, subject
HAVING COUNT(DISTINCT winner)=3

Common questions

Powered by AI

Restricting analysis to books adapted into movies can limit interpretations of a book's success and popularity as it disregards other successful adaptation forms such as television, theater, or digital media, where a book may also shine. Movie adaptations are just one available metric of broader success. By focusing solely on movies, the analysis may neglect diverse adaptation pathways that also signify cultural impact and popularity within differing audience segments. This narrow focus may misrepresent a book's overall market success and cultural significance beyond the film industry .

Considering only books published after 2005 for analysis emphasizes current literary styles, themes, authors, and movements. However, this limitation may omit understanding the evolution of trends that form the current landscape, as it excludes works that are close to but before the cutoff which may have influenced later works. This restrictive window may lead to ignoring transitional works or undervaluing continued success and influence of slightly older texts. Thus, while focusing on post-2005 publications highlights recent trends, it risks an incomplete snapshot of literary progressions and the interplay between past and current influences .

Analyzing the years with exactly three Nobel prizes awarded in Physics highlights periods of exceptional scientific output and possibly collaborative or parallel breakthroughs in the field. Such clustering of awards within a single year implies a peak in research activity and notable advancements in theoretical or applied physics. Understanding these patterns may illuminate trends related to technological developments, funding influences, or shifts in scientific focus and collaboration. Thus, this analysis of clustered award years can provide insights into the historical progression and periods of significant innovation in Physics .

The condition that adaptations must have a higher rating than the original books may underscore a broad appeal and possibly better execution in a different medium, which suggests that certain stories are enhanced by visual or performance elements not present in the textual form. This heightened rating could indicate strong directorial vision, effective casting, or innovative storytelling in the adaptation. Moreover, it highlights potential differences in expectations and engagement between readers and viewers, offering insights into how storytelling can be transformed to suit varied consumer preferences and how narratives may evolve when transitioning from one medium to another .

Aggregating the number of Nobel prizes awarded per subject provides a quantitative understanding of recognition and emphasis across various scientific disciplines. A higher count in certain subjects might suggest targeted funding priorities, reflecting where significant advances are occurring or where efforts are disproportionately directed. Such data can shed light on the allocation dynamics within the scientific community, possibly highlighting disciplines with more substantial discoveries or those that attract greater interest and financial investment. Ultimately, this can reveal broader trends in scientific progress and institutional priorities .

Limiting book selections to those books with adaptations released within four years of the book's publication can offer insight into how quickly and readily literature can be adapted into another medium, reflecting its receptivity and relevance. A rapid transition from publication to adaptation suggests that a book was immediately impactful or popular, suggesting strong narrative elements or themes that resonate quickly with contemporary audiences and industries. Such insights can influence the identification of literary trends and the qualities that drive a book's adaptation potential .

Identifying Nobel winners who have succeeded in more than one subject underscores exceptional cross-disciplinary skills and adaptability, indicating a profound ability to innovate and contribute concepts that transcend domain boundaries. This highlights the versatility and integrative thinking of such individuals, reflecting the growing significance of interdisciplinary approaches in solving complex problems. It suggests that major breakthroughs often occur at the intersection of traditional fields, driven by recipients with broad expertise who can synthesize ideas and methodologies across subjects to generate novel solutions and insights .

Filtering data to include only books by authors who are still alive may skew analyses of literary trends by excluding established works of deceased influential authors. This could lead to an incomplete or biased understanding of current literary trends and innovation, as historical context and long-standing influences are not considered. While focusing on living authors highlights contemporary contributions and dynamic market trends, it might overlook foundational influences and context that are critical to well-rounded literary analysis. Therefore, it's crucial to consider dataset limitations when drawing conclusions about trends and influences in literature .

Counting the distinct number of Nobel prize winners for each subject sheds light on the diversity and competition within those categories. A higher count indicates a greater diversity of individuals contributing significantly within the field, reflecting a wide range of recognized talent and potential competition. Conversely, a low count might suggest monopolization by fewer individuals or institutions, potentially pointing to limited access, diversity, or even bias within the subject's field. This analysis helps in understanding competitive dynamics and inclusivity in academic and research domains associated with each Nobel prize category .

A FULL JOIN in SQL is used to retrieve all records when there is a match in either left (author) or right (book) table records. This operation allows for the identification of all books and authors, including authors who haven't published any books and books that lack corresponding author entries. By using a FULL JOIN, it is possible to gain insights into the entirety of the dataset and the completeness of the author-book relationship. Specifically, this highlights existing gaps, such as books without an associated author in the database and authors who have yet to publish a recorded work. This is crucial for database integrity analysis and completeness .

You might also like