Database Diagram
Store Procedure - uspMonthlyFee <ul><li>RESULTS </li></ul>“ Before” “ After”
Store Procedure - uspNightlyUpdate RESULTS “ Before” “ After”
Inline Table-Valued Function
Create an Indexed View Create a clustered index  on an existing view
Create Views for Reports Result From  View Selection
XML Loading
Configure Merge Replication
Merge Replication
Security Model <ul><li>Managing Security:  </li></ul><ul><li>login, server scope permission, password police, certificate,...
Code for Encryption
Create BFManager role and add a member to the Role Add Securables and grant execution permission to BFManager
Get Sensitive Data by Authorized User <ul><li>EXECUTE AS USER  =  ‘NingYin'  </li></ul><ul><li>EXEC sales .uspGetCreditCar...
Schemas and Views <ul><li>Schemas: Inventory, Sales </li></ul><ul><li>Create a view for inventory search </li></ul>
Triggers <ul><li>  Use DML triggers to enforce data integrity </li></ul><ul><li>Use DDL trigger to respond object changes ...
Maintenance Jobs <ul><li>Backup </li></ul><ul><li>Agent jobs </li></ul><ul><li>Table partitioning </li></ul><ul><li>Email ...
Backup Strategy <ul><li>Backup Plan: </li></ul><ul><li>Full Backup:  </li></ul><ul><li>Once a week Sunday night at 12:00am...
Schedule Agent Job: Daily Due Fee Update <ul><li>A store procedure is executed every night on SQL Server agent to check al...
Table Partition <ul><li>Partition  Transaction table into 3 different file groups </li></ul><ul><li>CREATE PARTITION FUNCT...
Table Partition
Configure Database Mail for Notification
Configure Agent to Use Database Mail
System Monitoring
BlockFlix Database Maintenance Plan <ul><ul><ul><li>Backup  Database Task </li></ul></ul></ul><ul><ul><ul><li>Create Reorg...
BlockFlix Database Maintenance Plan
Report: Membership
Report: Available Movies
Upcoming SlideShare
Loading in …5
×

Database Development Replication Security Maintenance Report

624 views

