(TCO 4) A Calls entity in a relational database for tracking a telemarketing cam
ID: 3596764 • Letter: #
Question
(TCO 4) A Calls entity in a relational database for tracking a telemarketing campaign has the following attributes: CallID (the primary key, an integer number, required), CalledNumber (text, maximum 10 characters, required), CallDateTime (date/time of the call), OperatorID (integer number, a foreign key referencing the primary key in the Operators table).
(a) Write an SQL Data Definition Language command to create the table for this entity.
(b) Write an SQL Data Definition Language command to add a column for a new attribute to this table: CallDuration (duration of the call in seconds, an integer number, required).
(c) Write an SQL Data Definition Language command to remove this table from the database.
Explanation / Answer
1.Creating a Table
CREATE TABLE Telemarketing(
CallID int NOT NULL,
CalledNumber varchar(10),
CallDateTime datetime,
OperatorID int,
PRIMARY KEY (CallID),
FOREIGN KEY (OperatorID) REFERENCES Operator(OperatorID)
);
Note: A FOREIGN KEY is a key used to link two tables together.
It is a field (or collection of fields) in one table that refers to the PRIMARY KEY in another table.
2.To add a column for a new attribute to This Table.
ALTER TABLE Telemarketing
ADD CallDuration number(10);
3.To Remove The Table from The Database
DROP TABLE Telemarketing;
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.