Solved

Credit card data, what datatype / length.

Posted on 2004-09-14
4
511 Views
Last Modified: 2013-11-18
Morning experts,  I want to update our old database fields we are using for credit cards.  Right now they are all varchar, but I wanted to find out what I should use for lengths and datatype for the following:

Card type (visa mastercard etc)
Card number
Experation date


0
Comment
Question by:moonrisesystems
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 10

Expert Comment

by:AaronAbend
ID: 12055280
for a card type I would use a char(1) and select letters that can be used to quickly identify the card (M for mastercard for example). easier than an int and virtually no difference in performance. Make sure it is NOT NULL. Use some other character for "unknown" if you must

Card number should still be a varchar. You save very little space with a char and can accommodate any card type.

Expiration date should be a date. Use the last date of the month/year (some cards actually have a complete date). If you do not do that and go with a char or varchar you will cause yourself a lot of trouble with date math.

Those are my recommendations. I have worked with credit cards though it has not been my focus. Others may have better experience.

Aaron
0
 
LVL 8

Accepted Solution

by:
MartinCMS earned 125 total points
ID: 12055417
I have worked with database with credit cards info for more then 5 yrs.... thru many data type conversion before we have a stable set of data.  Here are my recommendations:

Card Type:   Varchar(20)     spell out the word Visa not just the V,M,A,etc.,
Card Number:   Varchar(20)
Card Expire:  Varchar(5)  mm/yy

you might want to consider the CVC or Card Code to.  This is the verification code from the back of the card.  Most Merchants required this number now.

CVC:  Varchar(5)

Good Luck!




0
 
LVL 7

Expert Comment

by:ChrisFretwell
ID: 12056786
This site is good to explain the different card types, their lengths and check digits.

http://www.beachnet.com/~hstiles/cardtype.html

You may want to be careful about storing the CVV. Its purpose, wehn used, is to prove that the person making the transaction is in physical posession of the card. Its not on the magnetic stripe and not printed on receipts. This will mean reduced loss if somehow your system is comprimised. It can also reduce chargebacks if you require this number to be entered each time. This increases customer confidence etc. But those are marketing/business issues. Just thought I'd throw them in.
0
 
LVL 10

Expert Comment

by:AaronAbend
ID: 12057429
If you store the year and month as a varchar, I would recommend formatting it YYMM (good for another 96 years at least) or YYYYMM so you can do easier queries if necessary. Depends on what you plan to do with the data of course (even just for validating the expiration has not been passed would be easier if it were in this format).
0

Featured Post

Edgartown IT Case Study

Learn about Edgartown's quest to ensure the safety and security of the entire town's employee and citizen data. Read the case study!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Original post  on Monitis Blog. Web performance monitoring is broken into two camps: passive and active. Passive monitoring is defined as looking at real-world historical performance by monitoring actual log-ins, site hits, clicks, requests for…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question