Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For the below questions, use the following schema definition. account ( accountid , username, firstname, lastname ) digitalasset ( assetid , description, dollarprice ) transaction

For the below questions, use the following schema definition. account (accountid, username, firstname, lastname) digitalasset (assetid, description, dollarprice) transaction (tranid, accountid, timstamp) transactiondetail (tranid, assetid,qty.price) It is a schema for a digital-asset store, with accounts, digitalassets, and transactions that link accounts to digitalassets. Each transaction can have multiple items, which are in transactiondetail table. Pick the best answer that fits the question. Not all of the answers may be correct. If none of the answers fit, write your own answer.
1.(5 points) Find account id of John Doe. (a) select lastname,firstname from account where firstname='John' and lastname='Doe' (b) select accountid from transaction where firstname='John' and lastname='Doe' (c) select accountid from account where firstname='John' and lastname='Doe' (d) select accountid from account inner join transactiondetail using(accountid) where first- name='John' and lastname='Doe' (e) Other:
2.(5 points) Find the average price of a digitalasset. (a) select avg(price) from transactiondetail (b) select avg(dollarprice) from digitalasset (c) select avg(qty*dollarprice) from digitalasset (d) select avg(price) from digitalasset (e) Other:
3.(5 points) Find number of transactions by account. (a) select accountid,count(*) from transaction natural inner join transactiondetail group by accountid (b) select assetid,count(*) from transactiondetail group by assetid (c) select tranid,count(*) from transactiondetail group by tranid (d) select accountid,count(*) from transaction group by accountid (e) Other:
4.(5 points) Find names (descriptions) of all digital assets ever purchased by 'John Doe'. (a) select count(*) from account a natural inner join transaction b natural inner join transac- tiondetail c where a.lastname='Doe' and a.firstname='John' (b) select description from account a natural inner join transaction b natural inner join transac- tiondetail c natural inner join digitalasset d where a.lastname='Doe' and a.firstname='John' group by description (c) select description from account a natural inner join digitalasset d where a.lastname='Doe and a.firstname='John' group by description (d) select distinct description from account a natural inner join digitalasset d where a.lastname="Don and a.firstname='John' (e) Other:
5.(5 points) Find all transactions that total more than $1000.(a) select tranid from transaction a natural inner join transactiondetail b group by tranid having sum(qty*price)>1000 ntials (b) select tranid from transaction a natural inner join transactiondetail b where qty*price >1000 group by tranid (c) select tranid from account a inner join transaction a natural inner join transactiondetail b where qty*price >1000 group by tranid (d) select tranid from transactiondetail b where qty*price >1000(e) Other:
6.(5 points) Find accounts who have never purchased anything. (a) select a.* from account a natural inner join transaction b where b.tranid is null (b) select a.* from account a left join transactiondetail b on a.accountid=b.accountid where b.tranid=0(c) select a.* from account a inner join transaction b on a.accountid=b.accountid where b.tranid >0(d) select a.* from account a natural left outer join transaction b where b.tranid is null (e) Other::
7.(5 points) Find top 10 accounts who spent the most in 2023.(a) select top 10 accountid from transaction a natural inner join transactiondetail b where timstamp >='20230101' and timstamp <'20240101'(b) select accountid from transaction a natural inner join transactiondetail b where timstamp >='20230101' and timstamp <'20240101' order by sum(qty*price) desc (c) select accountid,row_number() over (order by sum(qty*price) desc) rn from transaction a natural inner join transactiondetail b where timstamp >='20230101' and timstamp <20240101' and rn <=10(d) select accountid,sum(qty*price) v from transaction a natural inner join transactiondetail b where timstamp >='20230101' and timstamp <'20240101' group by accountid order by 2 desc limit 10(e) Other:
8.(5 points) What is the most appropriate in (a) Btree Index (b) Bitmap Index (c) Clustered Index account.username field(d) Bitmap Clustered Index (e) Other:
9.(5 points) What is the most appropriate index for digitalasset.description field? pione (a) Btree Index (b) Bitmap Index (c) Clustered Index (d) Bitmap Clustered Index (e) Other:
10.(5 points) What is the most appropriate index for digitalasset.assetid field? (a) Btree Index (b) Bitmap Index (c) Clustered Index (d) Bitmap Clustered Index (e) Other:
11.(5 points) The below code (tip: write out the first few output numbers): yola il coll with recursive n(n) as ( select 2 n union all select n+1 from n where n<1000 berolineas nie goe select a.n from n a left join n b on b.n < sqrt(a.n) group by a.n having a.n-2 or min (a.n % b.n)>0. accounts nick ()((a) Is invalid (b) Will generate a list of number

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_2

Step: 3

blur-text-image_step3

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions

Question

f. Did they change their names? For what reasons?

Answered: 1 week ago