In: Computer Science
Consider the following data.
Boardgames |
||||
ID |
name |
price |
manuf_id |
|
3234 |
Monopoly |
60 |
HB |
|
2244 |
Settlers of Catan |
45 |
MF |
|
2389 |
Catan: Seafarers |
20 |
MF |
|
4211 |
Carcassonne |
55 |
VG |
|
4383 |
Citadels |
35 |
HB |
|
4450 |
Pandemic |
55 |
VG |
|
Manufacturer |
|||
ID |
name |
founded |
|
HB |
Hasbro |
1997 |
|
MF |
Mayfair Games |
1982 |
|
VG |
Ventura Games |
2005 |
Answer the following:
Data definition language (DDL) statements let you to
perform these tasks:
1. Create, alter, and drop schema objects.
2. Grant and revoke privileges and roles.
3.Analyze information on a table, index, or cluster.
4. Establish auditing options.
5. Add comments to the data dictionary.
Since the question asks only to create the structure of
the table using SQL DDL and we can clearly see manuf_id is FOREIGN
KEY in table Boardgames taking REFERENCE from ID column of table
Manufacturer. Therefore we need to create Manufacturer before
creating table Boardgames.
Hence, we will use CREATE TABLE statement in order as
follows:-
CREATE TABLE Manufacturer(
ID varchar(2) PRIMARY KEY,
name varchar(20),
founded int(4)
);
CREATE TABLE Boardgames(
ID int(4) PRIMARY KEY,
name varchar(20),
price int(2),
manuf_id varchar(2),
FOREIGN KEY (manuf_id) REFERENCES Manufacturer (ID)
);
Hope this solves your Query.....