Foreign key as part of composite primary key or not?File name as primary key?Impact of miss-ordered fields in...
Is it "Vierergruppe" or "Viergruppe", or is there a distinction?
Should I take out a loan for a friend to invest on my behalf?
Hotkey (or other quick way) to insert a keyframe for only one component of a vector-valued property?
Why is computing ridge regression with a Cholesky decomposition much quicker than using SVD?
Single word request: Harming the benefactor
Difference on montgomery curve equation between EFD and RFC7748
Rewrite the power sum in terms of convolution
Is it work or heat?
Database Backup for data and log files
Declaring and defining template, and specialising them
Why does Captain Marvel assume the people on this planet know this?
Why doesn't this Google Translate ad use the word "Translation" instead of "Translate"?
Child Theme Path Being Ignored With wp_enqueue_scripts
Does "Until when" sound natural for native speakers?
How does one describe somebody who is bi-racial?
How to draw cubes in a 3 dimensional plane
NASA's RS-25 Engines shut down time
Conservation of Mass and Energy
Why the color red for the Republican Party
List elements digit difference sort
How can I get players to stop ignoring or overlooking the plot hooks I'm giving them?
'The literal of type int is out of range' con número enteros pequeños (2 dígitos)
Do f-stop and exposure time perfectly cancel?
Counting all the hearts
Foreign key as part of composite primary key or not?
File name as primary key?Impact of miss-ordered fields in a composite, clustered primary key?Postgresql Retrieve / Find Primary Key Serial Autonumber field for Audit logsShould I replace my varchar primary key with an integer primary key?Mysql might have too many indexesAllow only parent DELETE cascade to delete child rowsShould I create a child table without primary key?How can I define and declare a good PRIMARY KEY for my dataset?Handling multiple primary keysViability of surrogate key based from existing column as primary key
I'm designing a relational database. This is what I'm trying to design:
I will have production orders and products.
A production order will have one product, but a product could be on zero or more production orders (In fact, there will be always at least one production order for each product. It has no sense to have a product that it's not going to be produce on database).
In other words, with a production I will produce a product, but I will have a lot of production orders to produce the same product.
We are going to distinguish each production order by its name (alphanumeric) and it must be unique.
I have two questions:
- Is the production order's name its primary key? I think I can use a integer as primary key.
- Does product's key must be part of production order's primary key? I don't think so but I'm not sure.
By the way, I'm going to use SQL Server.
database-design foreign-key primary-key
bumped to the homepage by Community♦ 58 secs 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'm designing a relational database. This is what I'm trying to design:
I will have production orders and products.
A production order will have one product, but a product could be on zero or more production orders (In fact, there will be always at least one production order for each product. It has no sense to have a product that it's not going to be produce on database).
In other words, with a production I will produce a product, but I will have a lot of production orders to produce the same product.
We are going to distinguish each production order by its name (alphanumeric) and it must be unique.
I have two questions:
- Is the production order's name its primary key? I think I can use a integer as primary key.
- Does product's key must be part of production order's primary key? I don't think so but I'm not sure.
By the way, I'm going to use SQL Server.
database-design foreign-key primary-key
bumped to the homepage by Community♦ 58 secs 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'm designing a relational database. This is what I'm trying to design:
I will have production orders and products.
A production order will have one product, but a product could be on zero or more production orders (In fact, there will be always at least one production order for each product. It has no sense to have a product that it's not going to be produce on database).
In other words, with a production I will produce a product, but I will have a lot of production orders to produce the same product.
We are going to distinguish each production order by its name (alphanumeric) and it must be unique.
I have two questions:
- Is the production order's name its primary key? I think I can use a integer as primary key.
- Does product's key must be part of production order's primary key? I don't think so but I'm not sure.
By the way, I'm going to use SQL Server.
database-design foreign-key primary-key
I'm designing a relational database. This is what I'm trying to design:
I will have production orders and products.
A production order will have one product, but a product could be on zero or more production orders (In fact, there will be always at least one production order for each product. It has no sense to have a product that it's not going to be produce on database).
In other words, with a production I will produce a product, but I will have a lot of production orders to produce the same product.
We are going to distinguish each production order by its name (alphanumeric) and it must be unique.
I have two questions:
- Is the production order's name its primary key? I think I can use a integer as primary key.
- Does product's key must be part of production order's primary key? I don't think so but I'm not sure.
By the way, I'm going to use SQL Server.
database-design foreign-key primary-key
database-design foreign-key primary-key
edited May 13 '16 at 8:44
VansFannel
asked Apr 26 '16 at 7:31
VansFannelVansFannel
6864927
6864927
bumped to the homepage by Community♦ 58 secs 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♦ 58 secs 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 |
1 Answer
1
active
oldest
votes
when you define primary key on column sql server implicitly define cluster index on that column and indexes are faster when you use integer datatype,alphanumeric is little bit slow searching than integer column.
production_order_table:-
production_order int(pk)
product_id int(fk) define non-cluster index
Product_table:-
product_id int(pk)
product_code varchar(20) (use two or three character for product code)
product_name varchar(50) (complete name of the product)
when you generate report then you can concate product_id + product_code.
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%2f136568%2fforeign-key-as-part-of-composite-primary-key-or-not%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
when you define primary key on column sql server implicitly define cluster index on that column and indexes are faster when you use integer datatype,alphanumeric is little bit slow searching than integer column.
production_order_table:-
production_order int(pk)
product_id int(fk) define non-cluster index
Product_table:-
product_id int(pk)
product_code varchar(20) (use two or three character for product code)
product_name varchar(50) (complete name of the product)
when you generate report then you can concate product_id + product_code.
add a comment |
when you define primary key on column sql server implicitly define cluster index on that column and indexes are faster when you use integer datatype,alphanumeric is little bit slow searching than integer column.
production_order_table:-
production_order int(pk)
product_id int(fk) define non-cluster index
Product_table:-
product_id int(pk)
product_code varchar(20) (use two or three character for product code)
product_name varchar(50) (complete name of the product)
when you generate report then you can concate product_id + product_code.
add a comment |
when you define primary key on column sql server implicitly define cluster index on that column and indexes are faster when you use integer datatype,alphanumeric is little bit slow searching than integer column.
production_order_table:-
production_order int(pk)
product_id int(fk) define non-cluster index
Product_table:-
product_id int(pk)
product_code varchar(20) (use two or three character for product code)
product_name varchar(50) (complete name of the product)
when you generate report then you can concate product_id + product_code.
when you define primary key on column sql server implicitly define cluster index on that column and indexes are faster when you use integer datatype,alphanumeric is little bit slow searching than integer column.
production_order_table:-
production_order int(pk)
product_id int(fk) define non-cluster index
Product_table:-
product_id int(pk)
product_code varchar(20) (use two or three character for product code)
product_name varchar(50) (complete name of the product)
when you generate report then you can concate product_id + product_code.
edited Apr 26 '16 at 10:12
VansFannel
6864927
6864927
answered Apr 26 '16 at 7:56
Gulrez KhanGulrez Khan
116114
116114
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%2f136568%2fforeign-key-as-part-of-composite-primary-key-or-not%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