Best Practices for Database Schema Design

883 views

Published on

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

  • Be the first to like this

No Downloads
Views
Total views
883
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Best Practices for Database Schema Design

  1. 1. Best Practices for Database Schema Design Presenter: Kirill Dmitriev Try it free! www.ironnspeed.com/download
  2. 2. Etiquette <ul><ul><li>Ask questions at any time via Question and Answer facility </li></ul></ul><ul><ul><ul><li>Moderator will queue them up and … </li></ul></ul></ul><ul><ul><ul><li>… I will read aloud and answer so everyone can hear </li></ul></ul></ul><ul><ul><ul><li>… in the order received </li></ul></ul></ul><ul><ul><ul><li>This allows everyone to hear the question and is much faster </li></ul></ul></ul><ul><ul><ul><li>We expect many questions during this webinar! </li></ul></ul></ul><ul><ul><li>Listening via computer (VOIP)? </li></ul></ul><ul><ul><ul><li>Turn up your computer’s volume! </li></ul></ul></ul><ul><ul><ul><li>... or put on a headset if you can’t hear </li></ul></ul></ul><ul><ul><ul><li>… or dial in via landline telephone if you still can’t hear </li></ul></ul></ul>
  3. 3. What is Covered in this Course <ul><ul><li>Best Practices for Database Schema Design </li></ul></ul><ul><ul><li>How Schema Design Affects Application Generation by Iron Speed Designer </li></ul></ul><ul><ul><li>How to Modify Schema in Database and in Iron Speed Designer </li></ul></ul>
  4. 4. What does Iron Speed Designer Do? <ul><li>ASPX pages </li></ul><ul><li>C# and Visual Basic code-behind files </li></ul><ul><li>Data access layer </li></ul><ul><li>Stored procedures </li></ul>Iron Speed Designer builds Web applications… … straight from your database.
  5. 5. To get most of Iron Speed Designer prepare your database first! <ul><ul><li>Iron Speed Designer uses database schema to create pages </li></ul></ul><ul><ul><li>Pages layout and functionality are driven by schema </li></ul></ul><ul><ul><li>Application performance depends on your schema </li></ul></ul><ul><ul><li>Properly designed schema is easy extendable </li></ul></ul><ul><ul><li>To create web application with Iron Speed Designer no knowledge of code, ASPX or other .NET concepts required but knowledge of database schemas, foreign keys, and SQL is helpful </li></ul></ul>
  6. 6. Prepare Your Database <ul><ul><li>The better your database is structured… … the more Iron Speed Designer can do </li></ul></ul><ul><ul><ul><li>You’ll get more Web pages </li></ul></ul></ul><ul><ul><ul><li>You’ll get more sophisticated master-detail Web pages </li></ul></ul></ul><ul><ul><ul><li>It’s easier to extend your application </li></ul></ul></ul><ul><ul><ul><li>It’s easier to maintain your data </li></ul></ul></ul>
  7. 7. <ul><ul><ul><li>No repeating information: Use index tables </li></ul></ul></ul><ul><ul><ul><li>Less fields in table – more efficient </li></ul></ul></ul>Normalize Schema
  8. 8. Create Child Tables for 1-to-Many Relationships <ul><ul><li>Child tables are used to create </li></ul></ul><ul><ul><ul><li>Master-detail (parent-child) pages </li></ul></ul></ul><ul><ul><li>Child table examples </li></ul></ul><ul><ul><ul><li>Orders.CustomerID  Customers.CustomerID (one customer may have many orders) </li></ul></ul></ul><ul><ul><ul><li>OrderDetails.OrderID  Orders.OrderID (one order may have many line items) </li></ul></ul></ul><ul><ul><li>DBAs call this ‘normalizing your database’ </li></ul></ul>
  9. 9. Create Separate Lookup Tables <ul><ul><li>Lookup tables are used to create </li></ul></ul><ul><ul><ul><li>Dropdown lists for data entry </li></ul></ul></ul><ul><ul><ul><li>Display Foreign Key As </li></ul></ul></ul><ul><ul><li>Lookup table examples </li></ul></ul><ul><ul><ul><li>Order.ShipperID  Shipper.ShipperID (choose order shipping method: FedEx, UPS, USPS) </li></ul></ul></ul><ul><ul><ul><li>Displays “Shipped Via FedEx” (instead of “Shipped Via 3”) </li></ul></ul></ul>
  10. 10. Index! <ul><ul><ul><li>Index all Foreign keys, Primary keys and any fields you search by or filter by </li></ul></ul></ul><ul><ul><ul><li>Full text index is not supported. </li></ul></ul></ul>
  11. 11. Naming conventions <ul><ul><ul><li>Use meaningful names: they are used by Iron Speed Designer to create labels </li></ul></ul></ul><ul><ul><ul><li>Use Camel Case! Iron Speed Designer can parse names based on capitalization: ContactID -> Contact; UserName -> User Name </li></ul></ul></ul><ul><ul><ul><li>File name: use Companion field to specify a file name for File upload. See DesignerConfigurationOptions.xsl </li></ul></ul></ul><ul><ul><ul><li>Singular and Plural: helps to create proper names for pages: CategoriesTable instead of CategoryTable </li></ul></ul></ul>
  12. 12. Fields Data Types <ul><ul><ul><li>Using correct data type helps Designer to generate proper controls </li></ul></ul></ul><ul><ul><ul><li>If your string field is supposed to hold not more then 20 symbols limit its length to 20 (nvarchar(20)) </li></ul></ul></ul><ul><ul><ul><li>If your field can have only two values, use bit type </li></ul></ul></ul><ul><ul><ul><li>Use image type for images rather than binary </li></ul></ul></ul><ul><ul><ul><li>Use money rather than decimal for currency </li></ul></ul></ul>
  13. 13. Create Database Views for Complex Queries <ul><ul><li>Create Database views for </li></ul></ul><ul><ul><ul><li>Multi-table joins </li></ul></ul></ul><ul><ul><ul><li>Complex queries: distinct, not, nested queries </li></ul></ul></ul><ul><ul><li>Create via Microsoft Enterprise Manager or similar tool </li></ul></ul><ul><ul><ul><li>Designer treats database views just like database tables </li></ul></ul></ul><ul><ul><li>Database view examples </li></ul></ul><ul><ul><ul><li>Current quarter sales (query filters based on time) </li></ul></ul></ul><ul><ul><ul><li>Paid invoices (query filters based on status field) </li></ul></ul></ul><ul><ul><li>Iron Speed Designer is not a query construction tool ! </li></ul></ul>
  14. 14. Make Database Views Updatable if Possible <ul><ul><li>Designer uses updatable database views to create </li></ul></ul><ul><ul><ul><li>Add Record page </li></ul></ul></ul><ul><ul><ul><li>Edit Record page </li></ul></ul></ul><ul><ul><ul><li>Edit Table pages </li></ul></ul></ul><ul><ul><li>Create updatable views in your database </li></ul></ul><ul><ul><ul><li>Cannot make an updatable view in Designer </li></ul></ul></ul><ul><ul><ul><li>View must have primary key declared in database </li></ul></ul></ul><ul><ul><ul><li>Update ‘flows’ through the view to underlying tables </li></ul></ul></ul><ul><ul><li>Iron Speed Designer is not a query construction tool ! </li></ul></ul>
  15. 15. Declare Primary Keys in your Database <ul><ul><li>Primary keys are used to create </li></ul></ul><ul><ul><ul><li>Show Record pages </li></ul></ul></ul><ul><ul><ul><li>Edit Record pages </li></ul></ul></ul><ul><ul><ul><li>Edit Table pages </li></ul></ul></ul><ul><ul><li>Primary key relationship examples </li></ul></ul><ul><ul><ul><li>Orders.OrderID </li></ul></ul></ul><ul><ul><ul><li>Shipper.ShipperID </li></ul></ul></ul><ul><ul><li>Not permitted to modify your database? </li></ul></ul><ul><ul><ul><li>Create a Virtual Primary Key in Iron Speed Designer </li></ul></ul></ul>
  16. 16. Create Virtual Primary Keys in Designer <ul><ul><li>Use VPKs if you can’t add a primary key in your database </li></ul></ul><ul><ul><li>Used mostly with database views </li></ul></ul><ul><ul><li>Designer uses VPKs to create Show Record, Edit Record & Edit Table pages from database views </li></ul></ul><ul><ul><li>Go to: Application Wizard’s Keys step OR Databases  New Virtual Primary Key… </li></ul></ul>
  17. 17. Declare Foreign Keys in your Database <ul><ul><li>Foreign keys are used to create </li></ul></ul><ul><ul><ul><li>Master-detail (parent-child) pages </li></ul></ul></ul><ul><ul><ul><li>Every Designer-built page can be a master-detail page! </li></ul></ul></ul><ul><ul><ul><li>Pages with data from multiple tables (multi-table joins) </li></ul></ul></ul><ul><ul><ul><li>Display Foreign Key As </li></ul></ul></ul><ul><ul><li>Foreign key relationship examples </li></ul></ul><ul><ul><ul><li>OrderDetails.OrderID  Orders.OrderID </li></ul></ul></ul><ul><ul><ul><li>Orders.ShipperID  Shipper.ShipperID </li></ul></ul></ul><ul><ul><li>Not permitted to modify your database? </li></ul></ul><ul><ul><ul><li>Create a Virtual Foreign Key in Iron Speed Designer </li></ul></ul></ul>Throw me a frickin' bone here!  I'm the boss!  Need the info! – Dr. Evil
  18. 18. Create Virtual Foreign Keys in Designer <ul><ul><li>Use VFKs if you can’t add a foreign key in your database </li></ul></ul><ul><ul><li>Used to create Master-Detail pages & Display Foreign Key As </li></ul></ul><ul><ul><li>Go to: Application Wizard’s Keys step OR Databases  New Virtual Foreign Key… </li></ul></ul>
  19. 19. Create an Application: Application Wizard <ul><ul><li>Go to: Tools  Application Wizard… OR Files  New Application… </li></ul></ul>

×