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:
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_PerOrdersFOREIGN KEY (P_Id)
REFERENCES Persons(P_Id)
1)Alter table STATES
2)Add constraint FK_StateCountry
3)Foreign key (Country_Abbr)
4)References COUNTRY (Country_Abbr)
Box 3 is wrong, it must be FOREIGN KEY (Country_Abbr).
Yes you are absolutely right
1)Alter table STATES
2)Add constraint FK_StateCountry
3)Foreign key (Country_Abbr)
4)References COUNTRY (Country_Abbr)
yes, the correct answer is
1)Alter table STATES
2)Add constraint FK_StateCountry
3)Foreign key (Country_Abbr)
1)Alter table STATES
2)Add constraint FK_StateCountry
3)Foreign key (Country_Abbr)
4)References COUNTRY (Country_Abbr)
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)
Here are some hyperlinks to web sites that we link to due to the fact we think they are really worth visiting.
the time to read or check out the content or web-sites we have linked to below the
Here is a great Blog You may Uncover Intriguing that we Encourage You
the time to study or visit the material or sites we have linked to beneath the
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
here are some hyperlinks to sites that we link to because we think they may be really worth visiting