Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
What are the SQL statements that will produce the tables and columns identified below (including relationships/keys/constraints)? Also, could you tell me the SQL statements to populate at least 5 records in each of the tables?
Thanks!!
Book
- book_id (primary key)
- title
- author_id (foreign key to Author table)
- year_of_release
- number_of_pages
- genre
- location (in library, checked out)
Author
- author_id (primary key)
- name
Customer
- customer_id (primary key)
- name
- age
- phone_number
- join_date
BookCheckout
- book_id (foreign key to Book table)
- customer_id (foreign key to Customer table)
- checkout_date
- due_date
- return_date
Relationships:
- Book to Author (one-to-many)
- Book to Customer (many-to-many)
- Customer to BookCheckout (one-to-many)
Keys and Constraints:
- Primary keys:
- book_id (Book table)
- author_id (Author table)
- customer_id (Customer table)
- Foreign keys:
- author_id (Book table) -> author_id (Author table)
- book_id (BookCheckout table) -> book_id (Book table)
- customer_id (BookCheckout table) -> customer_id (Customer table)
- Constraints:
- A book cannot have more than one checkout record at a time.
- A customer cannot check out more than one copy of the same book at a time.
Expert Solution
arrow_forward
Step 1: Introduction
This qus is from the subject SQL . Here we have to put light on the three important type of queries. These queries will be based on all Table creation, putting constraints as per the given instructions and inserting values into the created tables. All this work is done in the following steps.
Step by stepSolved in 3 steps with 1 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Write the sql ddl statments for books relational database. Specify data types, also keys and referntial integrityarrow_forward1.What is the result when the following SQL query is executed on a table named products? Choose the most correct answer. SELECT AVG(Products)FROM Products; Group of answer choices The query results in an error because the is no AVG function None of the above The query results in an error be cause a column is not specified The query returns the average of the Products table 2. If the primary key in the Employee table is located in the "ID" column what is the maximum number of results the following SQL SELECT query will return? SELECT *FROM EmployeeWHERE ID = 15; Group of answer choices 2 1 3 Do not have enough information to determine the answer 0arrow_forwardCreate a SQL statement in MariaDB with the following columns and their aliases from the Employees table. Aliases should be created as seen including case sensitive. (A full statement is required, but doesnt need to be run with an output) Screenshot the code ONLY and attach. last_name - Name street_address - Local Address phone_number - Phone #arrow_forward
- Use your ERD to define the table structures in the database using SQL DDL commands to build your schema.arrow_forwardThank you for helping! Write the SQL code to produce the total number of hours and charges for each of the projects represented in the ASSIGNMENT table. The result is shown as below. Write the SQL code to display the information of employees who are working as either programmer or system analyst. Write the SQL code to produce job_descriptions(job_title) of employees who are working at project ‘Evergreen’.arrow_forwardUSE this part to write SQL statements at the bottom questions 1-11 Branch(branch_id:integer, branch_name:varchar(50), branch_location:varchar(40), money_on_hand:numeric(15,2) create table Branch (branch_id integer, branch_name varchar(50), branch_location varchar(40), money_on_hand numeric(15,2), primary key (branch_id)); Loan(loan_number:integer, branch_id:integer, amount:numeric(8,2)) foreign key branch_id references Branch(branch_id) create table Loan (loan_number integer, branch_id integer, amount numeric(8,2), primary key (loan_number), foreign key (branch_id) references Branch (branch_id)); Customer(customer_id:integer, customer_last_name:varchar(35),customer_first_name:varchar(25), customer_street:varchar(30),…arrow_forward
- I want to write the SQL to create the tables for the ERD attached, but I also want to add this to the tables: rental date, due date, and return date so that I can support overdue queries. I also want it so each table has primary keys and foreign keys. I want it so the tables have at least 4 rows of data. How can I do this? Thank you for your help as I learn more about SQL and table creation.arrow_forwardI need help with this question for my Database Management class for SQL developer. Thank you REP (REP_NUM, LAST_NAME, FIRST_NAME, STREET, CITY, STATE, POSTAL_CODE, COMISSION, RATE) CUSTOMER (CUSTOMER_NUM, CUSTOMER_NAME, STREET, CITY, STATE, POSTAL_CODE, BALANCE, CREDIT_LIMIT, REP_NUM) ORDERS (ORDER_NUM, ORDER_DATE, CUSTOMER_NUM) ORDER_LINE (ORDER_NUM, ITEM_NUM, NUM_ORDERED, QUOTED_PRICE) ITEM (ITEM_NUM, DESCRIPTION, ON_HAND, CATEGORY, STOREHOUSE, PRICE) Question: List TOY category items and orders placed for them. Report: Item_Num, Description, Order_Num, and Order_Datearrow_forwardGiven the following schema, answer the following questions USERS Attribute Data Type USER_ID NUMBER(3) USER_NAME VARCHAR2(20) USER_TYPE VARCHAR2(10) USER_LIMIT NUMBER(1) BOOKS Attribute Data Type BOOK_ID NUMBER(5) BOOK_TITLE VARCHAR2(25) BOOK_YEAR VARCHAR2(4) Write the SQL code that will create the tables structures for the tables named Books, and Users. Identify and include any PK and FK for both tables.arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education