A better way to do it?
-
Ah user requirements, they will drive you nuts at some stage. I can understand the requirement (I thought the student thing was only an example) I do suggest you put in place as much validation as you can think of to reduce the need for intelligent input. You may end up with only a few critical fields that need autorisation.
Never underestimate the power of human stupidity RAH
-
Guys, I have a scenario which need your advice on it. I try to keep it short here.. So not putting whole thing in. I need to develop a system which require approval to maintain any record. Below is my DB design Student Table - StuId - StuName - StuAddress - RecStatus (Deleted, Active, Pending Add, Pending Edit or Pending Delete) Approval Table - AprId - AprCat (Add Request, Edit Request or Delete Request) - AprModule (Which table to refer to) - AprModuleId (Target Record) - AprStatus (Pending Approval, Approve, Reject) - AprBy - AprDT Approval Detail Table (Handle Edit Request Record) - AprDId - AprId - UpdField (Which Field to update) - NewValue (New Record) For Adding record, system will insert the record into the student table and have it update as Pending Add in RecStatus. The Id will then added to Approval table for Approval Request. For Delete Record, system will update the record as Pending Delete in RecStatus. The StuId will added to approval table for approval request. For Edit record, system will not change the record in student table. But it added into the Approval Detail table and sit there for approval. If request approved, system will loop thru the approval detail record and update the fields one by one. This is how I do it, Was thinking is there any better way to work with this kind of scenario? If yes, please point me to the right direction. Thank
CA
Cee Ann wrote:
Was thinking is there any better way to work with this kind of scenario?
Ehr.. how does a multi-table update look like (in a transaction please) with someone "approving" each record before it's edited? And what are you going to do with concurrent edits? Say both I and your boss edit the same record. Now both edits are awaiting approval. And both of us need the ID that's generated, so we can enlist the student into a class. Whose edit will win? It better be my edit :) Whoever felt the need to give his permission; keep him away from the database-design. There's a GOOD reason why a developer creates the design, and not the user. His permission might be required for a business-rule, but it has nothing to do with how we physically store data. Aw, and why are you prefixing your fieldnames? And why is it already inconsistent? Wouldn't it be a bit more readable if you omit the prefix?
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]
-
Cee Ann wrote:
Was thinking is there any better way to work with this kind of scenario?
Ehr.. how does a multi-table update look like (in a transaction please) with someone "approving" each record before it's edited? And what are you going to do with concurrent edits? Say both I and your boss edit the same record. Now both edits are awaiting approval. And both of us need the ID that's generated, so we can enlist the student into a class. Whose edit will win? It better be my edit :) Whoever felt the need to give his permission; keep him away from the database-design. There's a GOOD reason why a developer creates the design, and not the user. His permission might be required for a business-rule, but it has nothing to do with how we physically store data. Aw, and why are you prefixing your fieldnames? And why is it already inconsistent? Wouldn't it be a bit more readable if you omit the prefix?
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]
Hi, For multiple table update, are you referring to other table such as classes or course? On concurrent edit, we only allow record in active status to be edit. If the record is in Pending Edit Approval Status, the record will not be allow to edit again. Until the pending request is approved/rejected. This is been taken care in the RecStatus field of each table. So, it will not happen that you and my boss edit the same record in same time. But If it really happen, I will let me boss win. As he is paying my salary. :) The database is design by me. If you see any issue with it, please point it out. So I can learn from my mistake. Forgive my laziness on the prefixing of fieldname, It all started when I writing my SQL statement and felt it's too long.. So I try to shorten it a little bit. Was learning my way to not prefixing my fieldname with EF6, as I get the suggestion function in VS. :) Thanks for the update.
CA
-
Based on the information provided, I think you already have the best idea so far. Well done!
For any kind of web services please visit forwardslash.us
-
Hi, For multiple table update, are you referring to other table such as classes or course? On concurrent edit, we only allow record in active status to be edit. If the record is in Pending Edit Approval Status, the record will not be allow to edit again. Until the pending request is approved/rejected. This is been taken care in the RecStatus field of each table. So, it will not happen that you and my boss edit the same record in same time. But If it really happen, I will let me boss win. As he is paying my salary. :) The database is design by me. If you see any issue with it, please point it out. So I can learn from my mistake. Forgive my laziness on the prefixing of fieldname, It all started when I writing my SQL statement and felt it's too long.. So I try to shorten it a little bit. Was learning my way to not prefixing my fieldname with EF6, as I get the suggestion function in VS. :) Thanks for the update.
CA
Cee Ann wrote:
For multiple table update, are you referring to other table such as classes or course?
I don't have the entire schema so I can't say to which tables it applies. Let's take a fictive person called Jane and enlist her into three courses. That's 4 items that need be "approved". Now enlist 400 students in 40 different courses :)
Cee Ann wrote:
If you see any issue with it, please point it out
Whether it is valid depends on the users' needs; I can't tell whether it's valid, but one can always apply the normalization principles. To me it'd be valid if it is in BNF.
Cee Ann wrote:
Forgive my laziness on the prefixing of fieldname
Lazy? I was wondering why you're doing all that work, when it doesn't seem to help much :)
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]
-
Cee Ann wrote:
For multiple table update, are you referring to other table such as classes or course?
I don't have the entire schema so I can't say to which tables it applies. Let's take a fictive person called Jane and enlist her into three courses. That's 4 items that need be "approved". Now enlist 400 students in 40 different courses :)
Cee Ann wrote:
If you see any issue with it, please point it out
Whether it is valid depends on the users' needs; I can't tell whether it's valid, but one can always apply the normalization principles. To me it'd be valid if it is in BNF.
Cee Ann wrote:
Forgive my laziness on the prefixing of fieldname
Lazy? I was wondering why you're doing all that work, when it doesn't seem to help much :)
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]
Eddy Vluggen wrote:
Now enlist 400 students in 40 different courses :)
It will be a lot of approval need to be done. Luckily I'm the developer not the person who need to approve it. :)
Eddy Vluggen wrote:
To me it'd be valid if it is in BNF.
BNF?
Eddy Vluggen wrote:
it doesn't seem to help much :)
So, if is for you, you will do it as below? Student Table - StudentId - StudentCode - StudentName - StudentAddress - RecordStatus
-
Eddy Vluggen wrote:
Now enlist 400 students in 40 different courses :)
It will be a lot of approval need to be done. Luckily I'm the developer not the person who need to approve it. :)
Eddy Vluggen wrote:
To me it'd be valid if it is in BNF.
BNF?
Eddy Vluggen wrote:
it doesn't seem to help much :)
So, if is for you, you will do it as below? Student Table - StudentId - StudentCode - StudentName - StudentAddress - RecordStatus
Cee Ann wrote:
Luckily I'm the developer not the person who need to approve it
Make sure to add in an extra dialog, asking the user whether he/she is sure about the edit and wants to save :cool:
Cee Ann wrote:
BNF?
Sorry, BCNF[^]; the normal forms are numbered. The model is said to be in 3NF if you validated the first three rules. BCNF is "rule 3.5", it's somewhere between 3 and 4.
Cee Ann wrote:
So, if is for you, you will do it as below?
I'd drop the word "Student" from the fieldname, as there would not be any other entities with an Id in the Student-table. If you're referring to a name in the student-table, then "name" would probably apply to the student. Then I'd rename "RecordStatus" to "ApprovedByFool", as it is more descriptive.
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]
-
Cee Ann wrote:
Luckily I'm the developer not the person who need to approve it
Make sure to add in an extra dialog, asking the user whether he/she is sure about the edit and wants to save :cool:
Cee Ann wrote:
BNF?
Sorry, BCNF[^]; the normal forms are numbered. The model is said to be in 3NF if you validated the first three rules. BCNF is "rule 3.5", it's somewhere between 3 and 4.
Cee Ann wrote:
So, if is for you, you will do it as below?
I'd drop the word "Student" from the fieldname, as there would not be any other entities with an Id in the Student-table. If you're referring to a name in the student-table, then "name" would probably apply to the student. Then I'd rename "RecordStatus" to "ApprovedByFool", as it is more descriptive.
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]
Go on Eddy - why don't you tell them how you really feel :)
Everyone dies - but not everyone lives
-
Cee Ann wrote:
Luckily I'm the developer not the person who need to approve it
Make sure to add in an extra dialog, asking the user whether he/she is sure about the edit and wants to save :cool:
Cee Ann wrote:
BNF?
Sorry, BCNF[^]; the normal forms are numbered. The model is said to be in 3NF if you validated the first three rules. BCNF is "rule 3.5", it's somewhere between 3 and 4.
Cee Ann wrote:
So, if is for you, you will do it as below?
I'd drop the word "Student" from the fieldname, as there would not be any other entities with an Id in the Student-table. If you're referring to a name in the student-table, then "name" would probably apply to the student. Then I'd rename "RecordStatus" to "ApprovedByFool", as it is more descriptive.
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]
Eddy Vluggen wrote:
Make sure to add in an extra dialog, asking the user whether he/she is sure about the edit and wants to save :cool:
Got it. BCNF... Something new for me to study..
Eddy Vluggen wrote:
I'd drop the word "Student" from the fieldname, as there would not be any other entities with an Id in the Student-table. If you're referring to a name in the student-table, then "name" would probably apply to the student. Then I'd rename "RecordStatus" to "ApprovedByFool", as it is more descriptive.
What if StudentId is a foreign key to other table? Write 'StudentId' as fieldname in the other tables and 'Id' as fieldname in Student table?
-
Eddy Vluggen wrote:
Make sure to add in an extra dialog, asking the user whether he/she is sure about the edit and wants to save :cool:
Got it. BCNF... Something new for me to study..
Eddy Vluggen wrote:
I'd drop the word "Student" from the fieldname, as there would not be any other entities with an Id in the Student-table. If you're referring to a name in the student-table, then "name" would probably apply to the student. Then I'd rename "RecordStatus" to "ApprovedByFool", as it is more descriptive.
What if StudentId is a foreign key to other table? Write 'StudentId' as fieldname in the other tables and 'Id' as fieldname in Student table?
Cee Ann wrote:
What if StudentId is a foreign key to other table
Then you could name it after the table it comes from, but it'd be better to come up with a descriptive name. Take "Employee" and "Person" as a fictive example with multiple references to itself; Employee Id Name FK_Manager FK_DedicatedDriver Person Id FK_Mother FK_Father As you can see, there's no mention of the fact in the fieldname to the table. That's because we can assume that people will recognize "mother" as a person, and "manager" as an employee. If it weren't, "FK_MotherPerson" might be needed.
Cee Ann wrote:
Write 'StudentId' as fieldname in the other tables
It's not an id, but a foreign key; it's something that points to the id of a record in a different table :) That information is also obvious from the above naming; anything with a "FK" points to the Id-field of another table.
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]
-
Cee Ann wrote:
What if StudentId is a foreign key to other table
Then you could name it after the table it comes from, but it'd be better to come up with a descriptive name. Take "Employee" and "Person" as a fictive example with multiple references to itself; Employee Id Name FK_Manager FK_DedicatedDriver Person Id FK_Mother FK_Father As you can see, there's no mention of the fact in the fieldname to the table. That's because we can assume that people will recognize "mother" as a person, and "manager" as an employee. If it weren't, "FK_MotherPerson" might be needed.
Cee Ann wrote:
Write 'StudentId' as fieldname in the other tables
It's not an id, but a foreign key; it's something that points to the id of a record in a different table :) That information is also obvious from the above naming; anything with a "FK" points to the Id-field of another table.
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]