Question

Someone please answer all of these. I need these badly. The submission date is knocking at the door.

Experiment 1: SQL data definition and data insertion 46 hours) 1. CREATE TABLE. The database schema consists of the three rel

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Create table S(Sno int Primary Key, Sname varchar(20), Sgender varchar(6), Sage int, Sdepartment varchar(30));

Insert into S(Sno, Sname, Sgender, Sage, Sdepartment)

values(1,'Tom','Male',21,'ECE'),(2,'Mary','Female',20,'EEE'),(3,'John','Male',23,'ECE'),(4,'Rajesh','Male',21,'BioTech'),(5,'Niru','Female',21,'CSc');

Create table courses(Cno int Primary Key, Cname varchar(30), Cpno int, Ccredit int, Foreign Key (Cpno) References courses(Cno));

Insert into courses(Cno, Cname, Cpno, Ccredit)

Values(1, 'Data Structure', 2, 3),(2,'Database',3,4),(3,'Manual Testing',2,1),(4,'Automation Testing',3,5);

Create table Course(Sno int, Cno int, grade int, Foreign Key (Sno) References S(Sno), Foreign Key (Cno) References courses(Cno));

Insert into Course(Sno, Cno, grade)

values(1,1,25),(1,2,80),(3,3,87),(3,4,65),(4,2,75),(4,3,75),(5,3,81),(2,1,69),(1,3,80),(1,4,80),(3,1,87),(3,2,87) ;

/* 1 */

Select a.Sno as SID, a.Sname as 'Student Name' from S a, Course b Where a.Sno = b.Sno And Cno = 1;

/* 1 */ Select a. Sno as SID, a. Sname as Student Name from Sa, Course b Where a. Sno = b.Sno And Cno 1; 100 % Results Mess

/* 2*/

Select a.Sno as SID, a.Sname as 'Student Name'

From S a, Course b, courses c

Where a.Sno = b.Sno And b.Cno = c.Cno

And c.Cname = 'Data Structure';

/* 2*/ Select a. Sno as SID, a. Sname as Student Name From S a, Course b, courses Where a. Sno = b. Sno And b.Cno = c. Cno

/* 3 */

Select distinct a.Sno as SID, a.Sname as 'Student Name'

From S a, Course b

Where a.Sno = b.Sno

And Cno != 1;

/* 3 */ Select distinct a. Sno as SID, a. Sname as Student Name From S a, Course b where a. Sno = b. Sno And no != 1; 100 %

/* 4 */

Select distinct a.Sno as SID, a.Sname as 'Student Name'

From S a, Course b

Where a.Sno = b.Sno

group by a.Sno, a.Sname

Having Count(*) = (Select Count(*) from courses);

/* 4 */ Select distinct a. Sno as SID, a. Sname as Student Name From Sa, Course b Where a. Sno = b. Sno group by a. Sno, a.

/* 5 */

Select c.Sno, avg(c.grade) as 'Average Grade' from Course c,

(Select distinct a.Sno From S a, Course b Where a.Sno = b.Sno group by a.Sno, a.Sname Having Count(*) = (Select Count(*) from courses)) d

where c.Sno = d.Sno And c.Cno = 1 And c.grade < 35

group by c.Sno;

