You need to set up a rule that every STATE.Country_Abbr must match an existing record in the COUNTRY table

DRAG DROP
You have two existing tables, one named COUNTRY and the other named STATES.
The tables are defined as follows:

You need to set up a rule that every STATE.Country_Abbr must match an existing record in
the COUNTRY table.
Develop the solution by selecting and arranging the required code blocks in the correct order.
You may not need all of the code blocks.

DRAG DROP
You have two existing tables, one named COUNTRY and the other named STATES.
The tables are defined as follows:

You need to set up a rule that every STATE.Country_Abbr must match an existing record in
the COUNTRY table.
Develop the solution by selecting and arranging the required code blocks in the correct order.
You may not need all of the code blocks.

Answer: See the explanation.

Explanation:

Box 1:

Box 2:

Box 3:

Box 4:

Note:
To allow naming of a FOREIGN KEY constraint, and for defining a FOREIGN KEY constraint
on multiple columns, use the following SQL syntax:
MySQL / SQL Server / Oracle / MS Access:
ALTER TABLE Orders
ADD CONSTRAINT fk_PerOrders

FOREIGN KEY (P_Id)
REFERENCES Persons(P_Id)



Leave a Reply 14

Your email address will not be published. Required fields are marked *


zzz

zzz

1)Alter table STATES
2)Add constraint FK_StateCountry
3)Foreign key (Country_Abbr)
4)References COUNTRY (Country_Abbr)

annonymous

annonymous

Box 3 is wrong, it must be FOREIGN KEY (Country_Abbr).

Mido

Mido

Yes you are absolutely right

WK

WK

1)Alter table STATES
2)Add constraint FK_StateCountry
3)Foreign key (Country_Abbr)
4)References COUNTRY (Country_Abbr)

Gerry

Gerry

yes, the correct answer is

1)Alter table STATES
2)Add constraint FK_StateCountry
3)Foreign key (Country_Abbr)

Gerry

Gerry

1)Alter table STATES
2)Add constraint FK_StateCountry
3)Foreign key (Country_Abbr)
4)References COUNTRY (Country_Abbr)

SQLCzar

SQLCzar

ALTER TABLE states
ADD CONSTRAINT FK_state_country
FOREIGN KEY (country_abbr)
REFERENCES country(country_abbr)

create table country(
sno int primary key,
country_abbr int)

CREATE UNIQUE NONCLUSTERED INDEX [IX_country] ON [dbo].[country]
(
[country_abbr] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO

create table states(
sno1 int primary key,
country_abbr int)

CREATE UNIQUE NONCLUSTERED INDEX [IX_states] ON [dbo].[states]
(
[country_abbr] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO

ALTER TABLE states
ADD CONSTRAINT FK_state_country
FOREIGN KEY (country_abbr)
REFERENCES country(country_abbr)

Google

Google

Here are some hyperlinks to web sites that we link to due to the fact we think they are really worth visiting.

app builder

app builder

the time to read or check out the content or web-sites we have linked to below the

Cash for cars

Cash for cars

Here is a great Blog You may Uncover Intriguing that we Encourage You

how to make money from home

how to make money from home

the time to study or visit the material or sites we have linked to beneath the

mirar a este sitio

mirar a este sitio

although sites we backlink to beneath are considerably not connected to ours, we really feel they are truly really worth a go through, so have a look

プラセンタ

プラセンタ

Sites of interest we have a link to

Gossip Lanka Hot News

Gossip Lanka Hot News

here are some hyperlinks to sites that we link to because we think they may be really worth visiting