Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Design and Architecture
  4. A better way to do it?

A better way to do it?

Scheduled Pinned Locked Moved Design and Architecture
databasedesignquestionannouncement
18 Posts 6 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Peter Leow

    Based on the information provided, I think you already have the best idea so far. Well done!

    C Offline
    C Offline
    Cee Ann
    wrote on last edited by
    #4

    Thank for the comment.

    1 Reply Last reply
    0
    • M Mycroft Holmes

      I disagree with the entire design concept of delaying a change until it is approved, it feels like a nightmare waiting to happen, the first time someone needs an "urgent" change implemented the workflow will be short circuited by the needs of the business to get the job done. I use a logging system (almost all system rely on logging) make the changes immediately and record the information in a log file, if there is a problem you can trace the perpetrator and reverse the changes if required. This allows the business to do their job quickly and gives you the recovery information when they screw up.

      Never underestimate the power of human stupidity RAH

      C Offline
      C Offline
      Cee Ann
      wrote on last edited by
      #5

      Hi, I like your quote "Never underestimate the power of human stupidity". The concept is requested by the user which what they been practice right now. No matter how urgent the changes is, they need to go thru the approval before getting the changes out for others to use it. We do have a log system which log all changes and approval in the system. I agree will your suggestion, as the whole process will be very quick and no delay. But this process will be great if all user know that what is a correct record looks like. Most of the user will just use whatever data display in the system to get the job done. And it will be a mess when 'Someone' found out is a wrong data. It will take a lot of money and resources to reserve it(In Business). For us, no record is better than wrong record. Thank for the sharing. :)

      M 1 Reply Last reply
      0
      • C Cee Ann

        Hi, I like your quote "Never underestimate the power of human stupidity". The concept is requested by the user which what they been practice right now. No matter how urgent the changes is, they need to go thru the approval before getting the changes out for others to use it. We do have a log system which log all changes and approval in the system. I agree will your suggestion, as the whole process will be very quick and no delay. But this process will be great if all user know that what is a correct record looks like. Most of the user will just use whatever data display in the system to get the job done. And it will be a mess when 'Someone' found out is a wrong data. It will take a lot of money and resources to reserve it(In Business). For us, no record is better than wrong record. Thank for the sharing. :)

        M Offline
        M Offline
        Mycroft Holmes
        wrote on last edited by
        #6

        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

        C 1 Reply Last reply
        0
        • M Mycroft Holmes

          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

          C Offline
          C Offline
          Cee Ann
          wrote on last edited by
          #7

          Ya, they are driving me nuts now.. Yes, the student thing is an example but the process is not. Will try to think off any other validation required like what you mention. Thank for the suggestion.

          1 Reply Last reply
          0
          • C Cee Ann

            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

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #8

            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[^]

            C 1 Reply Last reply
            0
            • L Lost User

              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[^]

              C Offline
              C Offline
              Cee Ann
              wrote on last edited by
              #9

              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

              L 1 Reply Last reply
              0
              • P Peter Leow

                Based on the information provided, I think you already have the best idea so far. Well done!

                I Offline
                I Offline
                IPTVEXpert
                wrote on last edited by
                #10

                For any kind of web services please visit forwardslash.us

                1 Reply Last reply
                0
                • C Cee Ann

                  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

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #11

                  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[^]

                  C 1 Reply Last reply
                  0
                  • L Lost User

                    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[^]

                    C Offline
                    C Offline
                    Cee Ann
                    wrote on last edited by
                    #12

                    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

                    L 1 Reply Last reply
                    0
                    • C Cee Ann

                      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

                      L Offline
                      L Offline
                      Lost User
                      wrote on last edited by
                      #13

                      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[^]

                      W C 2 Replies Last reply
                      0
                      • L Lost User

                        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[^]

                        W Offline
                        W Offline
                        Wayne Gaylard
                        wrote on last edited by
                        #14

                        Go on Eddy - why don't you tell them how you really feel :)

                        Everyone dies - but not everyone lives

                        1 Reply Last reply
                        0
                        • L Lost User

                          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[^]

                          C Offline
                          C Offline
                          Cee Ann
                          wrote on last edited by
                          #15

                          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?

                          L 1 Reply Last reply
                          0
                          • C Cee Ann

                            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?

                            L Offline
                            L Offline
                            Lost User
                            wrote on last edited by
                            #16

                            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[^]

                            C 1 Reply Last reply
                            0
                            • L Lost User

                              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[^]

                              C Offline
                              C Offline
                              Cee Ann
                              wrote on last edited by
                              #17

                              Got it, Thanks a lot Eddy for everything.

                              L 1 Reply Last reply
                              0
                              • C Cee Ann

                                Got it, Thanks a lot Eddy for everything.

                                L Offline
                                L Offline
                                Lost User
                                wrote on last edited by
                                #18

                                You're welcome :)

                                1 Reply Last reply
                                0
                                Reply
                                • Reply as topic
                                Log in to reply
                                • Oldest to Newest
                                • Newest to Oldest
                                • Most Votes


                                • Login

                                • Don't have an account? Register

                                • Login or register to search.
                                • First post
                                  Last post
                                0
                                • Categories
                                • Recent
                                • Tags
                                • Popular
                                • World
                                • Users
                                • Groups