0

これまでのところ、レシート情報を格納するテーブルがあります。

例えば:

TABLE receipt
receipt_ID (int)(primary key)
creditcard (int) //Last 4 digits of credit card.
purhcaseAmount (int)
transactionTypeID (int)
remainingBalance (int)

ほとんどの領収書にはクレジット カード番号の最後の 4 桁しか表示されないため、creditCard 列には 4 桁の制限があります。

ただし、一部の銀行では最初の 2 桁と最後の 2 桁が表示されるため、この情報をデータベースに保持したいと考えています。

このビジネス要件に適合するように、データベース設計をどのように変更しますか?

4

3 に答える 3

2

You may want to store multiple pieces of information about the credit card, such as name, card type, etc. For the number itself, why be clever? Just make it a varchar(19) and store it as 12****************34 or whatever other format you choose.

于 2012-07-16T19:33:18.253 に答える
2

I wouldn't use an int, even for the last 4 digits. As a rule of thumb, if the number you're storing makes no sense if it is added up, store it as a string.

于 2012-07-16T19:33:20.203 に答える
0

ビジネス要件が 4 桁を格納することである場合、それらが文字列のどこにあるかは重要ですか? この情報は何に使用されますか?

問題がない場合は、正規表現で数字を取得し、数字ではないものを無視して、数字をテーブルの列に詰め込みます。

于 2012-07-16T19:37:42.953 に答える