/* 5 */ - Select S.Sno, avg(serade) as Average Grade from Course C, (Select distinct a. Sno From S a, Course b Where a. Sno

Add a comment
Know the answer?
Add Answer to:
Someone please answer all of these. I need these badly. The submission date is knocking at...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Consider the following database and answer the questions below. a) Write the SQL statement the displays...

    Consider the following database and answer the questions below. a) Write the SQL statement the displays the names of the students who have enrolled in the Database Systems course b) Write the SQL statement that displays a list of the students whose names start with 'S' c) Write the SQL statement that displays the Student ID, Student Name, Course ID, and Grade for students that passed at least one course with a grade better than B+ (i.e. A-, A, and...

  • 4. The exams database: The following database contains multiple choice exam questions tables Questions and On...

    4. The exams database: The following database contains multiple choice exam questions tables Questions and On Hons). Each question has a question Tert and each one of the options has and optid, which is an integer representing options A) (optid=1), B) (optid=2), C) (optid=3), etc. as well as the text of the option. The field correct is either Oor 1 and indicates which is the correct option for that particular question. courseThe exams have numbers 1, 2, 3, etc. Each...

  • Consider the following GRADEBOOK relational schema describing the data for a grade book of a particular...

    Consider the following GRADEBOOK relational schema describing the data for a grade book of a particular instructor (Note: The attributes A, B, C, and D store grade cutoffs.) catalog(cno,ctitle) students(sid,fname,lname,minit) courses(term,secno,cno,A,B,C,D) enrolls(sid,term,secno) Specify and execute the following queries using the RA interpreter on the GRADEBOOK database schema. a. Retrieve the names of students enrolled in the ‘Automata’ class in the term of Fall 1996. b. Retrieve the SID values of students who have enrolled in CSc226 as well as CSc227....

  • 10- Specify the following queries in SQL on the database schema of Figure 2. a. Retrieve...

    10- Specify the following queries in SQL on the database schema of Figure 2. a. Retrieve the names of all senior students majoring in ‘CS’ (Computer Science). b. Retrieve the names of all courses taught by Professor King in 2004 and 2005. c. For each section taught by Professor King, retrieve the course number, semester, year, and number of students who took the section. d. Retrieve the name and transcript of each senior student (Class =4) majoring in CS. A...

  • 2. Consider the following database and answer the questions below SPORT ENROLLMENT STUDENT COURSE ST ST...

    2. Consider the following database and answer the questions below SPORT ENROLLMENT STUDENT COURSE ST ST TITLE 313 1313 50s0 Basketbal 8989 Basketbal 007 COMP203A 7007 COMP20e 007 ames Bond 302 Database Systems COMP203 Computer Or n Brown 00 CoMP302 A o0 3un SmuCOMP42daedDatabase Systems 3 13 COMP 209 70 5050 Susan Smith COMP447 nced Database S 1313 COMP2O3A 1313 COMP302 5050 COMP20 C 1313 COMP42 7007 Write the SQL statement that displays the names of the students who have...

  • Find the courses taken by every student who has taken CSE132A. Note that, if no student...

    Find the courses taken by every student who has taken CSE132A. Note that, if no student has taken CSE132A, then all courses should be in the answer. Write the SQL query that uses only NOT EXISTS tests on nested quieries We will use the database schema from the SQL assignment: student sidcourse cid prerequisite cid pre.cid record sid cid qtr year grade Consider the following queries (from the SQL assignment): 2. Find the courses taken by every student who has...

  • Can someone please help me solve the following database management question a - d please help...

    Can someone please help me solve the following database management question a - d please help uestion-4 The relational database schema of Question-3 is reproduced here. COURSE (NUMBER, TITLE, ENROLLED) RANK-1 (CNUMBER, R1-SSN) RANK-2 (CNUMBER, R2-SSN) TALLEST (CNUMBER, TALL-SSN) STUDENT (SSN, NAME, MAJOR, SEX, GPA) Formulate the following queries in soL. (30] (a) List the course numbers in which "Jack Hernandez" is the first ranked student. You are not allowed to use any JOIN operation and your answer must be...

  • SQL Homework Create a single script to do all of the following. Be sure to create...

    SQL Homework Create a single script to do all of the following. Be sure to create in such a way that it can be re-run multiple times. Create a database named homework. In this database, create three tables: Student, Course, StudentCourse - Create the Student table with the following fields in this order: studentID as an integer; do not allow empty values firstName as a variable number of characters, max 30, with a null default value lastName as a variable...

  • Give an example of 3 relations illustrating primary keys and foreign keys. Consider the following relations:...

    Give an example of 3 relations illustrating primary keys and foreign keys. Consider the following relations: Student(sID, surName, firstName, campus, email) Course(dept, cNum, name) 
Offering(oID, dept, cNum, term, instructor)
 Took(sID, oID, grade) Such as: Offering[dept, cNum] ⊆ Course[dept, cNum] Took[sID] ⊆ Student[sID]
 Took[oID] ⊆ Offering[oID] Answer the following query using relational algebra -Give the Student number of all students who have taken the course number “343” by the department “CS”. - Find sID of all students who have earned some...

  • Give the following queries in the relational algebra using the following relational schema: Student (sid, name,...

    Give the following queries in the relational algebra using the following relational schema: Student (sid, name, age, address, email, cgpa) enrolledIn (sid, modulecode, grade) module (modulecode, modulename, credits, lecturername) a) What are the names of students enrolled in module code “cs3020”? b) Give the module code of all the modules that are taught by the teacher named “Altaf”? c) Who teaches the module with code”cs1500”? d) Give the name of all the teachers teaching the student with id”12f6778”.

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT