更好或更糟的鼠标陷阱? [英] Better or worse mouse trap?

查看:62
本文介绍了更好或更糟的鼠标陷阱?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个数据库项目并且刚开始离开

来自我的新手习惯,比如在用户字段中存储用户名,

文字。我现在已经将Name字段替换为NameID字段,并将此

字段作为外键映射到用户表,其中它是PK。我正在尝试基于真实的关系模型构建应用程序。这将在Name字段和其他字段中节省很多

的空间,因为ID整数替换了

的文本字符串。


我遇到的问题是在绑定过程中看似浪费处理能力
,以及发生的频率。主表绑定到一个

DataGrid,我现在不能将每个ItemTemplate单​​元格绑定到主表中的

对应文本。现在我必须在绑定ID作为参数时调用代码隐藏的

函数,并让函数

找出ID和Name之间的映射,然后将名称

发送回ASP.NET进行演示。


然后当几个DropDownLists获得
$ b时,必须在EditMode中再次发生这种情况$ b进入行为,再次,我调用代码隐藏函数来计算文本属于SelectedItem的



这不是大数据;这是小数据,也许是几千行

,每个12-15个字段。


在某种程度上这似乎更浪费处理器比什么更好的资源

我正在节省未使用的磁盘存储空间。


这是一个更好的鼠标陷阱还是更糟糕的陷阱?我想我正在做这个

" right"方式,关于使用关系模型。我只是不确定

这是值得的。谢谢你的意见。 ~Paul


发送http://www.developersdex.com ***

不要只是参加USENET ......获得奖励!

解决方案

我想你会发现,使用pk

参考,你所描述的新方式,将使编程和处理工作更顺畅作为

你去。不仅是关系数据库建模,还有当你创建彼此相关的对象时。


-Darrin



" Paul" <无***************** @ msn.com>在留言中写道

news:Ou **************** @ tk2msftngp13.phx.gbl ...

我我正在建立一个数据库项目,并且刚刚开始远离我的新手习惯,即在用户字段中存储用户名,作为
文本。我现在已经用NameID字段替换了Name字段,并将此
字段作为外键映射到用户表,其中它是PK。我正在尝试基于真实的关系模型构建应用程序。这将在Name字段和其他字段中节省大量空间,因为ID整数替换了文本字符串。

我遇到的问题是看似浪费处理能力
绑定期间,以及发生的频率。主表绑定到DataGrid,我现在不能将每个ItemTemplate单​​元格绑定到主表中的相应文本。现在我必须在使用ID作为参数绑定期间调用代码隐藏功能,并让函数
找出ID和Name之间的映射,然后发送名称
在ASP.NET中进行演示。

然后,当几个DropDownLists进入行为时,必须在EditMode中再次发生这种情况,再次,我调用代码隐藏函数来弄明白
该文本属于SelectedItem。

这不是大数据;这是一个很小的数据,也许是几千行
每个都有12-15个字段。

在某种程度上,这一切似乎都比处理器资源更浪费
我节省了未使用的磁盘存储空间。

这是一个更好的鼠标陷阱还是更糟糕的陷阱?我想我正在做这个
正确的方式,关于使用关系模型。我只是不确定它是否值得。谢谢你的意见。 ~Paul


***通过开发人员指南 http:// www.developersdex.com ***
不要只是参加USENET ......获得奖励!



保罗,


您是否需要分享一些代码,我感觉您的数据适配器

一次性提取太多信息,有一些方法可以通过查询排序来缩短您的

选择,并使用参数将其传递给

您的查询以提高效率。至于绑定文本框,我可能会为你提供一些信息以及你甚至想要做一些

更新等等。


我会留意这个帖子,只需回复,我想帮助我支付
即可。


Sincerly ,


Nikerz Inc


" Paul" <无***************** @ msn.com>在留言中写道

news:Ou **************** @ tk2msftngp13.phx.gbl ...

