Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I WANT TO SEE A DIFFERENT ANSWER,PLEASE DO NOT COPY AND PASTE THE ANSWER,WHICH IS THE SAME QUESTION ON CHEGG. PLEASE ANSWER THE QUEATONS ACCORDNG

I WANT TO SEE A DIFFERENT ANSWER,PLEASE DO NOT COPY AND PASTE THE ANSWER,WHICH IS THE SAME QUESTION ON CHEGG.

PLEASE ANSWER THE QUEATONS ACCORDNG TO THE CODE BELOW

  1. Explain your company and its business.

  2. (20 points) Explain your database design, i.e. which tables and relations are used, in details.

  3. (10 points) Draw ER diagram of your database1. Provide snapshots for tables.

  4. (10 points) Explain keys and cardinalities for each table.

  5. (20 points) Apply 4NF Normalization for your databases tables. Explain

each step of normalization.

pip install MySQLdb #Now we will import tha libraries

# Installed module we will be using to connect to MySQL database import MySQLdb Now we will connect to the database

host= # Preferably "localhost" if you are using on your computer user= # Preferably "root" if you are using on your computer password= dbname=

try: # Connecting to our database conn= MySQLdb.connect(host,user,password,dbname) print("Connected") conn.close() except: print("Can't connect to database") #here we can see if their is any connection error. If theirs an error we can debug the code by checking username or password.

#Also we can print(conn). If it return None then connection failed.

#Now for adding records to table

cursor=conn.cursor() # here conn is the connection object we created earlier

# Executing Query cursor.execute("insert into () values (%s,%s,...)",()") # cursor.execute takes 2 parameter # Syntax : cursor.execute(sqlquery,values) # Example : # name = "XYZ" # email = "xyz@gamil.com" # cursor.execute("insert into myTable(name,email) values (%s,%s)",(name,email)) conn.commit() # this is used to commit chandes to database #Now to fetch the records from databses

cursor=conn.cursor() # here conn is the connection object we created earlier

# Executing Query cursor.execute("select * from myTable") cursor.fetchone() # Fetched the first row # OR cursor.fetchall() # Fetches all rows

# We can also pass filters to select query email = "xyz@gamil.com" cursor.execute("select * myTable where email=%s",(email)) #Additional queries

cursor=conn.cursor() # here conn is the connection object we created earlier

cursor.execute("select * from myTable limit 5") result=cursor.fetchall() # The result variable holds the records returned from using .fetchall(). Its a list of tuples representing individual records from the table. # In the query above, you use the LIMIT clause to constrain the number of rows that are received from the SELECT statement.

# Query for selected particular columns only cursor.execute("select name from myTable") result=cursor.fetchall() #Note

cursor.execute("SELECT * FROM myTable") result=cursor.fetchall()

# as we know that fetchall() return a tuple so we can use a for loop to print records one by one. for i in result: print(i)

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

Step: 3

blur-text-image

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

Professional Visual Basic 6 Databases

Authors: Charles Williams

1st Edition

1861002025, 978-1861002020

More Books

Students also viewed these Databases questions

Question

List behaviors to improve effective leadership in meetings

Answered: 1 week ago

Question

Comment on the pH value of lattice solutions of salts.

Answered: 1 week ago

Question

What is the environment we are trying to create?

Answered: 1 week ago

Question

How would we like to see ourselves?

Answered: 1 week ago

Question

How can we visually describe our goals?

Answered: 1 week ago