Related questions
Solve B
I. This Project asks you to submit a SQL text file (e.g. project2.sql) with all your answers to all the questions listed in this assignment. Your answers will be written in SQL format. All SQL statements will be tested in a MySQL
STUDENT(StudentID, LastName, FirstName, Address, City, State, Zip, Phone)
- StudentID will be automatically increased integer identifier
- Choose VARCHAR or CHAR based on your personal understanding of the fields for the rest part of the relation/table
STUDENT_TEXTBOOK(StudentID, TextbookID, Class, Semester, Year)
- Semester would be CHAR
- Year would be integer
TEXTBOOK(TextbookID, Description, Price, Location, BookstoreID)
- TextbookID will be automatically increased integer identifier
- Price is a decimal with 2 decimal places after zero
- Description and Location can be VARCHAR or CHAR based on your personal understanding of the fields
BOOKSTORE(BookstoreID, Name, Address, City, State, Phone)
- BookstoreID will be automatically increased integer identifier
- Choose VARCHAR or CHAR based on your personal understanding of the fields for the rest part of the relation/table
SALES(SalesID, StudentID, TextbookID, NumberofPurchase, SalesDate)
- NumberofPurchase is number of copies purchased
NOTE:
- You must use MySQL.
- Create tables with columns, data types and populate your own data
- Underscore represents a part of a primary key
- Underscore and italic represent both part of the primary key and foreign key.
- Italic represent foreign key
II. PLACE ANSWERS in a text file (e.g. project2.sql) NOT A WORD DOC
A. List the 5 DDL "CREATE TABLE" statements including the primary keys. (10 points)
B. List any DDL statements that add the foreign key(s) constraints using "ALTER TABLE". (10 points)
C. List at least 3 DDL INSERT statements (per table) to populate data in all 5 tables. (10 points)
D. Write a separate SQL query for each of the 10 questions below. (70 points)
1. List all Student LAST and FIRST NAMES who are from a city starting with a selected word with at least two letters long.
2. List all Student IDs who have textbook sales totals greater than a selected value.
3. List the last name, first name, and phone of the Students who made a purchase with three selected SalesIDs. Use a subquery.
4. Answer the previous question but use an inner join.
5. List all student names and phone numbers. If they had purchased textbooks in the year 2012, then list the textbook descriptions. Otherwise, allow the textbook description to be null. You can use the default data format DD-MON-YY. (Hint: you will use a left outer join.)
6. List last name, first name, and phone of students who have purchased a textbook that has a price greater than a given number/value. (Use subquery).
7. Rewrite the last questions using an inner join and alias for table names.
8. List last name, first name, and phone of Students who have purchased a Textbook that was supplied by a bookstore with a name that begins with a given English letter. (Use subquery).
9. Rewrite the previous question using an inner join of the tables and alias for table names.
10. List the total "sum" of textbook prices for each student in descending order by last name and first name, class, textbook description AND total purchases for a given year. Use an inner join for the tables. NOTE: The business rule for the STUDENT_TEXTBOOK table assumes that a student will only purchase one textbook at a time.
Achha Thank You.
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps
- Using php and sql: create a query and any supporting PHP code that will output only messages from the user named "Abla".arrow_forwardSQL CODE FOR For the players who show up in Batting, Bowling, and Fielding tables, create a list that shows their names, runs they have scored, wickets they have taken, and catches they have taken? table is in picture (bowling table is same as batting and fielding )arrow_forwardCreate a stored procedure that will return the number of customers in a given state. The parameter for your stored procedure should accept the state abbreviation ('UT') and return the results of a query that returns the number of customers in that state.arrow_forward
- SQL A table Products have: a name (TEXT) a description (TEXT) a unit cost stored in cents (INTEGER) and of course we also add an id column to identify them. Separately, we'd like to track the number of items in stock for each product. To do so we'll have a store and an inventory table. Stores have just an id and a name. Then, our inventory table should combine stores and products, listing how much of each product each store has in stock. a product_id (INTEGER) a store_id (INTEGER) a quantity (INTEGER) in stock Now we can insert some stores, products and inventory into our database. There are 2 stores -- one called NY and one called NJ. There are 2 products we are concerned with. Their names are sneakers, costing 220ドル (remember this is dollars!) and boots costing 350ドル. Use any description for each that you'd like. NY has 4 sneakers in stock and 3 boots. NJ has 5 sneakers in stock and no boots. Insert the above data into the tables you have created.arrow_forwardINFO 2303 Database Programming Assignment : PL/SQL Practice Note: PL/SQL can be executed in SQL*Plus or SQL Developer or Oracle Live SQL. Write an anonymous PL/SQL block that will delete all patients for doctors that works in the Family Practice Verify that patients have been deleted accordingly. Then do a select * from patients where doc_id = (select doc_id from doctor where area = ‘Family Practice’. You should get no rows.arrow_forwardSQL ( ORACLE SQL DEVELOPER ) : THIS IS FIRST , SECOND AND THIRD TABLE for the Task 1 to solve : create table author_45( auth_name char(50), gender char(1), age number(3), nationality char(50), PRIMARY KEY (auth_name) ); create table book_45( isbn number(10), title char(50), ver_no number(2), publisher char(50), PRIMARY KEY (isbn) ); create table writtenBy_45( isbn number(10), auth_name char(50), yr_published number(4), price number(3), no_copy number(4), PRIMARY KEY (isbn,auth_name), foreign key (isbn) references book_45, foreign key (auth_name) references author_45 ); insert into author_45 values ('Benoit','F',42,'French'); insert into author_ 45 values ('Antonini','M',33,'Italian'); insert into author_ 45 values ('McAven','F',31,'Australian'); insert into author_ 45 values ('Williams','M',90,'British'); insert into book_45 values (101,'atabases',1,'Possum'); insert into book_45 values (202,'SQL Primer',2,'Hall'); insert into book_45 values...arrow_forward
- I need SQL code for the following question: - Use MYSQL for coding Create a MySQL table named 'prime_test' that contains two columns. The first column is an integer named 'number' that is the primary key and cannot be NULL. The second column is a variable length string named 'is_prime' with a maximum length of 50. Write one or more insert statements that fills only the 'number' column of table 'prime_test' with the integers between 2 and 100. Write one or more update statements that sets the 'is_prime' column for each associated integer. For a prime, the column should read 'prime'. For non-primes, the column should read 'composite'. Write a final select statement to return only the 'number' column from 'prime_test' for records that are prime, ordered from largest to smallest.arrow_forwardThis assignment is aimed at building an understanding of how to improve performance within databases by taking advantage the computers hardware by modifying MS SQL settings Prerequisites: Completion of Assignment 1B, reading of Module Readings and Slides. Run the following query to understand how much Memory is currently in use in the database: SELECT physical_memory_in_use_kb/1024 AS sql_physical_memory_in_use_MB, large_page_allocations_kb/1024 AS sql_large_page_allocations_MB, locked_page_allocations_kb/1024 AS sql_locked_page_allocations_MB, virtual_address_space_reserved_kb/1024 AS sql_VAS_reserved_MB, virtual_address_space_committed_kb/1024 AS sql_VAS_committed_MB, virtual_address_space_available_kb/1024 AS sql_VAS_available_MB, page_fault_count AS sql_page_fault_count, memory_utilization_percentage AS sql_memory_utilization_percentage, process_physical_memory_low AS sql_process_physical_memory_low, process_virtual_memory_low AS...arrow_forwardUsing php and sql: Create a PDO object to connect to your database for running select queries.Write a database query to output all the messages in the messages table.arrow_forward
- calculate_new_balance Given a starting balance (a number), and a list of transaction tuples, calculate the final balance for an account. Transaction tuples are of the shape ("description", amount, "withdrawal") , or ("description", amount, "deposit"). The last entry in the tuple will be either "withdrawal" or "deposit". Every withdrawal decreases the balance of the account by the specified amount, and every deposit increases the balance. The return value is the new account balance, as a number. (which could be negative) Sample calls should look like: >>> calculate_new_balance(100, [("payday", 20, "deposit"), ("new shoes", 50, "withdrawal"), ("illicit winnings", 200, "deposit")])270>>> calculate_new_balance(100, [])100arrow_forwardTask 3: The Marketing team wants to collect emails of the users on InstantStay. However, the team needs a SQL statement to execute inside their programming environment. You need to create a statement that they can easily run the EXECUTE command to return a single column table containing the USER_EMAIL addresses. Task: Create a prepared statement for use with the EXECUTE command.arrow_forward
- Text book imageComputer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONText book imageComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceText book imageNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Text book imageConcepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningText book imagePrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationText book imageSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY