How to set up login/guest and checkout/add to cart
I want to create an online store database. I want to give users the ability to 'add to cart' and 'check out' without login.
My idea is that if the user logs in, then I can save the information in tables ex(bag, order), but if the user wants to check out as guest than I can create a guest_unique_id and set up bag that way. Guest bag will be mannually deleted after 10 days.
The only issue I see is that sometimes account_id will be empty. I guess I can check to see if guest_unique_id is NULL then user has an account, if not then it is a guest.
What you guys think about this structure, is there a better way to do this?

database-design
bumped to the homepage by Community♦ 12 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
I want to create an online store database. I want to give users the ability to 'add to cart' and 'check out' without login.
My idea is that if the user logs in, then I can save the information in tables ex(bag, order), but if the user wants to check out as guest than I can create a guest_unique_id and set up bag that way. Guest bag will be mannually deleted after 10 days.
The only issue I see is that sometimes account_id will be empty. I guess I can check to see if guest_unique_id is NULL then user has an account, if not then it is a guest.
What you guys think about this structure, is there a better way to do this?

database-design
bumped to the homepage by Community♦ 12 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
I want to create an online store database. I want to give users the ability to 'add to cart' and 'check out' without login.
My idea is that if the user logs in, then I can save the information in tables ex(bag, order), but if the user wants to check out as guest than I can create a guest_unique_id and set up bag that way. Guest bag will be mannually deleted after 10 days.
The only issue I see is that sometimes account_id will be empty. I guess I can check to see if guest_unique_id is NULL then user has an account, if not then it is a guest.
What you guys think about this structure, is there a better way to do this?

database-design
I want to create an online store database. I want to give users the ability to 'add to cart' and 'check out' without login.
My idea is that if the user logs in, then I can save the information in tables ex(bag, order), but if the user wants to check out as guest than I can create a guest_unique_id and set up bag that way. Guest bag will be mannually deleted after 10 days.
The only issue I see is that sometimes account_id will be empty. I guess I can check to see if guest_unique_id is NULL then user has an account, if not then it is a guest.
What you guys think about this structure, is there a better way to do this?

database-design
database-design
edited Feb 9 '18 at 20:54
Community♦
1
1
asked Feb 9 '18 at 14:36
davedave
111
111
bumped to the homepage by Community♦ 12 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
bumped to the homepage by Community♦ 12 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
Why not have account_id always populated? When anyone who creates a shopping bag, they get an account_id auto assigned, but there's another field on the account table with a boolean is_guest flag set true by default. You could keep things like customer details in a separate table with a 1:1 map to the account table, for customers who do create accounts.
Your challenge then is that you might have repeat customers with different account_ids, but might be worth it depending on how likely customers will create accounts.
add a comment |
what about creating IS_ACCOUNT_TABLE and link account_ID with order or bag tables

1
Did you make a new account, with a new name Dave/Bill?
– LowlyDBA
Feb 9 '18 at 18:39
add a comment |
The best thing would be to create a separate Bag table for guest users ex. (GUEST_BAG_TB), create a column in this table called guest_ip_address to store their ip address and use that to track them, then on checkout since you will be collecting their email generate a random password and email it to them and automatically register them through that, then block them the next time they try to check out as a guest with the same email and ask them to login. From time to time, run a cron job and delete old entries in the GUEST_BAG_TB table if necessary. The IS_Guest boolean column in the IS_ACCOUNT_TB table will not be necessary.
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "182"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f197498%2fhow-to-set-up-login-guest-and-checkout-add-to-cart%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
Why not have account_id always populated? When anyone who creates a shopping bag, they get an account_id auto assigned, but there's another field on the account table with a boolean is_guest flag set true by default. You could keep things like customer details in a separate table with a 1:1 map to the account table, for customers who do create accounts.
Your challenge then is that you might have repeat customers with different account_ids, but might be worth it depending on how likely customers will create accounts.
add a comment |
Why not have account_id always populated? When anyone who creates a shopping bag, they get an account_id auto assigned, but there's another field on the account table with a boolean is_guest flag set true by default. You could keep things like customer details in a separate table with a 1:1 map to the account table, for customers who do create accounts.
Your challenge then is that you might have repeat customers with different account_ids, but might be worth it depending on how likely customers will create accounts.
add a comment |
Why not have account_id always populated? When anyone who creates a shopping bag, they get an account_id auto assigned, but there's another field on the account table with a boolean is_guest flag set true by default. You could keep things like customer details in a separate table with a 1:1 map to the account table, for customers who do create accounts.
Your challenge then is that you might have repeat customers with different account_ids, but might be worth it depending on how likely customers will create accounts.
Why not have account_id always populated? When anyone who creates a shopping bag, they get an account_id auto assigned, but there's another field on the account table with a boolean is_guest flag set true by default. You could keep things like customer details in a separate table with a 1:1 map to the account table, for customers who do create accounts.
Your challenge then is that you might have repeat customers with different account_ids, but might be worth it depending on how likely customers will create accounts.
answered Feb 9 '18 at 17:13
Randolph WestRandolph West
2,649215
2,649215
add a comment |
add a comment |
what about creating IS_ACCOUNT_TABLE and link account_ID with order or bag tables

