是否有可能在SQL saletable中使用存储数据制作销售方分类帐,而无需在C#中使用SQL表关系? [英] Is it possible to make sale party ledger with stored data in SQL saletable without SQL table relationships in C#?

查看:77
本文介绍了是否有可能在SQL saletable中使用存储数据制作销售方分类帐,而无需在C#中使用SQL表关系?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是编程的新手我正在使用c#编写交易软件,但我对sql server并不熟悉。我已经在sql server表中存储了值,例如partyNames,itemNames,SaleBill,PurchaseBill,Cash payments等。是否可以在sqlserver中制作没有表关系的股票分类帐报表和派对分类帐报表?



我尝试了什么:



i试图建立桌子的关系但是它太混乱因为我有这么多的字段在销售和购买账单。我不知道如何关联表字段。

i只将每个表的id与一个名为vouchers的新表相关联。

如果有可能,请回答没有表关系的报告

解决方案

我们无法真正告诉您 - 我们不知道您的数据是什么样的,或者您正在尝试实现的目标。但是我可以说这并不是任何有经验的人会这样做的。



坐下来,想想你的数据以及它在现实世界中的相关性。 />
想一下发票。

公司可能会向您发出几个订单,每个订单都需要一张发票。

每张发票可能是多个物品。

所以你最终有四张桌子:

物品

<前lang =text> ID主键,可能是IDENTITY或GUID
描述
价格

客户

 ID主键,可能是IDENTITY或GUID 
CustName
地址

发票

 ID主键,可能是IDENTITY或GUID 
InvoiceNo
InvoiceDate
terms
CustID到Customers.ID的外键

InvoiceItems

 ID主键,可能是IDENTITY或GUID 
InvoiceID外键至Invoices.ID
ItemID外国Items.ID的关键



您不希望不同表中的ID匹配,只是通过外键引用正确的值。

因此,当您处理订单时,您会查找客户ID,并使用该ID作为外键在Invoices表中创建一个新行。然后,您使用新的发票ID

在InvoiceLines表中创建每个新行作为外键返回整个发票。



合理?好。现在认为您的数据是相关的,以及您需要如何存储它。


可能吗?是的。



建议吗?地狱不!



你不会因为不了解人际关系的运作方式而轻松自己。你只是给自己多次手工完成所有关系变得更容易的工作,而不是你只是把工作放在了解关系数据库是如何工作的。



关系是表之间的关系,而不是字段。表中的记录彼此相关,包含数据,主键和外键,用于维护与其他表中记录的关系。


i am new in programming i am making a trading software in c# but i am not familiar with sql server so much. i have stored values in sql server tables like partyNames, itemNames, SaleBill, PurchaseBill, Cash payments etc. is it possible to make stock ledger reports and party ledger reports without table relationships in sqlserver?

What I have tried:

i tried to make relationship of tables but it is so confusing because i have so many fields in sale and purchase bills. And i don't know how to relate table fields.
i only related every table's id to a new table named vouchers.
please just answer that if it is possible to make reports without table relationships

解决方案

We can't really tell you - we have no idea what your data looks like, or exactly what you are trying to achieve. But I can say it's not the way anyone with any experience would go.

Sit back, think about your data and how it is related in the real world.
Think of invoices for a moment.
A company may make several orders with you, each order needs an invoice.
Each invoice may be for multiple items.
So you end up with four tables:
Items

ID            Primary key, probably IDENTITY or GUID
Description
Price

Customers

ID            Primary key, probably IDENTITY or GUID
CustName
Address

Invoices

ID            Primary key, probably IDENTITY or GUID
InvoiceNo     
InvoiceDate
terms
CustID        Foreign key to Customers.ID

InvoiceItems

ID            Primary key, probably IDENTITY or GUID
InvoiceID     Foreign key to Invoices.ID
ItemID        Foreign key to Items.ID


At no point do you expect the ID's in the different tables to match, just that they reference the correct value via foreign keys.
So when you process an order, you look up the Customer ID, and create a new row in the Invoices table using that ID as the foreign key. You then use that new Invoice ID
to create each new line in the InvoiceLines tables as the Foreign key back to the overall invoice.

Make sense? Good. Now think your data relates, and how you need to store it.


Possible? Yes.

Advisable? Hell no!

You're not going to make it easy on yourself by not understanding how relationships work. You're just giving yourself many times the amount of work manually doing all of the things that relationships make easier than if you just put the work in to understand how relational databases work.

Relationships are between tables, not fields. Records in tables are related to each other and contain data, primary and foreign keys, that maintain the relationships to records in other tables.


这篇关于是否有可能在SQL saletable中使用存储数据制作销售方分类帐,而无需在C#中使用SQL表关系?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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