sql server agent

advertisement
SQL710 Assignment 1 - due Tuesday March 16, 2004
Revisions of March 9 shown in red
(worth 10% of final mark)
Seneca College Student Council has decided to operate entertainment rentals stores at
each campus. The stores will rent DVDs, videotapes, and videogames to students. You
have been selected to be the Database Administrator for this application. You are to
hand in your hard drive and a signed assignment submission form available at
http://cs.senecac.on.ca/bullets/honesty.txt
You are to consolidate the information available at this time to a centralized SQL Server
database named MoviesXX where XX are your initials (for example, my database would
be named MoviesPB). Each campus store will access this centralized database. Students
will also be able to view information over the Internet. Set properties for your database
as follows:
 2 Data files each 10MB with 5% growth permitted to a maximum size of 50MB
each
 Log File size of 5MB with 10% growth permitted to a maximum size of 10MB
 Recovery model: Full
DESIGN
The database design has been established using the Access MovieRentals database
provided with this assignment.
Business Rules currently defined in the Access database MovieRentals that must be
defined in your database include:
 A customer can have 0, 1 or many rental agreements
 A rental agreement is for one and only one customer
 A rental agreement must have at least one rental agreement item and can have
more than one rental agreement item
 A rental agreement item pertains to one and only one rental agreement
 A rental agreement item rents one and only one item
 An item can be rented by 0, 1 or many rental agreement items
 An item represents one and only one title
 A title can have 0, 1 or many items
 A title can be of one and only one category
 A category can have 0, 1 or many titles
 An item can be of one and only one media type
 A media type can have 0, 1 or many items
 A rental rate represents one and only one media format
 A media format can have 0, 1 or many rental rates
 A category can have 0, 1 or many rental rates















A rental rate pertains to one and only one category
A campus can have 0, 1 or many employees
An employee can work at one and only one campus
A student may be an employee
An employee can only be a student
A student is located at one and only one campus
A campus may have 0, 1 or many students
An item is located at one and only one campus
A campus may contain 0, 1 or many items
A rental agreement is processed by one and only one employee
An employee may process 0, 1 or many rental agreements
Most fields are required in each table – optional fields include only
Customer.MoviesPassword, RentalAgrt.CreditCardNum,
RentalAgrt.CreditExpDate, RentalAgrtItem.ReturnDate, Title.Description
Unique fields in addition to Primary Keys include: Category.Description,
Customer.StudentNumber, Media.Description, Campus.Campus,
Employee.StudentNumber
Default values include: Item.PurchaseDate (default: Current Date),
Item.TimesRented (default: 0), Item.Available (default:Y)
Validation criteria include: RentalAgrt.PaymentMethod (values of CA or MC
only), RentalRate.NumDaysRental (values between 1 and 7), RentalRate.Fee
(values between 0 and 10), Title.Genre (values of dra, com, act, rom, sci or kid),
Title.Rating (values of G, PG, PG13, AA or R).
DATA
The process used to transfer each set of data below is to be saved as an
appropriately named DTS package.
Data for most tables is already contained in the Access database MovieRentals and is to
be uploaded to your SQL Server database.
For each of the remaining data sources youTitle information is available in the attached
HTML file named Title (my apologies for originally providing a Rich Text file!) and
is to be uploaded to your database. Item information is available in the Excel spreadsheet
ItemFmt.xls and is also to be uploaded to your database.
Student information from SIRIS will be made available initially in the format of a text
file. A sample of the student data that is to be uploaded is provided in the text file named
Customer.txt. The program code in this file must be translated into a campus code (CPA,
CPD, DAD programs are located at SY, CNS, CTY programs are located at Don Mills,
and BUS and ACC programs are located at Newnham).
Employee information is available in the attached text file EmployeeFmt.txt and is to be
uploaded.
Add yourself as a customer and an employee using appropriate data values. Add a rental
agreement for yourself for 2 items using appropriate data values.
You must alter the Items table by adding an optional column called LastRentalDate
(of date format) to store the date the item was last rented.
SQL SERVER AGENT
Set yourself and me up as operators. Create a job called Overdue to be performed each
day at 1 pm that print to a file all items more than 2 days late and the name, phone and
email for customer renting that item. Save the output in c:\temp\overdue.txt
Create another job called TopRentals to be performed every Monday at 9am to execute
an SQL query listing titles in each media in decreasing order of number of rentals for the
past week. Save the output in c:\temp\rentals.txt.
Create another job called Monthly to be performed the first Monday of each month at
1am. The job is to execute an SQL statement that lists all rental agreements from the
previous month that have had all rental items returned. Save this output to a file name
returneditems in c:\temp. If this step is successful then execute the next step to delete all
completed rental agreements and rental agreement items from the previous month. The
next step should execute unconditionally and print to a file named delete.txt all items for
titles which have not been rented in the past 12 months. If this step is successful then
perform the next step of deleting these items and titles. Notify yourself when this job is
finished.
Define alerts as follows:
 an alert called Fatal to notify yourself every 5 minutes when a fatal SQL Server
error (choose any one of the fatal errors) occurs
 an alert called 18458 to notify yourself with an appropriate message whenever
SQL Server error 18458 occurs
 an alert called DataSize to notify yourself with an appropriate error message
whenever data file size is greater than 40MB
 an alert called LogSize to notify yourself with an appropriate error message
whenever log file size is greater than 9MB
Download