Right now I have 3 tables:
CREATE TABLE `tbl_payment_info` (
`payment_info_id` int(11) NOT NULL,
`user_id` int(11) NOT NULL,
`payment_type` tinyint(2) NOT NULL, (for users to choose paypal or credit card)
`num_credits` int(11) NOT NULL,
`price_per_credits` float NOT NULL,
`payment_time_stamp` datetime NOT NULL,
PRIMARY KEY (`payment_info_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
CREATE TABLE `tbl_paypal_info` (
`paypal_info_id` int(11) NOT NULL AUTO_INCREMENT,
`paypal_email` varchar(100) DEFAULT NULL,
`payment_info_id` int(11) NOT NULL,
PRIMARY KEY (`paypal_info_id`),
KEY `tbl_paypal_info_ibfk_1` (`payment_info_id`),
CONSTRAINT `tbl_paypal_info_ibfk_1` FOREIGN KEY (`payment_info_id`) REFERENCES `tbl_payment_info` (`payment_info_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
CREATE TABLE `tbl_credit_card_info` (
`credit_card_info_id` int(11) NOT NULL,
`payment_info_id` int(11) NOT NULL,
`card_fullname` varchar(128) NOT NULL,
`credit_number` varchar(20) NOT NULL,
`credit_card_type` tinyint(2) NOT NULL,
`billing_address_Line_1` varchar(100) NOT NULL,
`billing_address_line_2` varchar(100) DEFAULT NULL,
`billing_city` varchar(50) NOT NULL,
`billing_country` varchar(50) NOT NULL,
`billing_phone` varchar(50) DEFAULT NULL,
PRIMARY KEY (`credit_card_info_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
am I missing anything? is there any better ways to write it more efficiently? Any advice will be helpful. Thanks in advance.
No idea if these might be all the fields missing, but the ones that stick out on the credit card table are:
On the PayPal table, you might also want to save the transactionId. I don’t know if this is the intent of the payment_info column you have in that table, but if it is, you might want to change the field type from int to varchar, as paypal returns a mixture of letters and numbers in their transaction id’s
And one comment, credit card numbers are at most 16 digits long. You have a 20 char field for it.
My final comment on efficiency, is that I wouldn’t waste space using UTF-8 on the first table. It doesn’t really look as if it will be storing international characters.