SQL:在一个查询或每个表的查询中从多个表中选择? [英] SQL: Selecting from multiple tables in one query or a query for each table?

查看:120
本文介绍了SQL:在一个查询或每个表的查询中从多个表中选择?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于DAL层部分的跟进问题。关于处理的第一个问题大对象



我有一个表(PlacesTable)与6个其他表相连(1:Many and Many:Many relations)



在我的DAL中,我应该添加一个大的查询,加入6个表格+ m:m个参考表(btw它生成多个不需要的数据请参阅我的旧问题),并将所有数据放在其特定的对象属性中,或者我应该为每个表使用单个查询并为每个获取的表创建一个对象..并最终将它们发送到UI?



如果我不够清楚,请让我知道我进一步的信息需要知道!



提前感谢您的时间和帮助=)

解决方案

一个查询返回用户界面所需的所有信息,您最好用。



每个数据库连接速度都会很慢,您将不得不等待所有这些信息完成在您的数据准备好用于UI之前。



应用程序和SQL服务器之间最慢的事情是建立连接的行为 - 越少越好。 / p>

A follow up question concerning the DAL layer part .. The first question about dealing with large objects

I have one table (PlacesTable) that is connected by like 6 other tables (1:Many and Many:Many relations)

In my DAL should I put a big query that join the 6 tables + the m:m reference tables (btw it produces multiple data that I don't need Please refer to my old question) and place all the data in it's specific object property or, should I use a single query for each table and create an object for each fetched table .. and finally send those to the UI ?

If I wasn't clear enough please let me know what I further information do you need to know!

Thanks in advance for your time and help =)

解决方案

You are better off with a single query returning all the information required for the UI.

Each database connection will be slow and you will have to wait for all of them to finish before having your data ready for the UI.

The slowest thing between the application and the SQL server is the act of establishing connections - the less of them, the better.

这篇关于SQL:在一个查询或每个表的查询中从多个表中选择?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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