DotNetNuke - Modules - Creating The Tables
On Tuesday we installed the free version of CodeSmith to help us create the database access code. Before we can create the access code, we need some tables in our system. Even if you think you know all about creating tables in a database, don’t skip this lesson. There are some very specific tips related to working with DotNetNuke that you will miss if you skip it.
Here are some helpful tips for creating tables in the DotNetNuke database:
- Prefix your table names with some unique identifier related to your organization and/or project. (For example, I prefix all of my table names with dmbcllc.) This will be useful when using CodeSmith to generate your scripts. (Trust me.) I’ll tell you more about this when we run the scripts.
- Create an identity field call ID that is an integer and auto-incrementing for each table.
This makes the identity field clear to everyone looking at the code and ensures that you have at least one field that is unique. Again, this will be important as we write our access code.Some people like naming this field TableNameID. That will work, too. I just find naming it ID clearer. - Make the ID field the primary key.
Again, this is critical to making the data access code work properly. - When creating a field in a table that points to the ID field in a second table, name the field TableNameID.
For example, if you have an Address table with an ID field and you have an Employee table that needs to point to the ID field for entity relationship purposes, name the field in Employee AddressID. This makes it clear to everyone that the field is pointing to the ID field in the Address table. - PascalCase all of your field names.
I know that historically words in database field names have been Underscore_Separated, but we are going to use the tables and field names to create DataTables in our .NET code. If you create a DataSet against a table that has Underscore_Separated words, you will end up with properties in your DataSet with Underscore_Separated words. Since the code you will spend most of your time working with will be the DataSet, we want to ensure that we end up with PascalCased properties. To do that, we need PascalCased field names. (Of course, you should make your table names PascalCased as well.) - If you have entity relationships between the tables, set them up now.
By doing so, these relationships will remain established when you create your datasets, allowing your datasets to maintain the referential integrity of the tables prior to sending the data down to the database.
Other post in DotNetNuke - Module Development
- Creating DotNetNuke Modules - May 20th, 2008
- Creating DNN Modules - The Tools - May 22nd, 2008
- DotNetNuke Modules - Foundational Concepts - May 26th, 2008
- DotNetNuke Modules - Install DNN into VS 2008 - May 27th, 2008
- DotNetNuke Modules - Creating Base Modules - May 28th, 2008
- DotNetNuke Modules - Registering Your Module - May 29th, 2008
- DotNetNuke Modules - Where Stuff Shows Up - June 3rd, 2008
- DotNetNuke Modules - Benefits of Architecture - June 4th, 2008
- DotNetNuke Modules - Anatomy of the View - June 9th, 2008
- DotNetNuke Modules - Adding Actions - June 11th, 2008
- DotNetNuke Modules - DNN Controls - Label - June 18th, 2008
- DotNetNuke - Internationalization - June 25th, 2008
- DotNetNuke Modules - Internationalization (part 2) - June 30th, 2008
- DotNetNuke Modules - Labels w/ no Help - July 9th, 2008
- DotNetNuke Modules - LinkButtons - July 14th, 2008
- DotNetNuke Modules - Collapsible Panels - July 16th, 2008
- DotNetNuke - The Data Layer - Installing CodeSmith - July 22nd, 2008
- DotNetNuke - Modules - Creating The Tables - July 24th, 2008
- DotNetNuke - Modules - Creating Stored Procs - July 29th, 2008
- DotNetNuke - Modules - Portal Specific Modules - July 31st, 2008
- DotNetNuke Modules - Data Access Layer - August 5th, 2008
- DotNetNuke Modules - Data Access Layer - August 7th, 2008
- DotNetNuke - Data Access Layer Alternative - August 12th, 2008
- DotNetNuke - Modules - Linking within the module - August 14th, 2008
- DotNetNuke - Make Your Module Searchable - August 19th, 2008
- DotNetNuke Modules - Making Content Portable - August 25th, 2008
- DotNetNuke Modules - Exceptions the DNN Way - September 2nd, 2008
- DotNetNuke Modules - PortalModuleBase - September 4th, 2008
- DotNetNuke Modules - Inter Module Communication - September 9th, 2008
- DotNetNuke Modules - Finding The Page a Module is On - September 15th, 2008
- DotNetNuke Modules - Caching - September 17th, 2008
- DotNetNuke Modules - Module Settings - September 22nd, 2008
- DotNetNuke Modules - Retrieving Settings - September 24th, 2008
- DotNetNuke Modules - Advanced Architecture - October 20th, 2008
- DotNetNuke Modules - Creating the PA - October 30th, 2008
- DotNetNuke Modules - Automating the PA - November 5th, 2008
If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!




















































September 30th, 2008 at 6:07 am
I find your video tutorial extremely helpful. As a complete beginner, I would appreciate a video for this step of the tutorial. Do we create the table from within the site Host - SQL paste create procedure, or do we create the table from within Visual Studio Server explorer? Or SQL Server Management express?
September 30th, 2008 at 6:32 am
Whatever tool works for you.
I would recommend using either Visual Studio, SQL Server Management Studio or SQL Server Management Studio Express.