Published on

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
624
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
0
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Database Development Replication Security Maintenance Report

  1. 1. Database Diagram
  2. 2. Store Procedure - uspMonthlyFee <ul><li>RESULTS </li></ul>“ Before” “ After”
  3. 3. Store Procedure - uspNightlyUpdate RESULTS “ Before” “ After”
  4. 4. Inline Table-Valued Function
  5. 5. Create an Indexed View Create a clustered index on an existing view
  6. 6. Create Views for Reports Result From View Selection
  7. 7. XML Loading
  8. 8. Configure Merge Replication
  9. 9. Merge Replication
  10. 10. Security Model <ul><li>Managing Security: </li></ul><ul><li>login, server scope permission, password police, certificate, symmetric key, asymmetric key </li></ul><ul><li>database role, user group, authentication </li></ul><ul><li>schemas, views, triggers, store procedure </li></ul>
  11. 11. Code for Encryption
  12. 12. Create BFManager role and add a member to the Role Add Securables and grant execution permission to BFManager
  13. 13. Get Sensitive Data by Authorized User <ul><li>EXECUTE AS USER = ‘NingYin' </li></ul><ul><li>EXEC sales .uspGetCreditCardNumber 1 </li></ul><ul><li>REVERT ; </li></ul><ul><li>GO </li></ul><ul><li>Result: </li></ul><ul><li>UnencryptedCCValue </li></ul><ul><li>------------------------------ </li></ul><ul><li>6598452635478965 </li></ul><ul><li>(1 row(s) affected) </li></ul>
  14. 14. Schemas and Views <ul><li>Schemas: Inventory, Sales </li></ul><ul><li>Create a view for inventory search </li></ul>
  15. 15. Triggers <ul><li> Use DML triggers to enforce data integrity </li></ul><ul><li>Use DDL trigger to respond object changes in database </li></ul><ul><ul><li>CREATE TRIGGER AuditOperations </li></ul></ul><ul><ul><li>ON DATABASE </li></ul></ul><ul><ul><li>FOR DDL_TABLE_VIEW_EVENTS </li></ul></ul><ul><ul><li>AS </li></ul></ul><ul><ul><li>RAISERROR('DDL Database level changes are prevented by the AuditOperations trigger', 16, 1) </li></ul></ul><ul><ul><li>ROLLBACK </li></ul></ul><ul><ul><li>GO </li></ul></ul><ul><ul><li>CREATE TRIGGER TransDeleteAuditor ON dbo.Transactions </li></ul></ul><ul><ul><li>INSTEAD OF DELETE NOT FOR REPLICATION </li></ul></ul><ul><ul><li>AS </li></ul></ul><ul><ul><li>BEGIN </li></ul></ul><ul><ul><li>RAISERROR('Transactions delete is prevented by the MDL trigger', 16, 1) </li></ul></ul><ul><ul><li>ROLLBACK </li></ul></ul><ul><ul><li>END </li></ul></ul><ul><ul><li>GO </li></ul></ul><ul><li>CREATE TRIGGER AuditOperations </li></ul><ul><li>ON DATABASE </li></ul><ul><li>FOR DDL_DATABASE_LEVEL_EVENTS </li></ul><ul><li>AS </li></ul><ul><li>DECLARE @data xml </li></ul><ul><li>DECLARE @cmd nvarchar(350) </li></ul><ul><li>DECLARE @logMsg nvarchar(400) </li></ul><ul><li>SET @data = eventdata() </li></ul><ul><li>SET @cmd = @data.value </li></ul><ul><li>('(/EVENT_INSTANCE/TSQLCommand/CommandText)[1]', 'nvarchar(350)') </li></ul><ul><li>SET @logMsg = @cmd + ' (' + SYSTEM_USER + ' on ' + HOST_NAME() + ')' </li></ul><ul><li>RAISERROR (@logMsg, 10, 1) WITH LOG </li></ul><ul><li>GO </li></ul>
  16. 16. Maintenance Jobs <ul><li>Backup </li></ul><ul><li>Agent jobs </li></ul><ul><li>Table partitioning </li></ul><ul><li>Email notification </li></ul><ul><li>Other: </li></ul><ul><li>Performance monitoring and tuning </li></ul>
  17. 17. Backup Strategy <ul><li>Backup Plan: </li></ul><ul><li>Full Backup: </li></ul><ul><li>Once a week Sunday night at 12:00am </li></ul><ul><li>Differential Backup: </li></ul><ul><li>Every night 11:00pm </li></ul><ul><li>Transaction Log Backup: </li></ul><ul><li>Every hour from 6:00am ~ 11:00pm </li></ul>
  18. 18. Schedule Agent Job: Daily Due Fee Update <ul><li>A store procedure is executed every night on SQL Server agent to check all customers and update information. </li></ul>
  19. 19. Table Partition <ul><li>Partition Transaction table into 3 different file groups </li></ul><ul><li>CREATE PARTITION FUNCTION pf_TransactionDate (datetime) </li></ul><ul><li>AS RANGE RIGHT </li></ul><ul><li>FOR VALUES('01/01/2008','01/01/2009') </li></ul><ul><li>CREATE PARTITION SCHEME ps_TransactionDate </li></ul><ul><li>AS PARTITION pf_TransactionDate </li></ul><ul><li>TO (fg1, fg2, fg3) </li></ul><ul><li>CREATE TABLE dbo.TransactionArchive </li></ul><ul><li>(TransactionID int IDENTITY NOT NULL, </li></ul><ul><li>TransactionTYpeID int NOT NULL, </li></ul><ul><li>CustomerID int NOT NULL, </li></ul><ul><li>CopyID int NOT NULL, </li></ul><ul><li>MediaID int NOT NULL, </li></ul><ul><li>StoreID int NOT NULL, </li></ul><ul><li>TransactionDate datetime NOT NULL) </li></ul><ul><li>ON ps_TransactionDate(TransactionDate) </li></ul><ul><li>Implement partitioning and verify: </li></ul><ul><li>USE BlockFlix </li></ul><ul><li>INSERT INTO dbo.MediaArchive(MediaID, Title, GenreID, RatingID, [Year]) </li></ul><ul><li>SELECT MediaID, Title, GenreID, RatingID, [Year] </li></ul><ul><li>FROM dbo.Media </li></ul><ul><li>SELECT MediaID, Title, $Partition.pf_MediaReleaseYear([Year]) PartitionNo </li></ul><ul><li>FROM dbo.MediaArchive </li></ul><ul><ul><li>MediaID Title PartitionNo </li></ul></ul><ul><ul><li>----------- -------------------------------------------------- ----------- </li></ul></ul><ul><ul><li>1011 A Great Flick 1 </li></ul></ul><ul><ul><li>1012 Ba BOO 1 </li></ul></ul><ul><ul><li>1013 Botle Neck 1 </li></ul></ul><ul><ul><li>1016 Lefty 1 </li></ul></ul><ul><ul><li>1017 Looking Down 3 </li></ul></ul><ul><ul><li>1018 Too Much SQL 3 </li></ul></ul><ul><ul><li>1019 Moo Money 3 </li></ul></ul><ul><ul><li>1020 Late For Dinner 3 </li></ul></ul>
  20. 20. Table Partition
  21. 21. Configure Database Mail for Notification
  22. 22. Configure Agent to Use Database Mail
  23. 23. System Monitoring
  24. 24. BlockFlix Database Maintenance Plan <ul><ul><ul><li>Backup Database Task </li></ul></ul></ul><ul><ul><ul><li>Create Reorganize Index Task </li></ul></ul></ul><ul><ul><ul><li>Check BlockFlix Database IntegrityTask </li></ul></ul></ul><ul><ul><ul><li>Resource Error Task </li></ul></ul></ul><ul><ul><ul><li>Execute SQL Server Agent Job: Check Media Due Process </li></ul></ul></ul><ul><ul><ul><li>Execute T-SQL statement Task </li></ul></ul></ul><ul><ul><ul><li>Maintenance cleanup task </li></ul></ul></ul><ul><ul><ul><li>Rebuild index task </li></ul></ul></ul><ul><ul><ul><li>History cleanup task </li></ul></ul></ul><ul><ul><ul><li>Shrink database task </li></ul></ul></ul><ul><ul><ul><li>Update statistics task </li></ul></ul></ul>
  25. 25. BlockFlix Database Maintenance Plan
  26. 26. Report: Membership
  27. 27. Report: Available Movies

×