我我正在建立一个数据库项目,并且刚刚开始远离我的新手习惯,即在用户字段中存储用户名,作为
文本。我现在已经用NameID字段替换了Name字段,并将此
字段作为外键映射到用户表,其中它是PK。我正在尝试基于真实的关系模型构建应用程序。这将在Name字段和其他字段中节省大量空间,因为ID整数替换了文本字符串。

我遇到的问题是看似浪费处理能力
绑定期间,以及发生的频率。主表绑定到DataGrid,我现在不能将每个ItemTemplate单​​元格绑定到主表中的相应文本。现在我必须在使用ID作为参数绑定期间调用代码隐藏功能,并让函数
找出ID和Name之间的映射,然后发送名称
在ASP.NET中进行演示。

然后,当几个DropDownLists进入行为时,必须在EditMode中再次发生这种情况,再次,我调用代码隐藏函数来弄明白
该文本属于SelectedItem。

这不是大数据;这是一个很小的数据,也许是几千行
每个都有12-15个字段。

在某种程度上,这一切似乎都比处理器资源更浪费
我节省了未使用的磁盘存储空间。

这是一个更好的鼠标陷阱还是更糟糕的陷阱?我想我正在做这个
正确的方式,关于使用关系模型。我只是不确定它是否值得。谢谢你的意见。 ~Paul


***通过开发人员指南 http:// www.developersdex.com ***
不要只是参加USENET ......获得奖励!



如果你没有机会在这里发布代码,这里的网址可能是

帮助你。

http://www.w3schools.com/sql/sql_join.asp

基本上,您应该让数据库将id加入名称。您可能

不应该在代码隐藏中编写代码来执行此操作。


最简单的代码是这样的:(对于上面的示例

员工和订单)。


SELECT Employees.Name作为名称,Orders.Product作为产品

来自员工,订单

WHERE Employees.Employee_ID = Orders.Employee_ID


我会先使用类似的东西,然后在JOIN上阅读

关键字。


从数据库返回的数据表/数据集将有一列

名称和一列您可以轻松绑定到的产品当名称

与订单存储在同一个表中时。将用户名移动到专用的

用户表应该对您的Web代码影响很小(除了更改用于获取信息的sql语句或存储过程的
)。

- Mike Mayer,C#MVP

" Nikerz Inc" < NI ******* @ hotmail.com>在消息中写道

新闻:uw ************** @ TK2MSFTNGP12.phx.gbl ...

嗨Paul,排序和实际使用参数传递给您的查询,使其更有效。至于绑定文本框,我可以为你提供一些信息以及你甚至想要做一些
更新等等。

我会留意这个线程,只是回复,我想帮助我在哪里可以获得


非常好,

Nikerz Inc

;保罗" <无***************** @ msn.com>在消息中写道
新闻:Ou **************** @ tk2msftngp13.phx.gbl ...

我正在建设一个数据库项目,刚刚开始离开我的新手习惯,比如在用户字段中存储用户名,作为
文本。我现在已经用NameID字段替换了Name字段,并将此
字段作为外键映射到用户表,其中它是PK。我正在尝试基于真实的关系模型构建应用程序。这将在Name字段和其他字段中节省大量空间,因为ID整数替换了文本字符串。

我遇到的问题是看似浪费处理能力
绑定期间,以及发生的频率。主表绑定到DataGrid,我现在不能将每个ItemTemplate单​​元格绑定到主表中的相应文本。现在我必须在使用ID作为参数绑定期间调用代码隐藏功能,并让函数
找出ID和Name之间的映射,然后发送名称
在ASP.NET中进行演示。

然后,当几个DropDownLists进入行为时,必须在EditMode中再次发生这种情况,再次,我调用代码隐藏函数来弄明白
该文本属于SelectedItem。

这不是大数据;这是一个很小的数据,也许是几千行
每个都有12-15个字段。

在某种程度上,这一切似乎都比处理器资源更浪费
我节省了未使用的磁盘存储空间。

