Creating the Databases
Make PDF417 In C#.NET
Using Barcode maker for .NET framework Control to generate, create PDF417 image in .NET framework applications.www.OnBarcode.com
Decode PDF417 In C#
Using Barcode scanner for VS .NET Control to read, scan read, scan image in VS .NET applications.www.OnBarcode.com
The PTracker database will contain tables and stored procedures to persist the data for the business objects in the object model designed earlier in the chapter. This is a SQL Server 2008 Express database, so you can think of it as being just another file in your project. To create the database, open Visual Studio and create a new Class Library project named PTDB. I won t have you build this project at any point, so you can ignore the project settings and Class1.cs file. The purpose of this project is just so you can use Visual Studio to set up the database. Choose Project Add New Item, and choose the Service-based Database option. As shown in Figure 3-18, name the file and click Add.
Drawing Barcode In C#
Using Barcode creation for Visual Studio .NET Control to generate, create Barcode image in VS .NET applications.www.OnBarcode.com
Make Code 3 Of 9 In C#
Using Barcode creation for .NET framework Control to generate, create Code 3 of 9 image in .NET framework applications.www.OnBarcode.com
CH APT ER 3 O BJECT -O RIEN TED A PPLI CA TI O N D ESI GN
Universal Product Code Version A Generator In C#.NET
Using Barcode creation for Visual Studio .NET Control to generate, create UPC A image in .NET applications.www.OnBarcode.com
Code 128B Generation In Visual C#.NET
Using Barcode generator for Visual Studio .NET Control to generate, create ANSI/AIM Code 128 image in .NET applications.www.OnBarcode.com
Figure 3-18. Adding the PTracker database in Visual Studio Visual Studio will force you to walk through the process of creating a DataSet for the new database. You can walk through or cancel that wizard as you choose. It is not required for anything covered in this book. Repeat the process to add a Security.mdf database as well. The end result is that you ll have two databases in the project and more importantly, in the Server Explorer window, as shown in Figure 3-19.
Matrix 2D Barcode Drawer In C#.NET
Using Barcode creator for VS .NET Control to generate, create Matrix image in .NET framework applications.www.OnBarcode.com
Creating UCC - 14 In Visual C#
Using Barcode generation for .NET Control to generate, create EAN - 14 image in VS .NET applications.www.OnBarcode.com
Figure 3-19. The PTracker and Security databases in Server Explorer You can also create tables within Server Explorer: just right-click the Tables node under the database, and choose New Table. This will bring up a table designer in VS .NET, with which you can define the columns for the new table.
Generate PDF417 In None
Using Barcode printer for Office Excel Control to generate, create PDF 417 image in Office Excel applications.www.OnBarcode.com
PDF-417 2d Barcode Drawer In None
Using Barcode creator for Font Control to generate, create PDF417 image in Font applications.www.OnBarcode.com
C HA PTER 3 OBJEC T-ORIE NTED APPLIC ATION DES IGN
Code 128 Printer In None
Using Barcode generator for Excel Control to generate, create Code128 image in Office Excel applications.www.OnBarcode.com
Read GTIN - 12 In Visual C#
Using Barcode reader for .NET framework Control to read, scan read, scan image in .NET applications.www.OnBarcode.com
Once the columns, keys, and indexes have been set up, save the changes by closing the designer or clicking the Save button in the toolbar. At this point, you ll be prompted to provide a name for the table, and it will be added to the database.
PDF417 Scanner In Visual Basic .NET
Using Barcode decoder for .NET Control to read, scan read, scan image in Visual Studio .NET applications.www.OnBarcode.com
PDF-417 2d Barcode Creation In Java
Using Barcode creator for Java Control to generate, create PDF 417 image in Java applications.www.OnBarcode.com
Code 39 Extended Creator In Java
Using Barcode generation for Android Control to generate, create Code 3/9 image in Android applications.www.OnBarcode.com
Creating QR-Code In Objective-C
Using Barcode encoder for iPhone Control to generate, create QR Code image in iPhone applications.www.OnBarcode.com
Follow this process to add each of the following four tables to the database.
UCC - 12 Generator In None
Using Barcode creation for Software Control to generate, create UPCA image in Software applications.www.OnBarcode.com
Barcode Maker In .NET
Using Barcode encoder for VS .NET Control to generate, create Barcode image in .NET applications.www.OnBarcode.com
UPCA Decoder In Visual Studio .NET
Using Barcode reader for .NET Control to read, scan read, scan image in VS .NET applications.www.OnBarcode.com
Drawing Code 128 In VS .NET
Using Barcode generation for Reporting Service Control to generate, create Code 128 image in Reporting Service applications.www.OnBarcode.com
The Roles table will store the list of possible roles a resource can fill when assigned to a project it simply contains an Id value and the name of the role. Figure 3-20 shows the VS .NET designer with these columns added and the Id column configured as the primary key.
Figure 3-20. Design of the Roles table Notice that none of the columns allow null values. There s no business requirement to differentiate between an empty value and one that was never entered, so null values would make no sense. The table also has a LastChanged column, which will be used to implement otimistic, first-writewins concurrency in 18. It is of type timestamp, so it provides a unique, auto-incrementing value every time a row is inserted or updated. All the tables in the PTracker database will have this type of column.
The Projects table will contain the data for each project in the system. The columns for this table are shown in Figure 3-21.
Figure 3-21. Design of the Projects table The Id column is set up as the primary key, and it s of type uniqueidentifier, which is a Guid type in .NET.
CH APT ER 3 O BJECT -O RIEN TED A PPLI CA TI O N D ESI GN
There are many ways to create primary key columns in tables, including using auto-incrementing numeric values or user-assigned values. However, the use of a uniqueidentifier is particularly powerful when working with object-oriented designs. Other techniques don t assign the identifier until the data is added to the database, or they allow the user to provide the value, which means that you can t tell if it collides with an existing key value until the data is added to the database. With a uniqueidentifier, however, the business developer can write code to assign the primary key value to an object as the object is created. There s no need to wait until the object is inserted into the database to get or confirm the value. If the value isn t assigned ahead of time, the database will supply the value. Notice that the two datetime fields allow null values. The null value is used here to indicate an empty value for a date. The Description column is also allowed to be null. This isn t because of any business requirement, but rather because it is quite common for database columns to allow null values in cases in which they re meaningless. 18 will illustrate how to easily ignore any null values in this column. The Description column is of type varchar(MAX) so that it can hold a blob of text data. This field allows the user to enter a lengthy description of the project, if so desired.