You need to add a FOREIGN KEY constraint to the line_item_id column in the curr_order table to refer to the id column in the line_item table.
Which statement should you use to achieve this result?
| A. |
ALTER TABLE curr_order ADD CONSTRAINT curr_order_fk FOREIGN KEY (line_item_id) REFERENCES line_item(id); |
|
| B. |
ALTER TABLE curr_order MODIFY (CONSTRAINT curr_order_fk FOREIGN KEY (line_item_id) REFERENCES line_item(id)); |
|
| C. |
ALTER TABLE line_item ADD CONSTRAINT line_item_fk FOREIGN KEY (id) REFERENCES curr_order(line_item_id); |
|
| D. |
ALTER TABLE line_item MODIFY (CONSTRAINT line_item_fk FOREIGN KEY (id) REFERENCES curr_order(line_item_id); |
Ans)
a)
ALTER TABLE curr_order ADD
CONSTRAINT curr_order_fk FOREIGN KEY (line_item_id) REFERENCES line_item(id);
_____________________Thank You
You need to add a FOREIGN KEY constraint to the line_item_id column in the curr_order table...
1> Alter Table Department_JCS 2> Add Constraint Department_fk 3> Foreign Key (ManagerSSN) References Employee_JCS(EmployeeSSN) 4> GO Msg 547, Level 16, State 1, Server DESKTOP-54BQ7EN\LOCALDB#743D77CD, Line 1 The ALTER TABLE statement conflicted with the FOREIGN KEY constraint "Department_fk". The conflict occurred in database "master", table "dbo.Employee_JCS", column 'EmployeeSSN'. How can I get rid of this problem and make a foreign key to with the given variables? Am I making a syntax error or is it something else?
1.Imposing a foreign key constraint on the column of a table prevents that column from having null values; thus, the NOT NULL constraint does not have to be added for that column to assure it is not null. True False 2. A condition is part of a CHECK constraint. A condition consists of which universal computing pattern? a. expression - logical operator - expression b. condition - comparison operator - condition c. expression - comparison operator - expression 3. You...
7- The values of a Foreign Key column in a table can be referenced to any column in a second table (Primary key or non-primary key). TRUE FALSE) 8- Using WITH GRANT OPTION clause will result in granting the user the authority to pass ONLY his/her privileges to other users. TRUE FALSE ) 9. To change the characteristics of a column, use the ALTER TABLE command with a SET clause. TRUE FALSE) 10- When inserting new values into a table...
CREATE TABLE Gender ( gender CHAR(1), description VARCHAR(10), PRIMARY KEY (gender) ); CREATE TABLE People ( ID INT, name VARCHAR(50), gender CHAR(1), height FLOAT, PRIMARY KEY (ID), FOREIGN KEY (gender) REFERENCES Gender (gender) ); CREATE TABLE Sports ( ID INT, name VARCHAR(50), record FLOAT, PRIMARY KEY (ID), UNIQUE (name) ); CREATE TABLE Competitions ( ID INT, place VARCHAR(50), held DATE, PRIMARY KEY (ID) ); CREATE TABLE Results ( peopleID INT NOT NULL, competitionID INT NOT NULL, sportID INT NOT NULL,...
SQL CHECK CONSTRAINT AND TEST CASE... SQL Query Here are the tables: CREATE TABLE Movies( movieID INT, name VARCHAR(30) NOT NULL, year INT, rating CHAR(1), length INT, totalEarned NUMERIC(7,2), PRIMARY KEY(movieID), UNIQUE(name, year) ); CREATE TABLE Showings( theaterID INT, showingDate DATE, startTime TIME, movieID INT, priceCode CHAR(1), PRIMARY KEY(theaterID, showingDate, startTime), FOREIGN KEY(theaterID) REFERENCES Theaters, FOREIGN KEY(movieID) REFERENCES Movies ); CREATE TABLE Tickets( theaterID INT, seatNum INT, showingDate DATE, startTime TIME, customerID INT, ticketPrice NUMERIC(4,2), PRIMARY KEY(theaterID, seatNum, showingDate, startTime)...
CREATE TABLE GLAccounts ( AccountNo INT, AccountDescription VARCHAR(50), -- CONSTRAINT GLAccounts_PK PRIMARY KEY(AccountNo), -- CONSTRAINT AccountDescription_NULL CHECK(AccountDescription IS NOT NULL), -- CONSTRAINT AccountDescription_Zero_LEN CHECK(LEN(AccountDescription)>0) ); GO ----------------------------------------------------------------------------- CREATE TABLE Terms ( TermsID INT, TermsDescription VARCHAR(50), TermsDueDays SMALLINT, -- CONSTRAINT PK_Terms PRIMARY KEY(TermsID), -- CONSTRAINT TermsDescription_NULL CHECK(TermsDescription IS NOT NULL), CONSTRAINT TermsDueDays_NULL CHECK(TermsDueDays IS NOT NULL), -- CONSTRAINT TermsDescription_zero_LEN ...
Lesson 10Create the DEPARTMENT tables based on the following: Column Name ID Name Data Type Number Varchar2 Length 7 25 Populate the DEPARTMENT table with data from the DEPT table. Include only columns that you need. Create the EMPLOYEE table based on the following table chart: Column Name ID LAST_NAME FIRST_NAME DEPT_ID Data Type Number Varchar2 Varchar2 Number Length 7 25 25 7 Modify the EMPLOYEE table to allow for longer employee last names. Confirm your modification. Confirm that both the...
Utilize the JigSaw SQL file below to create a Star Schema diagram. Remember, to create a Star Schema from a normalized data model, you will need to denormalize the data model into fact and dimension tables. The diagram should contain all of the facts and dimension tables necessary to integrate the JigSaw operational database into a data warehouse. Write a brief paper describing the challenges you experienced in completing this assignment. -- CREATE DATABASE js; CREATE TABLE buy_methods ( buy_code...
create table salary (empid int primary key references emp (empid), paygrade varchar(2), amount decimal (10,2), lupdate TIMESTAMP DEFAULT CURRENT_TIMESTAMP, foreign key (empid) references emp (empid)); Use the Salary table above to answer the following question. Add a column to the salary table named position with each person's position as "staff", except for Walton, Shah, Harper who are "manager". ALTER TABLE salary ADD position varchar(32); how do we make the exception for Walton, Shah, Harper to be managers...is it the DEFAULT...
NEED HELP IN INSERT STATEMENTS FOR THE TABLES CAN YOU PLEASE ADD SOME INSERT STATEMENTS FOR A COMPANY SCHEMA SCRIPT. PLEASE ADN THANK YOU DROP TABLE dependent; DROP TABLE works_on; DROP TABLE project; DROP TABLE dept_locations; DROP TABLE department; DROP TABLE employee; CREATE TABLE employee ( fname varchar(15) not null, minit varchar(1), lname varchar(15) not null, ssn char(9), bdate date, address varchar(50), sex char, salary numeric(10,2), superssn char(9), dno numeric, primary key (ssn), foreign key (superssn) references employee(ssn) ); CREATE...