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.
  • 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