Question

You have been given a univerity business plan that produced the following information: PERSON: lname, fname,...

You have been given a univerity business plan that produced the
following information:
    PERSON: lname, fname, rname, idnum, private, linkblue
        lname, fname, rname are variable length strings
        idnum is type INT and is a key attribute
        private is BOOLEAN
        linkblue is string of 8 characters 

CREATE TABLE PERSON (idnum INT NOT NULL PRIMARY KEY, lname varchar(40), fname varchar(40), rname varchar(40), private BOOLEAN, linkblue char(8) NOT NULL);

    ADVISOR: student, advisor
        student is a foreign key to PERSON.idnum
        advisor is a foreign key to PERSON.idnum

CREATE TABLE ADVISOR (student INT NOT NULL, advisor INT NOT NULL, student_name VARCHAR(40), advisor_name VARCHAR(40), PRIMARY KEY (student, advisor), FOREIGN KEY (student) REFERENCES PERSON (idnum), FOREIGN KEY (advisor) REFERENCES PERSON (idnum));
#10 The student advisor needs a single list of the following:
    "status" where status is the string either "student" or 
    "advisor", fname, lname, email address.  The list should 
    contain all students at most once, and all advisors at most 
    once.  The advisors should be first and the students second.  

    Like:

    +---------+-------+-----------+-----------------+
    | status  | fname | lname     | email           |
    +---------+-------+-----------+-----------------+
    | advisor | Jane  | Mather    | [email protected] |
    | student | John  | Dillinger | [email protected]   |
    | student | Jane  | Mather    | [email protected] |
    +---------+-------+-----------+-----------------+

    Sort by status and lname.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer)
As per the given table, SQL query for listing the student advisor needs a single list of the following "status" where status is the string either "student" or
"advisor", fname, lname, email address:


select "advisor" as status,

Person.fname,

Person.lname,

Person.linkblue as email
from Person inner join ADVISOR
on Person.idnum = ADVISOR.advisor
UNION
select "student" as status,

Person.fname,

Person.lname,

Person.linkblue as email
from Person inner join ADVISOR
on Person.idnum = ADVISOR.student
order by status, Person.lname;


**Please Hit Like if you appreciate my answer. For further doubts on the question or answer please drop a comment, I'll be happy to help. Thanks for posting.**

Add a comment
Know the answer?
Add Answer to:
You have been given a univerity business plan that produced the following information: PERSON: lname, fname,...
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
  • You have been given a univerity business plan that produced the following information: PERSON: lname, fname,...

    You have been given a univerity business plan that produced the following information: PERSON: lname, fname, rname, idnum, private, linkblue lname, fname, rname are variable length strings idnum is type INT and is a key attribute private is BOOLEAN linkblue is string of 8 characters ADDR: idnum, adtype, streetaddr, city, state, country, zip idnum is a foreign key to PERSON.idnum adtype is a string in the set {"bill","permanent","local"} streetaddr is a variable length string that includes #, street, and maybe...

  • You have been given a university business plan that produced the following information: PERSON: lname, fname,...

    You have been given a university business plan that produced the following information: PERSON: lname, fname, rname, idnum, private, linkblue lname, fname, rname are variable length strings idnum is type INT and is a key attribute private is BOOLEAN linkblue is string of 8 characters ADDR: idnum, adtype, streetaddr, city, state, country, zip idnum is a foreign key to PERSON.idnum adtype is a string in the set {"bill","permanent","local"} streetaddr is a variable length string that includes #, street, and maybe...

  • Given the mySQL tables created below...    Create a mySQL solution to return the itemIDs of...

    Given the mySQL tables created below...    Create a mySQL solution to return the itemIDs of items posted by user X, such that all the reviews are “Excellent” or “Good” for these items CREATE TABLE Users (    userId varchar (30) NOT NULL,    pass varchar (30),    fname varchar (50),    lname varchar (50),    email varchar (50),    gender char(1),    age integer,    banned boolean,    PRIMARY KEY (userId),    UNIQUE(email)) CREATE TABLE FavSellers (    userId...

  • Using SQL and the following info Question 3: Find the people who do not have Viper...

    Using SQL and the following info Question 3: Find the people who do not have Viper Certification but are still assigned to Viper class ship Find the fname, lname, and ship_instance_id for all people who do not have Viper certification but are assigned to at least one instance of a Viper class ship (this includes all variants of Viper class ships). Return a row for every ship/person combination. Order your results by fname in ascending order. Use the BSG database...

  • Using SQL and the following info Question 3: Find the people who do not have Viper...

    Using SQL and the following info Question 3: Find the people who do not have Viper Certification but are still assigned to Viper class ship Find the fname, lname, and ship_instance_id for all people who do not have Viper certification but are assigned to at least one instance of a Viper class ship (this includes all variants of Viper class ships). Return a row for every ship/person combination. Order your results by fname in ascending order. Use the BSG database...

  • Based on reference below. Write a relational algebra expression to return those users who have posted...

    Based on reference below. Write a relational algebra expression to return those users who have posted “excellent” reviews but never “poor” reviews. CREATE TABLE Users (             userId varchar (30) NOT NULL,             pass varchar (30),             fname varchar (50),             lname varchar (50),             email varchar (50),             gender char(1),             age integer,             banned boolean,             PRIMARY KEY (userId),             UNIQUE(email)) CREATE TABLE FavSellers (             userId varchar (30),             sellerId varchar (30),             PRIMARY KEY (userId, sellerId),...

  • Database HW help!!!!!!! Provide the SQL statements for the following queries. (1) Provide the names and...

    Database HW help!!!!!!! Provide the SQL statements for the following queries. (1) Provide the names and phones of all swimmers currently in level (of id) 3. +-------+---------+---------------------------+ | FName | LName   | EMail                     | +-------+---------+---------------------------+ | Bobby | Khan    | theBKhan1 | | Clara | Johnson | ClaraJohnson_11 | +-------+---------+---------------------------+ 2 rows in set (0.00 sec) (2) Provide the names of swimmers who have signed up to participate in the event '100M Butterfly' of Meet id 1. +-------+---------+ | FName...

  • SQL Query Question: I have a database with the tables below, data has also been aded...

    SQL Query Question: I have a database with the tables below, data has also been aded into these tables, I have 2 tasks: 1. Add a column to a relational table POSITIONS to store information about the total number of skills needed by each advertised position. A name of the column is up to you. Assume that no more than 9 skills are needed for each position. Next, use a single UPDATE statement to set the values in the new...

  • I need help with the following SQL query for a company database (script given below). The...

    I need help with the following SQL query for a company database (script given below). The name of the Department. The number of employees working in that department. The number of different projects controlled by this department. The name of the project controlled by this department that has the maximum number of employees of the company working on it. The number of the above project. The cumulative sum of the number of employees of the company working on the projects...

  • 9 We want to find out the courses that each student is not enrolled in. Give a listing of the course descriptions, and the students (lname) who are not taking that specific course (Use a cartesi...

    9 We want to find out the courses that each student is not enrolled in. Give a listing of the course descriptions, and the students (lname) who are not taking that specific course (Use a cartesian product and union it with a minus) drop table student_class; drop table student; drop table class; create table student ( ssn char(11) not null, lname varchar(40) not null, fname varchar(20) not null, phone char(12), address varchar(40), city varchar(20), state char(2), zip char(5), dob date,...

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