Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

QUESTION: (Answer in SQL) Let us define the term advertisement-gap as the number of users who have blurted about a topic that is of interest

QUESTION: (Answer in SQL) Let us define the term "advertisement-gap" as the number of users who have blurted about a topic that is of interest to a vendor but are not being shown in any advertisements from the vendor. Write an SQL query that gives the vendor name and the corresponding "advertisement-gap" in decreasing order of the advertisement_gap.

BACKGROUND INFO:

Blurt ids are serial and unique to the blurts by a given user; the first blurt by a given user would have blurt id 1 and ids are incremented for each successive blurt by the user. Note that blurt ids are unique only to a user, so blurts by two different users may have the same blurt id. Besides an id, each blurt also has its text, timestamp, and user location as additional attributes.

The system should have a pre-defined notion of topics that are simply subjects that people may blurt about. Examples of topics might include music, pollution, disease, disaster, sports, weather, etc. A topic has a unique id and description (the name of the topic).

Each blurt by a user is analyzed to associate with it zero or more topics. Related blurt-topic pairs are stored in blurt_analysis table. To account for the possible ambiguity arising from the choice of words or language used by a user, an association with a topic has a corresponding confidence level (an integer ranging from 1 10 indicating the strength of the association). For example consider the following blurt: I absolutely hate the rainy weather, cant go out, listening to the Beatles, just love them is analyzed to be associated with two topics, weather and music (Beatles).

For each topic, the associated sentiment is evaluated and quantified as an integral value ranging between -5 and 5, with higher values indicating a more positive sentiment. Considering the example blurt used above, the topic weather would have an associated sentiment of -5 (hate) while for music the corresponding value is 4 (love).

Note: You dont need to implement the value constraint as MySQL doesnt support it.

A vendor has interest in one or more topics and is interested in tracking all users who are blurting about a topic of interest. A vendor may also have a celebrity as its brand ambassador. Vendors create advertisements that have an associated unique id and a textual content. These advertisements are stored in the system and are available to be shown to the regular set of users (that is, not to the celebrities, just to the other regular users). Careful matching is done based upon a historical analysis of all blurts by a user. Based upon the analysis, a user may be shown zero or more advertisements.

SCHEMA:

user (email, password, name, date_of_birth, address, type)

celebrity (email, website, kind)

blurt (blurtid, email, text, location, time) foreign key(email) references user(email)

hobby (email, hobby) foreign key(email) references user(email))

follow (follower,followee) foreign key(follower) references user(email), foreign key(followee) references user(email))

vendor (id, name)

vendor_ambassador (vendorid, email) foreign key(email) references user(email), foreign key(vendorid) references vendor(id))

topic (id, description)

vendor_topics (vendorid,topicid) foreign key(vendorid) references vendor(id), foreign key(topicid) references topic(id))

blurt_analysis (email,blurtid,topicid,confidence,sentiment) foreign key(email,blurtid) references blurt(email,blurtid), foreign key(topicid) references topic(id)

advertisement (id, content, vendorid) foreign key(vendorid) references vendor(id))

user_ad (email,adid) foreign key(email) references user(email), foreign key(adid) references advertisement(id))

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Datacasting How To Stream Databases Over The Internet

Authors: Jessica Keyes

1st Edition

007034678X, 978-0070346789

More Books

Students also viewed these Databases questions

Question

Identify the different methods employed in the selection process.

Answered: 1 week ago

Question

Demonstrate the difference between ability and personality tests.

Answered: 1 week ago