|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
General (newbie) design question about fields naming and aliasesI'm using the Dataset Designer Tool to create datasets for my VB.NET 2005 application. In my SQL Server tables I have odd field names, like "PWD_EXP" or "SYS_NAME". I have to show these fields to the user in a datagrid, so I have to present them with another naming convention (like "Password Expiration" and "System Name"). My question is very simple : should i use aliases in my query, to "fix" the name directly in my SQL query, so that even the Dataset and my business logic contains correct names ("Password Expiration" instead of "PWD_EXP"), or should i leave the name fields as they are, and then modify only the Header Captions of my grids? I know it's a very stupid question, but i'm always asking me what is the best practice to do :) Thank you i.a., best regards Marco Try using CamelCase for your names--avoiding imbedded spaces. I think you'll
discover that the DataGridView converts CamelCase columns like AuthorName to "Author Name"... -- Show quote____________________________________ William (Bill) Vaughn Author, Mentor, Consultant Microsoft MVP INETA Speaker www.betav.com/blog/billva www.betav.com Please reply only to the newsgroup so that others can benefit. This posting is provided "AS IS" with no warranties, and confers no rights. __________________________________ Visit www.hitchhikerguides.net to get more information on my latest book: Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition) and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook) ----------------------------------------------------------------------------------------------------------------------- "M. Simioni" <m.simi***@gmail.com> wrote in message news:1172162371.334280.107080@j27g2000cwj.googlegroups.com... > Hi, > I'm using the Dataset Designer Tool to create datasets for my VB.NET > 2005 application. > > In my SQL Server tables I have odd field names, like "PWD_EXP" or > "SYS_NAME". > > I have to show these fields to the user in a datagrid, so I have to > present them with another naming convention (like "Password > Expiration" and "System Name"). > > My question is very simple : > should i use aliases in my query, to "fix" the name directly in my SQL > query, so that even the Dataset and my business logic contains correct > names ("Password Expiration" instead of "PWD_EXP"), or should i leave > the name fields as they are, and then modify only the Header Captions > of my grids? > > I know it's a very stupid question, but i'm always asking me what is > the best practice to do :) > > Thank you i.a., > best regards > > Marco > > Try using CamelCase for your names--avoiding imbedded spaces. I think you'll Ok, thank you.> discover that the DataGridView converts CamelCase columns like AuthorName to > "Author Name"... > And what about names like "PWD_EXP" that i have to present as "PasswordExpiration" in the DataGridView? Should i "convert" them with aliases directly in sql queries, or should i leave them as they are, and then rename the Heading captions? They seems to be stupid questions but i'd like to know what's the best practice to simplify the life of who will work again at my code. Thank you for your answers, Marco There are any number of approaches. I prefer to use stored procedures or
Views that expose the data in a standard (more easily consumed) way. Here you can provide column aliases as needed. The book is full of "best practice" suggestions--it was written to answer questions (like this) we've seen on this and other aliases over the last decade. -- Show quote____________________________________ William (Bill) Vaughn Author, Mentor, Consultant Microsoft MVP INETA Speaker www.betav.com/blog/billva www.betav.com Please reply only to the newsgroup so that others can benefit. This posting is provided "AS IS" with no warranties, and confers no rights. __________________________________ Visit www.hitchhikerguides.net to get more information on my latest book: Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition) and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook) ----------------------------------------------------------------------------------------------------------------------- "M. Simioni" <m.simi***@gmail.com> wrote in message news:1172167864.323691.157880@m58g2000cwm.googlegroups.com... >> Try using CamelCase for your names--avoiding imbedded spaces. I think >> you'll >> discover that the DataGridView converts CamelCase columns like AuthorName >> to >> "Author Name"... >> > Ok, thank you. > And what about names like "PWD_EXP" that i have to present as > "PasswordExpiration" in the DataGridView? Should i "convert" them with > aliases directly in sql queries, or should i leave them as they are, > and then rename the Heading captions? > They seems to be stupid questions but i'd like to know what's the best > practice to simplify the life of who will work again at my code. > Thank you for your answers, > Marco > I have done it a few ways.
Alias in query. Great for reporting types applications, as the data is only one way. Not so good when returning to the server, as you have to match the fields back. Alias in DataSet. This requires a small bit of work, but helps with roundtrip, esp. if you, or members of your team, are fond of drag and drop coding. Wait for .NET 3.5 (later this year) and use Object Spaces (or whatever it is going to be called). You can play with the Orcas betas if you are an MSDN subscriber. Use another O/R Mapper. -- Show quoteGregory A. Beamer MVP; MCP: +I, SE, SD, DBA http://gregorybeamer.spaces.live.com ******************************************** Think outside the box! ******************************************** "M. Simioni" <m.simi***@gmail.com> wrote in message news:1172162371.334280.107080@j27g2000cwj.googlegroups.com... > Hi, > I'm using the Dataset Designer Tool to create datasets for my VB.NET > 2005 application. > > In my SQL Server tables I have odd field names, like "PWD_EXP" or > "SYS_NAME". > > I have to show these fields to the user in a datagrid, so I have to > present them with another naming convention (like "Password > Expiration" and "System Name"). > > My question is very simple : > should i use aliases in my query, to "fix" the name directly in my SQL > query, so that even the Dataset and my business logic contains correct > names ("Password Expiration" instead of "PWD_EXP"), or should i leave > the name fields as they are, and then modify only the Header Captions > of my grids? > > I know it's a very stupid question, but i'm always asking me what is > the best practice to do :) > > Thank you i.a., > best regards > > Marco > |
|||||||||||||||||||||||