这是一个更好的鼠标陷阱还是更糟糕的陷阱?我想我正在做这个
正确的方式,关于使用关系模型。我只是不确定它是否值得。谢谢你的意见。 ~Paul


***通过开发人员指南 http:// www.developersdex.com ***
不要只是参加USENET ......获得奖励!




Hi, I''m building a database project and have just started getting away
from my newbie habit of storing, say, User names in a User field, as
text. I''ve now replaced the Name field with a NameID field and map this
field as a Foreign Key to a User table where it is a PK. I''m trying to
build the app based upon a real relational model. This will save a lot
of space in the Name field and other fields as the ID integers replace
the text strings.

The problem I have with it is the seeming waste of processing power
during binding, and how often that happens. The main table binds to a
DataGrid, and I can''t now just bind each ItemTemplate cell to the
corresponding text in the main table. Now I have to call a code-behind
function during binding with the ID as an argument and let the function
figure out the mapping between the ID and Name, and then send the Name
back to the ASP.NET for presentation.

Then this has to happen again in EditMode when several DropDownLists get
into the act, and again, I call a code-behind function to figure out
that text belongs in the SelectedItem.
This is not large data; it''s small data, maybe a couple of thousand rows
with 12-15 fields each.

In a way this all seems more wasteful of processor resources than what
I''m saving in unused disk storage.

Is this a better mouse trap or a worse one? I guess I''m doing it the
"right" way, with regard to using a relational model. I''m just not sure
it''s worth it. Thanks for you opinion. ~Paul


*** Sent via Developersdex http://www.developersdex.com ***
Don''t just participate in USENET...get rewarded for it!

解决方案

I think you''ll find that doing it the new way you have described, using a pk
reference, will make things work smoother in programming and processing as
you go along. Not only with relational database modeling, but also when you
are creating objects that relate to one another.

-Darrin


"Paul" <no*****************@msn.com> wrote in message
news:Ou****************@tk2msftngp13.phx.gbl...

Hi, I''m building a database project and have just started getting away
from my newbie habit of storing, say, User names in a User field, as
text. I''ve now replaced the Name field with a NameID field and map this
field as a Foreign Key to a User table where it is a PK. I''m trying to
build the app based upon a real relational model. This will save a lot
of space in the Name field and other fields as the ID integers replace
the text strings.

The problem I have with it is the seeming waste of processing power
during binding, and how often that happens. The main table binds to a
DataGrid, and I can''t now just bind each ItemTemplate cell to the
corresponding text in the main table. Now I have to call a code-behind
function during binding with the ID as an argument and let the function
figure out the mapping between the ID and Name, and then send the Name
back to the ASP.NET for presentation.

Then this has to happen again in EditMode when several DropDownLists get
into the act, and again, I call a code-behind function to figure out
that text belongs in the SelectedItem.
This is not large data; it''s small data, maybe a couple of thousand rows
with 12-15 fields each.

In a way this all seems more wasteful of processor resources than what
I''m saving in unused disk storage.

Is this a better mouse trap or a worse one? I guess I''m doing it the
"right" way, with regard to using a relational model. I''m just not sure
it''s worth it. Thanks for you opinion. ~Paul


*** Sent via Developersdex http://www.developersdex.com ***
Don''t just participate in USENET...get rewarded for it!



Hi Paul,

Would you have some code to share, I have a feeling that your data adapter
is pulling too much information at once, there is a few ways to shorten your
selection with a query of a sort and acutally using parameters to pass to
your query to make it more efficient. As for binding the textboxes I might
have some information for you as well incase you even want to do some
updates and such.

I''ll keep an eye on this thread, just reply and I''d like to help out where I
can.

Sincerly,

Nikerz Inc

"Paul" <no*****************@msn.com> wrote in message
news:Ou****************@tk2msftngp13.phx.gbl...

Hi, I''m building a database project and have just started getting away
from my newbie habit of storing, say, User names in a User field, as
text. I''ve now replaced the Name field with a NameID field and map this
field as a Foreign Key to a User table where it is a PK. I''m trying to
build the app based upon a real relational model. This will save a lot
of space in the Name field and other fields as the ID integers replace
the text strings.

