简体   繁体   English

我有一个表,该表具有由三列组成的主键。 如何索引此表?

[英]I have a table which has a primary key that is made of three columns. How do I index this table?

Betting houses function like this: every week there are two rounds, and in each round when someone wants to make a ticket he gets a number for that round (first ticket of that round(1), second (2)...). 博彩公司的运作方式是这样的:每周进行两次回合,每回合中有人要出票时,他都会获得该回合的号码(该回合的第一张票(1),第二张票(2)...)。 I have a ticket table of all entered tickets of a betting-house company. 我有一个投注站公司所有已输入票务的票务表。

This table has 30 columns of all the details of each ticket. 该表包含每个票证的所有详细信息的30列。 The primary key is (location, round, number) I explained this number as being the number of the ticket within that round, and the location is the location of the bet-house (a betting company has many bet-houses in different locations). 主键是(位置,回合,号码),我将此数字解释为该回合中的彩票号码,而位置则是下注公司的位置(下注公司在不同位置有很多下注公司) 。 I want to select each ticket one by one, but I do not know how to have some sort of organized way. 我想一张一张地选择每张票,但是我不知道如何有一种有组织的方式。 If the a single column with auto-increment integer type that would be easy. 如果单个列具有自动递增的整数类型,那将很容易。 I just want to some how index this triplet primary key to go through a loop to select each entry incrementally. 我只想了解如何索引此三元组主键以通过循环逐步选择每个条目。 I am using C# to do this? 我正在使用C#来做到这一点?

As you did not provide the real purpose of your task, I can think of 2 situations. 由于您没有提供任务的真正目的,因此我可以想到两种情况。

Firstly, you want to read the table in some smaller batches for processing/evaluation. 首先,您要分批读取表格以进行处理/评估。 In this case you have to make sure the table is immutable and run SELECT ... ORDER BY number, round, bethouse OFFSET 0 LIMIT 1000 , OFFSET 1000 LIMIT 1000 , OFFSET 2000 LIMIT 1000 and so on until you come to the last row. 在这种情况下,您必须确保表是不可变的,然后运行SELECT ... ORDER BY number, round, bethouse OFFSET 0 LIMIT 1000OFFSET 1000 LIMIT 1000OFFSET 2000 LIMIT 1000等等,直到到达最后一行。

Secondly, you want to process the new incoming rows. 其次,您要处理新的传入行。 In that case there is no way you can solve that with only the multicolumn PK. 在这种情况下,仅使用多列PK是无法解决的。 You have to add a column with an autoincrement value or a date column (ie when the row was created). 您必须添加具有自动增量值的列或日期列(即创建行时)。 Then you order the results by this column and watch for new rows with WHERE mycolumn > {LastReadValue} . 然后,您可以按此列对结果进行排序,并使用WHERE mycolumn > {LastReadValue}监视新行。

Hope that helps. 希望能有所帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将对数据表所做的更改提交到从中获取的表中? - How do I commit the changes I have made to a DataTable to the Table from which I grabbed it? 我如何播种具有外键的表,该表在模型中被指定为对象,但在表中被指定为GUID - How do i seed a table that has a foreign key, which is specified as an object in the model, but as a guid in the table 如何创建一个DbSyncForeignKeyConstraint到表具有复合主键 - how do I create a DbSyncForeignKeyConstraint to a table with a composite Primary Key 如何创建具有复合键的表,其中每个成员都是其他表的外键成员 - How do I create a table that has a composite key each member of which is a foreign key member to other tables 如何以编程方式复制具有复合键的MS Access表架构? - How do I programmatically copy MS Access table schema which has composite key? 如何获取表的PRIMARY KEY COLUMNS(如果是COMPOSITE主键) - How to get PRIMARY KEY COLUMNS of a table (in case of COMPOSITE primary key) 如何创建一个UserControl,它的控件映射到Database DataRow列。 C#Winforms - How do you create a UserControl which has controls mapped to Database DataRow columns. C# Winforms 如何获取ADO.NET中的主键列? - How do I get the primary key columns in ADO.NET? 我如何映射表的主键和标识符不是同一列? - How do I map a table were primary key and identifier is not the same column? 如何用自动增量主键在表中插入空行? - How do I insert an empty row in a table with an auto-Increment primary key?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM