检索规范化数据 [英] Retrieving normalized data

查看:70
本文介绍了检索规范化数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个销售表来存储每个销售操作

i知道存储每个销售数据行并将其产品名称或客户端名称作为字符串,这将使用大数据大小是不好的

我要将客户编号的销售操作存储为int

但是当通过select查询检索数据时该怎么办?

it返回客户端ID但我需要一个查询来返回客户端表中存储的客户端名称

最好的查询是什么?



我尝试过的事情:



是加入声明或工会还是什么?

1年后(例如)会有大量与客户端和产品名称相关的行由id

我应该用什么语句来处理那么多行?

I have a sells tables that stores every sell operation
i know that it's not good to store every sell data row and give it the product name or client name as strings, that will use large data size
i've to store the sell operation with the client id as int
but what to do when retrieveing data by select query?
it returns the client id's but i need a query to returns client name as it stored in clients table
what is the best query to do that?

What I have tried:

is that join statements or union or what?
after 1 year(for example) there will be a huge number of rows related to clients and product names by id
what statement should i use to handle that huge number of rows?

推荐答案

请先阅读问题的评论。



我建议从基础开始:教程:编写Transact-SQL语句Microsoft Docs [ ^ ]



作为Bruno( 0x01AA [ ^ ])在问题的评论中提到,要获取数据,你必须使用 SELECT语句 [ ^ ]。您可以使用加入 [ ^ ],见: SQL联接的可视化表示 [ ^ ]



因此,示例SELECT语句可能如下所示:

Please, read the comments to the question first.

I'd suggest to start with basics: Tutorial: Writing Transact-SQL Statements | Microsoft Docs[^]

As Bruno (0x01AA[^]) mentioned in the comment to the question, to fetch data, you have to use SELECT statement[^]. You can "link" 2 tables by using joins[^], see: Visual Representation of SQL Joins[^]

So, an example SELECT statement can look like this:
SELECT so.OperationId, so.Stuff, so.ClientId, ci.ClientName
FROM SellOperation AS so INNER JOIN Clients AS ci ON so.ClientId = ci.ClientId
WHERE so.ClientId = @ClientId





祝你好运!



Good luck!


这篇关于检索规范化数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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