Question
Asked Oct 25, 2019

What are the SQL commands to create TABLE BOOK, that includes  both primary and foreign keys, with the attached image and sql commands below?? **Below is missing foreign key command and need help to identify.

 

mysql> CREATE TABLE BOOK

->(BOOK_CODE CHAR(4) PRIMARY KEY,

->TITLE CHAR(40),

->PUBLISHER_CODE CHAR(3),

->TYPE CHAR(3),

-> PRICE DECIMAL(4,2)

->PAPERBACK CHAR(1) );

BOOK
Length
Decimal
Туре
Nulls
allowed?
Description
Column
places
Text
CHAR
4
No
Book code
BOOK CODE
(primary key)
CHAR
40
Book title
TITLE
CHAR
3
Publisher code
PUBLISHER CODE
3
CHAR
Book type
TYPE
Book price
DECIMAL
4
2
PRICE
CHAR
Paperback (Y. N)
1
PAPERBACK
help_outline

Image Transcriptionclose

BOOK Length Decimal Туре Nulls allowed? Description Column places Text CHAR 4 No Book code BOOK CODE (primary key) CHAR 40 Book title TITLE CHAR 3 Publisher code PUBLISHER CODE 3 CHAR Book type TYPE Book price DECIMAL 4 2 PRICE CHAR Paperback (Y. N) 1 PAPERBACK

fullscreen
check_circleExpert Solution
Step 1

Primary key:

A PRIMARY KEY is used to uniquely define every tuple in a table. The PRIMARY KEY imposes constraints on the table's integrity Only one PRIMARY KEY can be allowed in a table. No duplicate or NULL values are allowed by the primary key.

Column_Name Data Type PRIMARY KEY;

Foreign key:

A FOREIGN KEY in one table corresponds to the PRIMARY K...

Want to see the full answer?

See Solution

Check out a sample Q&A here.

Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour*

See Solution
*Response times may vary by subject and question
Tagged in

Engineering

Computer Science

Related Computer Science Q&A

Find answers to questions asked by student like you

Show more Q&A add
question_answer

Q: Using MIPS assembly language can someone help me write a program that does .. Write a program to fin...

A: Program Instructions:Ask the user for number of integers and get those integers.Load the array, redu...

question_answer

Q: define an array of 100 ints, and write a loop ( including the body) to initialize every element in t...

A: The program code is written in C programming as in the given question no programming language is spe...

question_answer

Q: Find the truth table that describes the following circuit.

A: The diagram shown below is taken from the given question- 

question_answer

Q: in Python using IDLE   Now write another program that reads her inventory file, displays all data fo...

A: A Python program to display the data for each item in an inventory is given below;Program:#Print the...

question_answer

Q: Create reports containing the following details from the database: Q1 How many books are there in th...

A: SELECT category, count(category) AS "numberOfBooks",FROM booksWHERE category='computer'; The above q...

question_answer

Q: What are the different companies providing NOS- Network Operating System?

A: A network operating system is basically an operating system which is developed to support PCs, works...

question_answer

Q: Hello good afternoon,   Write a C++ program that reads data from an input file, takes the data and c...

A: Program designcreate two functions for printing name, and computing and printing graderead data from...

question_answer

Q: Are the following two clauses the same: constraint X primary key (Y, Z) and constraint X primarykey ...

A: Primary key:Primary key is a key which is used to uniquely identify a row in a table.A Primary key c...

question_answer

Q: Design a reasonably efficient algorithm for solving each of the following problems and determine its...

A: AlgorithmLet x be one of the numbers and the other number is n-x. The first step is to maximize f(x)...