The problem I have with it is the seeming waste of processing power
during binding, and how often that happens. The main table binds to a
DataGrid, and I can''t now just bind each ItemTemplate cell to the
corresponding text in the main table. Now I have to call a code-behind
function during binding with the ID as an argument and let the function
figure out the mapping between the ID and Name, and then send the Name
back to the ASP.NET for presentation.

Then this has to happen again in EditMode when several DropDownLists get
into the act, and again, I call a code-behind function to figure out
that text belongs in the SelectedItem.
This is not large data; it''s small data, maybe a couple of thousand rows
with 12-15 fields each.

In a way this all seems more wasteful of processor resources than what
I''m saving in unused disk storage.

Is this a better mouse trap or a worse one? I guess I''m doing it the
"right" way, with regard to using a relational model. I''m just not sure
it''s worth it. Thanks for you opinion. ~Paul


*** Sent via Developersdex http://www.developersdex.com ***
Don''t just participate in USENET...get rewarded for it!



In case you don''t have a chance to post code here, here''s a url that might
help you.

http://www.w3schools.com/sql/sql_join.asp

Basically, you should let the database join the id to the name. You probably
should not be writing code in the code-behind to do it.

The simplest code is something like this: (for the above example of
employees and orders).

SELECT Employees.Name as Name, Orders.Product as Product
FROM Employees, Orders
WHERE Employees.Employee_ID=Orders.Employee_ID

I would use something simple like that at first, then read up on the JOIN
keyword.

The datatable / dataset returned from the database will then have a column
Name and a column Product that you can just bind to as easily as when name
was stored in the same table as orders. Moving user names to a dedicated
users table should have very little affect on your web code (other than
changing the sql statement or stored procedure used to get the information).
- Mike Mayer, C# MVP
"Nikerz Inc" <ni*******@hotmail.com> wrote in message
news:uw**************@TK2MSFTNGP12.phx.gbl...

Hi Paul,

Would you have some code to share, I have a feeling that your data adapter
is pulling too much information at once, there is a few ways to shorten your selection with a query of a sort and acutally using parameters to pass to
your query to make it more efficient. As for binding the textboxes I might have some information for you as well incase you even want to do some
updates and such.

I''ll keep an eye on this thread, just reply and I''d like to help out where I can.

Sincerly,

Nikerz Inc

"Paul" <no*****************@msn.com> wrote in message
news:Ou****************@tk2msftngp13.phx.gbl...

Hi, I''m building a database project and have just started getting away
from my newbie habit of storing, say, User names in a User field, as
text. I''ve now replaced the Name field with a NameID field and map this
field as a Foreign Key to a User table where it is a PK. I''m trying to
build the app based upon a real relational model. This will save a lot
of space in the Name field and other fields as the ID integers replace
the text strings.

The problem I have with it is the seeming waste of processing power
during binding, and how often that happens. The main table binds to a
DataGrid, and I can''t now just bind each ItemTemplate cell to the
corresponding text in the main table. Now I have to call a code-behind
function during binding with the ID as an argument and let the function
figure out the mapping between the ID and Name, and then send the Name
back to the ASP.NET for presentation.

Then this has to happen again in EditMode when several DropDownLists get
into the act, and again, I call a code-behind function to figure out
that text belongs in the SelectedItem.
This is not large data; it''s small data, maybe a couple of thousand rows
with 12-15 fields each.

In a way this all seems more wasteful of processor resources than what
I''m saving in unused disk storage.

Is this a better mouse trap or a worse one? I guess I''m doing it the
"right" way, with regard to using a relational model. I''m just not sure
it''s worth it. Thanks for you opinion. ~Paul


*** Sent via Developersdex http://www.developersdex.com ***
Don''t just participate in USENET...get rewarded for it!




这篇关于更好或更糟的鼠标陷阱?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