pgilmour24
New member
- Local time
- Today, 06:09
- Joined
- Nov 25, 2020
- Messages
- 9
Hi, complete novice here again, but I have a couple of questions about primary keys and the normalization of data.
I work at a lighting design company and I want to increase productivity by creating lighting, circuit and switchplate schedules, product sheets, orders, invoices etc. but last time I did any Access dbase work was about 10 years ago. Anyways to help me with this project I bought the Access Bible 2016 which has been great but has also brought up a few questions that I can't find specific enough answers on paper to.
To explain my question in relation to my work: we have several projects, each with their own projectID (currently generated by hand) which constitutes of the last two digits of the year and then a sequential number - eg 20 1345. I plan on using code to generate these projectIDs when a new project is added. Should I use this generated projectID as my primary key, or just have an autonumber as the primary key and then the generated projectID as a separate field? What are the pros and cons to both? I have read a couple of different fourm posts with contrasting info! Some say the primary key should be meaningful and others say meaningless...?!
To help explain the next question I have put my plan for the start of the tables below:
tblProject:
ProjectID (generated code which will always be unique/autonumber - see above) primary key
ProjectAddress
Client
ContactNum
etc
tblCircuitSchedule
ProjectID - foreign key
ProjectCircuitNumber - (autonumber which returns to 1 when working on a different project) indexed
Fitting Code indexed
Room
etc
Data from tblCircuitSchedule will look something like this
20 1345 / 1 / W1 / Sitting Room
20 1345 / 2 / D1 / Sitting Room
20 1345 / 3 / W2 / Kitchen
20 1789 / 1 / W1 / Hallway
20 1789 / 2 / W2 / WC
Can I have a combination of fields to act as my primary key - I know something like this is called a composite key but is it the best way to do this or should I have a table per project where the ProjectCircuitNumber is the primary key? Or am I completely barking up the wrong tree?
Thanks in advance
I work at a lighting design company and I want to increase productivity by creating lighting, circuit and switchplate schedules, product sheets, orders, invoices etc. but last time I did any Access dbase work was about 10 years ago. Anyways to help me with this project I bought the Access Bible 2016 which has been great but has also brought up a few questions that I can't find specific enough answers on paper to.
To explain my question in relation to my work: we have several projects, each with their own projectID (currently generated by hand) which constitutes of the last two digits of the year and then a sequential number - eg 20 1345. I plan on using code to generate these projectIDs when a new project is added. Should I use this generated projectID as my primary key, or just have an autonumber as the primary key and then the generated projectID as a separate field? What are the pros and cons to both? I have read a couple of different fourm posts with contrasting info! Some say the primary key should be meaningful and others say meaningless...?!
To help explain the next question I have put my plan for the start of the tables below:
tblProject:
ProjectID (generated code which will always be unique/autonumber - see above) primary key
ProjectAddress
Client
ContactNum
etc
tblCircuitSchedule
ProjectID - foreign key
ProjectCircuitNumber - (autonumber which returns to 1 when working on a different project) indexed
Fitting Code indexed
Room
etc
Data from tblCircuitSchedule will look something like this
20 1345 / 1 / W1 / Sitting Room
20 1345 / 2 / D1 / Sitting Room
20 1345 / 3 / W2 / Kitchen
20 1789 / 1 / W1 / Hallway
20 1789 / 2 / W2 / WC
Can I have a combination of fields to act as my primary key - I know something like this is called a composite key but is it the best way to do this or should I have a table per project where the ProjectCircuitNumber is the primary key? Or am I completely barking up the wrong tree?
Thanks in advance