(Data-Manipulation Application for the books Database) Define a data-manipulatio
ID: 3825792 • Letter: #
Question
(Data-Manipulation Application for the books Database) Define a data-manipulation application for the books database. The user should be able to edit existing data and add new data to the database (obeying referential and entity integrity constraints). Allow the user to edit the database in the following ways: a) Add a new author. b) Edit the existing information for an author. c) Add a new title for an author. (Remember that the book must have an entry in the AuthorISBN table.). d) Add a new entry in the AuthorISBN table to link authors with titles.Explanation / Answer
Solution:
I'll define the DML in SQL,
i)
INSERT INTO Author (Name, AuthorID, Address)
VALUES ('xyz', '123', 'abc')
ii)
UPDATE Author SET Name= 'Batman', Address= 'Wayne Mansion'
WHERE AuthorID= '123'
iii)
We can use two queries in order to fulfill this requirement, first we will enter the New title with details of the book in AuthorISBN table. Then we can define AuthorID as foreign key in the
INSERT INTO AuthorISBN (Title, ISBN, Domain, Price, AuthorID)
VALUES ('Introduction to SQL', '564124BC12', 'Computer Science', '120', '123')
ALTER TABLE AuthorISBN
ADD FOREIGN KEY (AuthorID) REFERENCES Author(AuthorID);
d)
ALTER TABLE AuthorISBN
ADD FOREIGN KEY (AuthorID) REFERENCES Author(AuthorID);
I hope this helps. Don't forget to give a thumbs up if you like this.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.