Write an introduction to your report, giving context and background to the reader, and explaining what...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write an introduction to your report, giving context and background to the reader, and explaining what you are going to do in your report. Question 1 (4 marks) Explain how SQL databases are used alongside websites, web apps and mobile apps to store users' data. Discuss in particular the reason why web servers can be easily horizontally scaled, but database servers cannot. Question 2 (2 marks) Explain the concept of the ORM (object-relational mapper) and how such tools are useful in database programming. Question 3 (2 marks) Give a brief overview of each of the following software tools. Your overview should mention functionality, applications, history, and the meaning of the tool's name. The Flask server (Python library) The psycopg2 database connector (Python library) The SQLAlchemy ORM (Python library) The overview should be written up as a passage of text rather than using tables or bullet lists. Question 4 (1 mark) Check whether Flask is installed. If it is not, install Flask using pip. If you get stuck, check some examples or try conda instead of pip. Explain what you did in this step in your own words, and include a screenshot. Question 5 (1 mark) Create a folder called server. In this folder, save the following as a Python file called app.py: from flask import Flask app = Flask (__name__) @app.route('/') def hello world(): return 'Hello, World!! 3 from flask import Flask app = Flask (__name__) @app.route('/') def hello_world(): return 'Hello, World!' Then run this file using the flask run command on the command line. You may need to set an environment variable using set or export to get this to work. The Flask server is now serving a web page. Visit this page in your browser. Explain what you did in this step in your own words, and include a screenshot. Question 6 (2 marks) While developing, when we make a change to the code, we want to easily see it in the browser when the page is refreshed. With the Flask server still running, change 'Hello, World!' to something else. Refresh the web page. Is the new value shown? Configure your Flask environment to automatically reload the code when you change it. (Hint: look up the FLASK_DEBUG environment variable). Explain what you did in this step in your own words, and include a screenshot. Question 7 (2 marks) Question 7 (2 marks) To show web pages, Flask uses templates. A template is a file containing hypertext markup language (HTML) code which will eventually be rendered as a web page. Research how to add a template to your Flask app, then add a simple HTML page. Explain what you did in this step in your own words, and include a screenshot. Show also all your code. Question 8 (2 marks) Drawing on tutorials and the Flask sample code made available, use the psycopg2 database connector to display information, from a database table, in your app. Choose one of the database tables in northwind or dvdrental, then use psycopg2 to pull information from that table into a Python data structure. Create a new web page in your app and use a template file to loop over the table rows and display them on the page. 4 Explain what you did in this step in your own words, and include a screenshot of the app running locally. Show also the relevant new code. Question 9 (4 marks) Drawing on tutorials and the Flask sample code made available, add Flask-SQLAlchemy to your app. Add a database model for one of the database tables in northwind or dvdrental (not the movies table or the table you used in the previous question), then (as in the previous question) use a template to create a page listing all the rows in this table. Explain what you did in this step in your own words, and include a screenshot of the app running in the browser. Show also the relevant new code. Question 10 (2 marks) Modify the page you just created so that Flask-SQLAlchemy is also used to display the number of rows in the table (research the .count() function in SQLAlchemy). Explain what you did in this step in your own words, and include a screenshot. Show also the relevant new code. Question 11 (4 marks) Research cascading style sheets (CSS), which are used to control the visual appearance of web pages. Use HTML and CSS to add some basic graphic styling to your page. Consider changing the background colour and font; elements on the page could be styled with colours, spacing, border colours, or other styles of your choosing. You may need to check Flask tutorials to see how to add a style sheet to your web app. Explain what you did in this step in your own words, and include a screenshot. Show also the relevant new code. Question 12 (2 marks) Using either Flask-SQLAlchemy or psycopg2, add a new page to your app which lists all films (at least their ID and name). Explain what you did in this step in your own words, and include a screenshot. Explain precisely what SQL queries are performed each time you load this page. Question 13 (3 marks) 5 Modify the previous page to add a new column which shows the name of one actor from each film (or nothing if no actors are known for that film). Explain what you did in this step in your own words, and include a screenshot. Explain precisely what SQL queries are performed by SQLAlchemy each time you load this page, and discuss the differences from the queries performed for the last question. Question 14 (2 marks) Explain the N+1 query problem and discuss the issues it causes, and methods to deal with it. Question 15 (3 marks) Modify your solution for Question X by implementing a solution to the N+1 query problem. Explain what you did in this step in your own words, and include a screenshot. Question 16 (1 mark) Create a new database on your local Postgres server, then create a new table there with at least three rows (you will need to issue the CREATE DATABASE, CREATE TABLE and at least one INSERT statement). Modify your app so that it connects to this new database. Create a new page in your app which lists all the information in this table. Explain what you did in this step in your own words, and include a screenshot. Question 17 (2 marks) Create a new page in your app which allows you to add information to your new database table. The page will need a form with several fields and a Submit button. Verify that this page works by adding rows and refreshing the page which displays the contents of your new table. Explain what you did in this step in your own words, and include a screenshot of the form and a screenshot showing the newly added rows; show also the new code. Conclusion (3 marks) Write a conclusion to your report, explaining the work done and how you resolved any challenges you faced along the way. Write an introduction to your report, giving context and background to the reader, and explaining what you are going to do in your report. Question 1 (4 marks) Explain how SQL databases are used alongside websites, web apps and mobile apps to store users' data. Discuss in particular the reason why web servers can be easily horizontally scaled, but database servers cannot. Question 2 (2 marks) Explain the concept of the ORM (object-relational mapper) and how such tools are useful in database programming. Question 3 (2 marks) Give a brief overview of each of the following software tools. Your overview should mention functionality, applications, history, and the meaning of the tool's name. The Flask server (Python library) The psycopg2 database connector (Python library) The SQLAlchemy ORM (Python library) The overview should be written up as a passage of text rather than using tables or bullet lists. Question 4 (1 mark) Check whether Flask is installed. If it is not, install Flask using pip. If you get stuck, check some examples or try conda instead of pip. Explain what you did in this step in your own words, and include a screenshot. Question 5 (1 mark) Create a folder called server. In this folder, save the following as a Python file called app.py: from flask import Flask app = Flask (__name__) @app.route('/') def hello world(): return 'Hello, World!! 3 from flask import Flask app = Flask (__name__) @app.route('/') def hello_world(): return 'Hello, World!' Then run this file using the flask run command on the command line. You may need to set an environment variable using set or export to get this to work. The Flask server is now serving a web page. Visit this page in your browser. Explain what you did in this step in your own words, and include a screenshot. Question 6 (2 marks) While developing, when we make a change to the code, we want to easily see it in the browser when the page is refreshed. With the Flask server still running, change 'Hello, World!' to something else. Refresh the web page. Is the new value shown? Configure your Flask environment to automatically reload the code when you change it. (Hint: look up the FLASK_DEBUG environment variable). Explain what you did in this step in your own words, and include a screenshot. Question 7 (2 marks) Question 7 (2 marks) To show web pages, Flask uses templates. A template is a file containing hypertext markup language (HTML) code which will eventually be rendered as a web page. Research how to add a template to your Flask app, then add a simple HTML page. Explain what you did in this step in your own words, and include a screenshot. Show also all your code. Question 8 (2 marks) Drawing on tutorials and the Flask sample code made available, use the psycopg2 database connector to display information, from a database table, in your app. Choose one of the database tables in northwind or dvdrental, then use psycopg2 to pull information from that table into a Python data structure. Create a new web page in your app and use a template file to loop over the table rows and display them on the page. 4 Explain what you did in this step in your own words, and include a screenshot of the app running locally. Show also the relevant new code. Question 9 (4 marks) Drawing on tutorials and the Flask sample code made available, add Flask-SQLAlchemy to your app. Add a database model for one of the database tables in northwind or dvdrental (not the movies table or the table you used in the previous question), then (as in the previous question) use a template to create a page listing all the rows in this table. Explain what you did in this step in your own words, and include a screenshot of the app running in the browser. Show also the relevant new code. Question 10 (2 marks) Modify the page you just created so that Flask-SQLAlchemy is also used to display the number of rows in the table (research the .count() function in SQLAlchemy). Explain what you did in this step in your own words, and include a screenshot. Show also the relevant new code. Question 11 (4 marks) Research cascading style sheets (CSS), which are used to control the visual appearance of web pages. Use HTML and CSS to add some basic graphic styling to your page. Consider changing the background colour and font; elements on the page could be styled with colours, spacing, border colours, or other styles of your choosing. You may need to check Flask tutorials to see how to add a style sheet to your web app. Explain what you did in this step in your own words, and include a screenshot. Show also the relevant new code. Question 12 (2 marks) Using either Flask-SQLAlchemy or psycopg2, add a new page to your app which lists all films (at least their ID and name). Explain what you did in this step in your own words, and include a screenshot. Explain precisely what SQL queries are performed each time you load this page. Question 13 (3 marks) 5 Modify the previous page to add a new column which shows the name of one actor from each film (or nothing if no actors are known for that film). Explain what you did in this step in your own words, and include a screenshot. Explain precisely what SQL queries are performed by SQLAlchemy each time you load this page, and discuss the differences from the queries performed for the last question. Question 14 (2 marks) Explain the N+1 query problem and discuss the issues it causes, and methods to deal with it. Question 15 (3 marks) Modify your solution for Question X by implementing a solution to the N+1 query problem. Explain what you did in this step in your own words, and include a screenshot. Question 16 (1 mark) Create a new database on your local Postgres server, then create a new table there with at least three rows (you will need to issue the CREATE DATABASE, CREATE TABLE and at least one INSERT statement). Modify your app so that it connects to this new database. Create a new page in your app which lists all the information in this table. Explain what you did in this step in your own words, and include a screenshot. Question 17 (2 marks) Create a new page in your app which allows you to add information to your new database table. The page will need a form with several fields and a Submit button. Verify that this page works by adding rows and refreshing the page which displays the contents of your new table. Explain what you did in this step in your own words, and include a screenshot of the form and a screenshot showing the newly added rows; show also the new code. Conclusion (3 marks) Write a conclusion to your report, explaining the work done and how you resolved any challenges you faced along the way.
Expert Answer:
Related Book For
Auditing Cases An Interactive Learning Approach
ISBN: 9780134421827
7th Edition
Authors: Mark S Beasley, Frank A. Buckless, Steven M. Glover, Douglas F Prawitt
Posted Date:
Students also viewed these databases questions
-
Provide an example of an internal control and how it can prevent breakdown or fraud. 2)In your company, what internal controls do you encounter on a regular basis? Are those controls appreciated or...
-
1. If each of the following functions were expanded as a Taylor series about the given point zo, what would be the its radius of convergence? (There is no need to actually obtain the expansion.) (a)...
-
Consider the following information: Probability of Return Return State of economy state Stock A Stock B Boom 0.2 15% 9% Normal 0.5 7% 11% Recession 0.3 3% 13% i. What is the expected return of the...
-
John Woods' weekly gross earnings for the present week were $2,500. Woods has two exemptions. Using an $80 value for each exemption and the tax rate schedule below, what is Woods' federal income tax...
-
What drives P/E ratios?
-
In most cases, mutations in the core of a protein that replace a smaller nonpolar side chain in the wild-type (e.g., Ala, Val) with a larger nonpolar side chain (e.g., Leu, Ile, Phe, Trp) in the...
-
Use Laplace transforms to convert the following nonhomogeneous systems of differential equations into an algebraic system, and find the solutions of the differential equations. a. \[\begin{aligned}...
-
Information related to Jordan Schlansky Company for 2012 is summarized below. Total credit sales $2,200,000 Accounts receivable at December 31 825,000 Bad debts written off 33,000 Instructions (a)...
-
6. Stock A has a beta of 1.10, and its required return is11.00%. Stock B's beta is 0.60. If the risk-free rate is 4.00%,what is the required rate of return on B's stock? 2 answers
-
On January 1, Year 2, PAT Ltd. acquired 90% of SAT Inc. when SAT's retained earnings were $1,000,000. There was no acquisition differential. PAT accounts for its investment under the cost method. SAT...
-
Alexa1 and Zoltan2 play the following game: AZ-game: Step 1: Alexa chooses a uniformly random element from the set 1,2,3). Let a denote the element that Alexa chooses. Step 2: Zoltan chooses a...
-
A few years ago, Largo Industries implemented an inventory auditing system at an installed cost of $172,000. Since then, it has taken depreciation deductions totaling $122,120. What is the system's...
-
2. Write a program in Java to take an infix mathematical expression. The expression will contain single- or double-digit numbers, '+',"-", "*", ***, and operators, and parenthesis. First check the...
-
Consider a multiplicative binomial model with N = 3, r = 0, u = 1.2, d = 0.8 and S 0 = 100. At time t = 1 when S 1 = 120 a (european) call option with maturity at T = 3 and struck at 100 is quoted at...
-
Today is December 31, 2019. Mike retired five years ago, on December 31, 2014. Since his retirement, he has been withdrawing $55,000 every year on December 31st. The first withdrawal was made on...
-
Financial statements for Askew Industries for 2024 are shown below (in thousands): 2024 Income Statement Net sales Cost of goods sold. Gross profit Operating expenses Interest expense Income tax...
-
The annual statement of comprehensive income of LightHouse Corp. contains the following data: revenue = $700,000; cost of sales including depreciation = $530,000; depreciation expense = $50,000;...
-
Discuss whether responsible human resources management should apply different standards for the home company and suppliers, for developed countries and developing countries, and for large companies...
-
One can only imagine the high expectations of investors when the boards of directors of CUC International, Inc. (CUC) and HFS, Inc. (HFS) agreed to merge in May 1997 to form Cendant Corporation. The...
-
Wallys Billboard & Sign Supply, Inc. was founded four years ago by Walter Johnson. The company specializes in providing locations for sign and billboard advertising and has recently begun to enter...
-
It was like riding a tiger, not knowing how to get off without being eaten, according to Satyam Computer Services Limited (Satyam) former Chairman, B. Ramalinga Raju, soon after massive fraud...
-
\(3 \pi+7 \sqrt{21}=7 \sqrt{21}+3 \pi\) Identify the property of real numbers that is being illustrated.
-
\((-10 \pi)+10 \pi=0\) Identify the property of real numbers that is being illustrated.
-
\(14 \times(3 \sqrt{2}+11.6)=14 \times 3 \sqrt{2}+14 \times 11.6\) Identify the property of real numbers that is being illustrated.
Study smarter with the SolutionInn App