Create a relational database that has a person table, a picture table, and a person–picture table. In the person table, store an id, the person name, and the person’s age. In the picture table, store a picture id and filename. In the person– picture table, keep track of the people in each picture. Write a function that let you find all the pictures for people over a certain age.
Note: Since this answer refers to a single relational database with multiple tables, it has to be completed with SQL.
```
from com.ziclix.python.sql import zxJDBC
from csv import *
#Returns a list of filenames for all pictures of people above the variable age
def findAllPictures(age):
#Grab the databse
db =zxJDBC.connect("jdbc:mysql://localhost/test", "root", None ,
"com.mysql.jdbc.Driver")
con = db.cursor()
#Make the person table
con.execute("create table Person (id INT, name VARCHAR(50), age INT)")
#Make the picture table
con.execute("create table Picture (id INT, filename VARCHAR(150))")
#Make the person-picture table
con.execute("create table PersonPicture (personid INT, pictureid INT)")
#Copy Any information In
#Read info from the database to return the picture list
con.execute("select * from Person where age>"+str(age))
personIds = []
for i in range(0, con.rowcount):
results= con.fetchone()
personIds.append(results[0])
pictureIds = []
for id in personIds:
con.execute("select * from PersonPicture where personId=="+str(id)) for i in range(0, con.rowcount):
results = con.fetchone()
pictureIds.append(results[1])
pictureFiles = []
for id in pictureIds:
con.execute("select * from Picture where id=="+str(id))
for i in range(0, con.rowcount):
results = con.fetchone()
pictureFiles.append(results[1])
return pictureFiles
```
You might also like to view...
The practice of writing a method to perform a single task and then calling that method whenever you need to perform that task is called:
a. Code reuse b. Divide and conquer c. Inheritance d. Parameter e. None of these
In C++11 reference variables that can refer only to temporary objects that would otherwise have no name are called __________ and are declared with a __________.
a. rvalues, ampersand (&) b. lvalues, ampersand (&) c. lvalues, double ampersand (&&) d. rvalues, double ampersand (&&) e. None of these
The shortcut menu displays when you click the ________
A) right mouse button B) left mouse button C) left and right button together D) none of the above
Vector containers are logically the same as arrays.
Answer the following statement true (T) or false (F)