Report 1 Downloads 110 Views
Relational Databases and Web Integration Week 24 [email protected]

Tuesday, 18 August 2009

The Problem Customer requires a way of tracking customer usage on a server for billing/ accounting purposes usage is based on quota’s getting current quota usage requires root privileges using and analyzing quota data doesn’t! A web application is required

Tuesday, 18 August 2009

Quota Records Current quota data will be gathered by a separate process and placed in a database table Table (at least for now!) has the following column: used: integer (units are kB)

Tuesday, 18 August 2009

Rails Application To create our basic Rails web application issue: rails accounting

To create our quota database table issue: script/generate resource quota used:integer rake db:migrate

Tuesday, 18 August 2009

v1.0

Rails Application Our web application only ever queries the code within the quota database table Need to also store data about: our customers (need to create, read, update and delete) the usage package they have subscribed to (also need to create, read, update and delete)

Tuesday, 18 August 2009

Customer Table To create our database tables issue: script/generate scaffold customer name:string contact:string package_id:integer script/generate scaffold package name:string limit:integer rake db:migrate

Now visit http://localhost:3000/customers

Tuesday, 18 August 2009

Notice that when viewing Customer data, our package ID is shown rather than the package name. When editing or creating a customer, we want that package to be selected from the available packages. Modify Customer views as we require!

Data Input Validation Always need new customers to: have a name and a contact email address Email addresses need to fit a given regular expression Package name’s should be unique Package limits need to be positive integers

Tuesday, 18 August 2009

v3.0 Modify our Customer and Account models to include this data validation.

Table Relationships

Customer’s subscribe to a single Package need to add a database constraint

Tuesday, 18 August 2009

Modify the Customer model to include this relationship constraint.

More Table Relationships

Quota data is associated with a customer! need to modify our original quota table

Tuesday, 18 August 2009

Migrate the Quota table and add in the missing customer_id field. Then add in the required relationship constraint between Customer and Quota.

Accounting Our web application now needs to incorporate our quota data Want to display: package limit (in units of GB) amount used (in units of GB) % space free

Tuesday, 18 August 2009

v4.0 Add in a helper function for unit conversion. Modify Customer view (show) to include package limit, amount used and % space free. Modify Customer model to include a usage method. Manually simulate adding in quota data to SQLite3 database and view its effect.