A foreign key is used to connect two tables.The foreign key in one table references the primary key of the another table( some case it can refer the primary key of the same table also).The table containing the primary key is parent and table containg the foreign key is child table.
FOREIGN KEY (PersonID) REFERENCES Persons(PersonID);
First PersonID is the foreign key column in the child table and Persons is the parent table .Persons(PersonID) indicates the primary key of parent table.
eg.CREATE TABLE Order (
Oid int NOT NULL,
Ono int NOT NULL,
PersonID int,
PRIMARY KEY (Oid),
FOREIGN KEY (PersonID) REFERENCES
Persons(PersonID)
);
The value of the foreign key either one of the value present in the parents tables primary column or it can be null.
1. The table being created must have a column named personid
True
2. The create table will fail because 2 tables can not have a field with the named personid
False
3. personid in this table must be unique.
false
foreignkey need not be unique.the only constraint is it must have value that is either present in parent table or it can be null.
4. There must be a different table named persons previously created
True
Since we are creating a link ,the parent table must be present before creating the foreign key references.
If the following appeared in a CREATE TABLE statement FOREIGN KEY (PersonID) REFERENCES Persons(PersonID) true false...
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,...
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...
A foreign key value must exist in the table where it is a primary key. True? False?
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...
Help Save & En s the following statement correct (true) or incorrect (false)j? with Big Data because querying related Tables (le. tables that are linked using Primary and Foreign Key Relationship containing Big Data requires more secondary memory than what current computers can support." True or Faise True False < Prey 25 of 2SⅢ Next> for working with large Data in tables within relational database MacBook Pro 5 6 8 9 0 0
Help Save & En s the following...
8.
True or False?
8.The primary key of the Employees table would be posted in the
Production Steps table as a foreign key.
26.The primary key of the Production Steps table would be posted
in the Production Plan table as a foreign key.
39. The link between the Products and Production Plan tables
would be implemented as a linking table.
0.. Materials Production Steps 0... 0.. Production Plan Employees 0..* 1..1 1..1 Products are Products 0.. Production 0..* Authorization develope.
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?
The employee is table, the best candidate for primary key is Select one: a. Department ID b. Employee hiredate c. Employee ID d. Employee salary Question 2 A primary key can be composed of more than one attribute. Select one: True False Question 3 A foreign key allows you to join two tables. Select one: True False Question 4 Given two tables, department (dept_id, dept_location, dept_name) and EMPLOYEE(emp_id, emp_name, emp_dept_id, emp_name, emp_salary), which attribute (column) is the foreign key? Select...
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...
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)...