Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a python function that is going to generate and return a SQL INSERT statement given a table name and value list as parameters. We

image text in transcribed
Write a python function that is going to generate and return a SQL INSERT statement given a table name and value list as parameters. We have not covered SQL yet, so you don't need to run the insert statements, just get your python code to return the required string: For example, print(generateinsert('Students', ['1', 'Jane', 'A+"])) should print INSERT INTO Students VALUES (1, Jane, A+); All statements start from INSERT INTO, followed by the name of the table, followed by VALUES and the comma-separated list of supplied values inside parentheses, terminated by a semi-colon Make sure that your function returns the string rather than prints it. If you are interested in additional coding challenge, modify your function to instead return (this modification is not required): INSERT INTO Students VALUES (1, 'Jane', 'A+"); (i.e., put quotes around strings, but not around numbers). Another example: generateInsert('Phones', ['42', '312-555-1212']) should return INSERT INTO Phones VALUES (42, 312-555-1212); You can assume that every entry in the list of values is a string, even if it is a number. Part 2 a) Define a relational schema with underlined (primary) keys and arrows connecting foreign keys and primary keys for a database containing the following information. Authors have LastName, FirstName, ID, and Birthdate (identified by ID) Publishers have Name, PubNumber, Address (identified by PubNumber) Books have ISBN, Title, Publisher (each book has a publisher and is identified by its ISBN). Authors Write Books; since many authors can co-author a book, we need to know the relative contribution of the author to a book, signified by their position in the author list (i.e. 1, 2, 3, etc.)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions