联系方式

  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp

您当前位置:首页 >> Database作业Database作业

日期:2019-04-11 10:47

Database Processing for Large-Scale Analytics

Assignment 1


Due Sunday, April 14th.


Supplemental reading: SQL reference book Oracle 11g SQL by Price, ISBN 9780071498500 (available in Books 24x7 DePaul online library as eBook). Sections 1.1, 1.2, 1.4, 1.6

NOTE: We will be using Oracle 12c to run queries. However, I do not see the 12c book in the 24x7 library search and all of the reading material on basic SQL is exactly the same for both versions.


Part 1


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

print(generateInsert('Students', ['1', 'Jane', 'A+']))  should print

INSERT INTO Students VALUES (1, Jane, A+);

If you like additional challenge, modify your function to return (not required for full credit):

INSERT INTO Students VALUES (1, 'Jane', 'A+');

(i.e., put quotes around strings, but not numbers).

Another example:

print( generateInsert('Phones', ['42', '312-555-1212'])) would produce

INSERT INTO Phones VALUES (42, 312-555-1212);

You can assume that every entry in the list of values is given as a string, even if it is a number in practice.


You should submit your python code and sample output for this part (to simplify grader’s life, please copy everything into your Word document submission).


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. We will do a similar example in the beginning of the next lecture.

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.).

b)Define a relational schema for students, student advisors, and advisor departments

Students have StudentID, First Name, Last Name, DOB, Telephone and a reference to their advisor

Advisors have ID, Name, Address, Research Area, and a reference link to their Department

?Departments have Name, Chair, Endowment (identified by Name)

Part 3


1)Using your logical schema from Part 2-a, write the necessary SQL DDL script to create the tables. Be sure to specify every primary key and every foreign key. You can make reasonable assumptions regarding the attribute domains (e.g., setting every column to VARCHAR2(100) is not reasonable).


2)Using logical schema from Part 2-b write the necessary SQL DDL script to create the tables. Be sure to specify every primary key and every foreign key.


3)Write SQL INSERT statements to populate your database from Part 2-a with the following data (NOTE: remember that strings would need to use single quotes, e.g., 'Asimov'). Be sure to verify that your statements worked correctly and loaded the data.


a)(King, Stephen, 2, September 9 1947)

b)(Asimov, Isaac, 4, January 2 1921)

c)(Verne, Jules, 7, February 8 1828)

d)(Rowling, Joanne, 37, July 31 1965)


e)(Bloomsbury Publishing, 17, London Borough of Camden)

f)(Arthur A. Levine Books, 18, New York City)


g)(1111-111, Databases from outer space, 17)

h)(2222-222, Revenge of SQL, 17)

i)(3333-333, The night of the living databases, 18)


j)(2, 1111-111, 1)

k)(4, 1111-111, 2)

l)(4, 2222-222, 2)

m)(7, 2222-222, 1)

n)(37, 3333-333, 1)

o)(2, 3333-333, 2)


版权所有:编程辅导网 2021 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。 站长地图

python代写
微信客服:codinghelp