Class5-Python-Module-Week10

1. Entity Relationship Diagram - Company

Your task is to design and describe the database of a company.

  • You are working in a IT company where multiple small teams deliver one product each. Every member of a team have a responsibilitiy (title) such as product owner, backend developer, frontend developer, data engineer etc. Also each product is being developed for a different customer, and these customers are serving within different domains. Your task is to design and create a database where you can handle (store and retrieve) all these information.

Your tasks:

  • Choose your entities, write down their attributes.

  • Create tables for these entities according to normalization rules.

  • Explain the relationships between entities.

  • Create an entity relationship diagram where you display all these information graphically.

Below is an example ERD. Try to come up with a similar end result. Good luck!

erd-sample

2. Import ERD

  • Import the company ERD created in exercise 1 to pgAdmin

3. Import Pagila DB with data

4. Connect to DB with Python

  • Now, connect to this imported Pagila database from python code.
  • Select all rows from actor table
  • Select first row of category table
  • Select first 50 rows of address table

Do the above operations inside python code. (Use fetchOne(), fetchMany(), fetchAll() etc.)

5. Create DB with Python

  • Create an empty database named PyCoders from your pgAdmin
  • Create a file named exercise5.py: this file will connect to PyCoders database
  • After connecting to database:
    • Create a table with name students
      • This table will have student_id and name columns
    • Create a table with name teachers
      • This table will have teacher_id and name columns
    • Now add 3 records for both of these databases.
  • You should do all of these inside the python code.
  • After doing these, run SELECT queries to get all data from both tables. Print these outputs.

Hackerrank Questions