1. Homepage
  2. Programming
  3. COMPSCI 351 : Fundamentals of Database Systems S1 C - Lab 02: MySQL DBMS

COMPSCI 351 : Fundamentals of Database Systems S1 C - Lab 02: MySQL DBMS

Engage in a Conversation
AustraliaUniversity of AucklandCOMPSCI 351Fundamentals of Database Systems DDLPython

COMPSCI 351 S1 C – Lab 02

  1. In Lab01 question 3, we used the PhpMyAdmin tool as an interface for accessing the MySQL DBMS back end. In this question, we use a programming interface to directly access the created databases of the MySQL DBMS.

MySQL Connector for Python (https://dev.mysql.com/doc/connector-python/en/) provides a database connectivity mechanism for communicating with MySQL servers through a Python program. Please read the above page link and install the ‘mysql.connector’ on your Python3 runtime environment. The following is a simplified code segment that enables the login to your MySQL account and display the names of all databases. CourseNana.COM

import mysql.connector
from getpass import getpass
from mysql.connector import connect, Error
def dbexec(conn, query):
with conn.cursor() as cursor:
cursor.execute(query)
for tb in cursor:
print(tb)
def main():
try:
with connect(
host="fosmysqlprd01.its.auckland.ac.nz",
user=input("Enter username: "),
password=getpass("Enter password: "),
) as connection:
print('DATABASE NAMES')
dbexec(connection, "SHOW DATABASES")
# extend your code here
except Error as e:
print(e)
main()

Your task is extending the above program in order to achieve the additional functions below: • Allow the user to select a database and display its tables. The DML statements are ‘USE database_name' and 'SHOW TABLES'. Note that database_name should be replaced with an actual database name. • Allow the user to select a table and display its content. The DML statement is 'SELECT * FROM table_name'. Note that table_name should be replaced with an actual table name. • Allow the user to enter a DML query statement and display the result of the query. CourseNana.COM

You can download the “Lab02_Q1_code.py” file and extend it. Since the MySQL DBMS is hosted inside the University intranet, the access from a programming interface can only be established via UOA network, i.e., either LAN on campus or remotely using VPN connection. A sample output of the completed program is shown as follows. Note that ‘abcd001’ is used as the example login UPI. You should replace it with your own student UPI value. CourseNana.COM

Enter username: abcd001
Enter password:
DATABASE NAMES
('information_schema',)
('performance_schema',)
('teaching_',)
('teaching_abcd001_A1',)
('teaching_abcd001_COMPANY',)
('teaching_abcd001_UNIVERSITY',)
('teaching_abcd001_Lab01',)
Select a database: teaching_abcd001_lab01
('COURSE',)
('GRADE_REPORT',)
('PREREQUISITE',)
('SECTION',)
('STUDENT',)
Select a table to show content: SECTION
(85, 'MATH2410', 'Fall', '07', 'King')
(92, 'CS1310', 'Fall', '07', 'Anderson')
(102, 'CS3320', 'Spring', '08', 'Knuth')
(112, 'MATH2410', 'Fall', '08', 'Chang')
(119, 'CS1310', 'Fall', '08', 'Anderson')
(135, 'CS3380', 'Fall', '08', 'Stone')
Enter a query statement: SELECT Course_name, Course_number,
Credit_hours FROM COURSE WHERE Department='CS'
('Intro to Computer Science', 'CS1310', 4)
('Data Structures', 'CS3320', 4)
('Database', 'CS3380', 3)

[6 marks] CourseNana.COM

  1. Composite and multi-valued attributes can be nested to any number of levels. Suppose we want to design an attribute for a STUDENT entity type to keep track of previous college education. Such an attribute will have one entry for each college previously attended, and this entry is composed of: college name, start and end dates, degree entries (degrees awarded at that college, if any), and transcript entries (courses completed at that college, if any). Each degree entry is formed of degree name and the month and year that it was awarded, and each transcript entry is formed of a course name, semester, year, and grade. Design such an attribute to hold this information using the ER diagram notation. [6 marks]

Get in Touch with Our Experts

WeChat (微信) WeChat (微信)
Whatsapp WhatsApp
Australia代写,University of Auckland代写,COMPSCI 351代写,Fundamentals of Database Systems代写, DDL代写,Python代写,Australia代编,University of Auckland代编,COMPSCI 351代编,Fundamentals of Database Systems代编, DDL代编,Python代编,Australia代考,University of Auckland代考,COMPSCI 351代考,Fundamentals of Database Systems代考, DDL代考,Python代考,Australiahelp,University of Aucklandhelp,COMPSCI 351help,Fundamentals of Database Systemshelp, DDLhelp,Pythonhelp,Australia作业代写,University of Auckland作业代写,COMPSCI 351作业代写,Fundamentals of Database Systems作业代写, DDL作业代写,Python作业代写,Australia编程代写,University of Auckland编程代写,COMPSCI 351编程代写,Fundamentals of Database Systems编程代写, DDL编程代写,Python编程代写,Australiaprogramming help,University of Aucklandprogramming help,COMPSCI 351programming help,Fundamentals of Database Systemsprogramming help, DDLprogramming help,Pythonprogramming help,Australiaassignment help,University of Aucklandassignment help,COMPSCI 351assignment help,Fundamentals of Database Systemsassignment help, DDLassignment help,Pythonassignment help,Australiasolution,University of Aucklandsolution,COMPSCI 351solution,Fundamentals of Database Systemssolution, DDLsolution,Pythonsolution,