0% found this document useful (0 votes)
36 views4 pages

DNA Quiz 3

Uploaded by

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

DNA Quiz 3

Uploaded by

Ramandeep Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 4
p ter a 2s CS4.301: Data and Applications (Monsoon 2022) fe Quiz -3 Name: Rowardn? Siege Time: 45 minutes Roll No, 2o2\10'0Se Maximum Marks: 20 QL. Let us consider a Twitter-like setting, with the following specifications. + Users post ‘tweets’, that is short pieces of text. + They may tag their tweets with zero or more tags of their own choice. For example, a user tweeting about Apple's ‘Far Out’ event may decide to use the tag "FarOut’ (prefixed by a ‘sharp’ sign: #FarOut, if we follow the convention by the twitter site). + Auser ’u' may follow zero or more other users, which means that their ‘tweets’ are visible to user 'u’ when he/she logs in. For the above setting, we will use the following schema: + Person (uname, city, street) - Assume the uname is unique. + Follows (uname1, uname2) - Person unamet follows person uname2 + Tweets (tid, ttext) - Tweet with tid has text ttext * PersonTweets (uname, tid, ts) - Person uname posted tweet tid at timestamp ts + TweetTag (tid, tagname) - Tweet tid had tagname in its list of tags. We now want to extract some information from the database. For each of the following questions, give the corresponding SQL query. i. Find all the people (uname) who posted a tweet with tag ‘MODI’. [2 marks] SELECTS UMdyene Fran ene Boum ASF, Teitag oh WT WWMER, —-Teagntiny = 100" YO ii, Find all the different, distinct tags ever used. [2 marks} Stuer * pigmer Joga oO FRM srwetceg -atgggeione Lo Scanned with CamScanner iii, Find all the tags ‘Rahul Gandhi’ ses in his tweets, (i.e, Rahul Gandhi's tweeting interests) [2 marks] Steer“ uname . togrosme FRom Grier as 2 pip TUtTOG OL TT He BoA uname + Sealusgandhi” 'v. Find all the people (uname) whose reading and tweeting interests do not intersect, ie, who do not read the tags they write about. [4 marks] Seer name Rom poston ORE TwHEAs OT | euuerag ak Tr WHERE WUE tee, fs sre tagnawne // Eee ey Trragname h ¥- Bonus: Find all pairs of people (uname) with atleast one follower in common, [2 marks] SELECT uname | rare PROM Resim AS Pp wm Forrws aK K wag Runome witeh follow’ ananua a AND were G wnarene Fotos Unanacz “ Scanned with CamScanner QR. Consider a relation R(K, A, B, FK1, FK2) that satisfies al integrity constraints, where K is the key of R, foreign keys PK1 and FK2 refer to primary key K, the domain of attributes A and B are integer values {1, 2, 3, 4, 5} or NULL. For the following parts, select all options that are correct. Part A [2 marks] Which of the following queries can give more rows in the result compared to the following query result? “SELECT * FROM R WHERE K=12: Note: 123 is a value taken from the domain of values of the key attribute K. (at SELECT DISTINCT R2.K, R2.A, R2.B, R2.FK1, R2.FK2 FROM R AS Ri, R2; b, SELECT * FROM R WHERE KIS NULL; \er SELECT * FROM R WHERE PKI IS NULL and FK2 1S NULL; dC SELECT DISTINCT RLK, RLA, RLB, RLFK1, RLPK2 FROM RAS R1, R2 © WHERE R1.A=R2.A; Part B [2 marks] Which of the following queries give the same result? Note: At least two queries give the same result, a. SELECT* FROM R WHERE A=1 AND KIN (SELECT K FROM R. WHERE B=1 AND FK1 IN (SELECT FK1 FROM R WHERE K IS NULL yi b, SELECT * FROM R WHERE FK1 IS NULL; sc SELECT * FROM R WHERE A=NULL AND A=2; La’ SELECT * FROM R AS R4, R2 WHERE R1LK=R2.K AND R2.K

You might also like