1
Did you make a new account, with a new name Dave/Bill?
– LowlyDBA
Feb 9 '18 at 18:39
add a comment |
what about creating IS_ACCOUNT_TABLE and link account_ID with order or bag tables

1
Did you make a new account, with a new name Dave/Bill?
– LowlyDBA
Feb 9 '18 at 18:39
add a comment |
what about creating IS_ACCOUNT_TABLE and link account_ID with order or bag tables

what about creating IS_ACCOUNT_TABLE and link account_ID with order or bag tables

answered Feb 9 '18 at 18:37
billbill
1
1
1
Did you make a new account, with a new name Dave/Bill?
– LowlyDBA
Feb 9 '18 at 18:39
add a comment |
1
Did you make a new account, with a new name Dave/Bill?
– LowlyDBA
Feb 9 '18 at 18:39
1
1
Did you make a new account, with a new name Dave/Bill?
– LowlyDBA
Feb 9 '18 at 18:39
Did you make a new account, with a new name Dave/Bill?
– LowlyDBA
Feb 9 '18 at 18:39
add a comment |
The best thing would be to create a separate Bag table for guest users ex. (GUEST_BAG_TB), create a column in this table called guest_ip_address to store their ip address and use that to track them, then on checkout since you will be collecting their email generate a random password and email it to them and automatically register them through that, then block them the next time they try to check out as a guest with the same email and ask them to login. From time to time, run a cron job and delete old entries in the GUEST_BAG_TB table if necessary. The IS_Guest boolean column in the IS_ACCOUNT_TB table will not be necessary.
add a comment |
The best thing would be to create a separate Bag table for guest users ex. (GUEST_BAG_TB), create a column in this table called guest_ip_address to store their ip address and use that to track them, then on checkout since you will be collecting their email generate a random password and email it to them and automatically register them through that, then block them the next time they try to check out as a guest with the same email and ask them to login. From time to time, run a cron job and delete old entries in the GUEST_BAG_TB table if necessary. The IS_Guest boolean column in the IS_ACCOUNT_TB table will not be necessary.
add a comment |
The best thing would be to create a separate Bag table for guest users ex. (GUEST_BAG_TB), create a column in this table called guest_ip_address to store their ip address and use that to track them, then on checkout since you will be collecting their email generate a random password and email it to them and automatically register them through that, then block them the next time they try to check out as a guest with the same email and ask them to login. From time to time, run a cron job and delete old entries in the GUEST_BAG_TB table if necessary. The IS_Guest boolean column in the IS_ACCOUNT_TB table will not be necessary.
The best thing would be to create a separate Bag table for guest users ex. (GUEST_BAG_TB), create a column in this table called guest_ip_address to store their ip address and use that to track them, then on checkout since you will be collecting their email generate a random password and email it to them and automatically register them through that, then block them the next time they try to check out as a guest with the same email and ask them to login. From time to time, run a cron job and delete old entries in the GUEST_BAG_TB table if necessary. The IS_Guest boolean column in the IS_ACCOUNT_TB table will not be necessary.
edited Jul 20 '18 at 11:54
answered Jul 20 '18 at 11:13
user6033723user6033723
11
11
add a comment |
add a comment |
Thanks for contributing an answer to Database Administrators Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f197498%2fhow-to-set-up-login-guest-and-checkout-add-to-cart%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown