Generate UserName from Existing table

  • Are you able to help on this?

    Greatly appreciate !

  • ScottPletcher - Wednesday, March 7, 2018 2:52 PM

    Jason A. Long - Wednesday, March 7, 2018 2:41 PM

    The really easy thing would be simply join the modern era and just use email address like every other website built in the last 10 years.

    Nothing will make me stop doing business with a company faster than a website that won't let me login because I can't remember some nonsensical username.

    Bit extreme, don't you think?  I guess you use the same email address for everything; I certainly don't.  I use bogus ones for a lot of (retail) companies so they don't have my real email address.

    Also, I would run like he!! from any bank or credit card or brokerage company, as examples, that used email to log in.  How many gazillions of people know your email?

    No... Not really... A username isn't exactly a security feature. I rely on reasonably complex passwords for that...
    If you're running from financial institutions that use your email as part of the login process, you must be doing quite a bit of running. Most the major financial institutions that I'm aware of (or at least the ones I use) all use multi-factor authentication that includes email address. As long as I'm using a devise that I've previously authenticated, my logins are as simple as providing my email address (as my account id) and my password.

  • Could this be done in a simpler manner?  Maybe, but here is one way.

    WITH base AS (
    SELECT
      [t].[ID]
      , [t].[FIRSTNAME]
      , [t].[LASTNAME]
      , [t].[USERNAME]
      , [ca1].[UserName] AS [BaseUserName]
      , ISNULL([ca2].[v1],-1) AS [UserNumeric]
    FROM
      #Temp t
      CROSS APPLY(SELECT [t].[FIRSTNAME] + '.' + [t].[LASTNAME])ca1(UserName)
      CROSS APPLY (SELECT CAST(STUFF([t].[USERNAME],1,LEN([ca1].[UserName]),'') AS INT))ca2(v1)
    ), UserMax AS (
    SELECT
      .[BaseUserName], MAX(.[UserNumeric]) AS MaxNumeric
    FROM
      [base] AS
    GROUP BY
      .[BaseUserName]
    ), UpdatingValues AS (
    SELECT
      [b1].[ID]
      , [b1].[FIRSTNAME]
      , [b1].[LASTNAME]
      , [b1].[USERNAME]
      , [b1].[BaseUserName]
      , [b1].[UserNumeric]
      , [ca3].[BaseUserName] + CAST([ca3].[MaxNumeric] + DENSE_RANK() OVER (PARTITION BY [b1].[BaseUserName] ORDER BY [b1].[ID]) AS VARCHAR(30)) AS NewUserName
    FROM
      [base] AS [b1]
      CROSS APPLY (SELECT * FROM [UserMax] AS [um] WHERE [um].[BaseUserName] = [b1].[BaseUserName])ca3(BaseUserName,MaxNumeric)
    WHERE
      [b1].[UserName] = ''
    )
    UPDATE [t] SET
      [USERNAME] = [uv].[NewUserName]
    FROM
      [#Temp] AS [t]
      INNER JOIN [UpdatingValues] AS [uv]
        ON ([t].[ID] = [uv].[ID]);
    GO

  • Lynn Pettis - Wednesday, March 7, 2018 4:58 PM

    Could this be done in a simpler manner?  Maybe, but here is one way.

    WITH base AS (
    SELECT
      [t].[ID]
      , [t].[FIRSTNAME]
      , [t].[LASTNAME]
      , [t].[USERNAME]
      , [ca1].[UserName] AS [BaseUserName]
      , ISNULL([ca2].[v1],-1) AS [UserNumeric]
    FROM
      #Temp t
      CROSS APPLY(SELECT [t].[FIRSTNAME] + '.' + [t].[LASTNAME])ca1(UserName)
      CROSS APPLY (SELECT CAST(STUFF([t].[USERNAME],1,LEN([ca1].[UserName]),'') AS INT))ca2(v1)
    ), UserMax AS (
    SELECT
      .[BaseUserName], MAX(.[UserNumeric]) AS MaxNumeric
    FROM
      [base] AS
    GROUP BY
      .[BaseUserName]
    ), UpdatingValues AS (
    SELECT
      [b1].[ID]
      , [b1].[FIRSTNAME]
      , [b1].[LASTNAME]
      , [b1].[USERNAME]
      , [b1].[BaseUserName]
      , [b1].[UserNumeric]
      , [ca3].[BaseUserName] + CAST([ca3].[MaxNumeric] + DENSE_RANK() OVER (PARTITION BY [b1].[BaseUserName] ORDER BY [b1].[ID]) AS VARCHAR(30)) AS NewUserName
    FROM
      [base] AS [b1]
      CROSS APPLY (SELECT * FROM [UserMax] AS [um] WHERE [um].[BaseUserName] = [b1].[BaseUserName])ca3(BaseUserName,MaxNumeric)
    WHERE
      [b1].[UserName] = ''
    )
    UPDATE [t] SET
      [USERNAME] = [uv].[NewUserName]
    FROM
      [#Temp] AS [t]
      INNER JOIN [UpdatingValues] AS [uv]
        ON ([t].[ID] = [uv].[ID]);
    GO

    Amazing......

    Thank you so much, You save my days.

    Appreciate !!!

  • yogi123 - Wednesday, March 7, 2018 5:49 PM

    Lynn Pettis - Wednesday, March 7, 2018 4:58 PM

    Could this be done in a simpler manner?  Maybe, but here is one way.

    WITH base AS (
    SELECT
      [t].[ID]
      , [t].[FIRSTNAME]
      , [t].[LASTNAME]
      , [t].[USERNAME]
      , [ca1].[UserName] AS [BaseUserName]
      , ISNULL([ca2].[v1],-1) AS [UserNumeric]
    FROM
      #Temp t
      CROSS APPLY(SELECT [t].[FIRSTNAME] + '.' + [t].[LASTNAME])ca1(UserName)
      CROSS APPLY (SELECT CAST(STUFF([t].[USERNAME],1,LEN([ca1].[UserName]),'') AS INT))ca2(v1)
    ), UserMax AS (
    SELECT
      .[BaseUserName], MAX(.[UserNumeric]) AS MaxNumeric
    FROM
      [base] AS
    GROUP BY
      .[BaseUserName]
    ), UpdatingValues AS (
    SELECT
      [b1].[ID]
      , [b1].[FIRSTNAME]
      , [b1].[LASTNAME]
      , [b1].[USERNAME]
      , [b1].[BaseUserName]
      , [b1].[UserNumeric]
      , [ca3].[BaseUserName] + CAST([ca3].[MaxNumeric] + DENSE_RANK() OVER (PARTITION BY [b1].[BaseUserName] ORDER BY [b1].[ID]) AS VARCHAR(30)) AS NewUserName
    FROM
      [base] AS [b1]
      CROSS APPLY (SELECT * FROM [UserMax] AS [um] WHERE [um].[BaseUserName] = [b1].[BaseUserName])ca3(BaseUserName,MaxNumeric)
    WHERE
      [b1].[UserName] = ''
    )
    UPDATE [t] SET
      [USERNAME] = [uv].[NewUserName]
    FROM
      [#Temp] AS [t]
      INNER JOIN [UpdatingValues] AS [uv]
        ON ([t].[ID] = [uv].[ID]);
    GO

    Amazing......

    Thank you so much, You save my days.

    Appreciate !!!

    But do you understand what the code is doing?  You will have to support this code if you use it in production.

  • Yes, I understand completely. Took an hours to get it.

    Will break in temp tables and do the updates.

    My next step is open up for all records, will test it first.

    New think I have learn is dense_Rank.

    Again thank you so much. Much Appriciate .

  • Jeff Moden - Wednesday, March 7, 2018 2:14 PM

    yogi123 - Wednesday, March 7, 2018 2:04 PM

    Jeff Moden - Wednesday, March 7, 2018 1:58 PM

    yogi123 - Wednesday, March 7, 2018 1:22 PM

    Michael L John - Wednesday, March 7, 2018 1:15 PM

    What have you tried?  Does it work?
    What are the rules for multiple users with the same name? 
    In your example, James Doyel appears three times.  His name becomes James.Doyel1, 2, and 3. 

    How do you know when a second person with the same name may be added?
    For example, "Michael.John" is created as a user name.  Two weeks later, another Michael John needs to be added to the system.  Does the original get changed to Michael.John1, and the new persons user name becomes Michael.John2?

    Yes, 

    If Michael.John user name is created, week later same another Michael.John came then it will be Michael.John1..

    The Rule is, If user name is not there then it uses as FirstName.LastName. If User Name is there it need to add auto incremented by 1.

    Why not just add the user "ID" to everyone and call it a day?

    They are going to display on UI, so they need to have unique UserName, and they decide to increment by 1 if it exist.

    Heh... that's what happens when users do the design. 😀

    That's mean--but SO true... :hehe:

  • roger.plowman - Thursday, March 8, 2018 7:47 AM

    Jeff Moden - Wednesday, March 7, 2018 2:14 PM

    yogi123 - Wednesday, March 7, 2018 2:04 PM

    Jeff Moden - Wednesday, March 7, 2018 1:58 PM

    yogi123 - Wednesday, March 7, 2018 1:22 PM

    Michael L John - Wednesday, March 7, 2018 1:15 PM

    What have you tried?  Does it work?
    What are the rules for multiple users with the same name? 
    In your example, James Doyel appears three times.  His name becomes James.Doyel1, 2, and 3. 

    How do you know when a second person with the same name may be added?
    For example, "Michael.John" is created as a user name.  Two weeks later, another Michael John needs to be added to the system.  Does the original get changed to Michael.John1, and the new persons user name becomes Michael.John2?

    Yes, 

    If Michael.John user name is created, week later same another Michael.John came then it will be Michael.John1..

    The Rule is, If user name is not there then it uses as FirstName.LastName. If User Name is there it need to add auto incremented by 1.

    Why not just add the user "ID" to everyone and call it a day?

    They are going to display on UI, so they need to have unique UserName, and they decide to increment by 1 if it exist.

    Heh... that's what happens when users do the design. 😀

    That's mean--but SO true... :hehe:

    So ironic too.  Developers say this over and over about users.  Yet when developers insist on "designing" tables without bothering with a true logical design, with no real normalization, with "automatic identity clustering keys", etc., and data modelers or DBAs try to call them out on it, they insist that, even with no full-time professional experience as data modelers, that they are as good (really better!) than the dms and DBAs.
    In short, when we say, "that's what happens when developers do the data/table design."

    This is not said just to be difficult.  I find it somewhat insulting and condescending when the implication is made that even after spending thousands of hours, full-time professionally dedicated to  data modeling / design, to be told by others with no full-time experience, who did it as a minor subset of their programming, that they're just as skilled as you are.

    SQL DBA,SQL Server MVP(07, 08, 09) A socialist is someone who will give you the shirt off *someone else's* back.

  • ScottPletcher - Thursday, March 8, 2018 7:53 AM

    roger.plowman - Thursday, March 8, 2018 7:47 AM

    Jeff Moden - Wednesday, March 7, 2018 2:14 PM

    yogi123 - Wednesday, March 7, 2018 2:04 PM

    Jeff Moden - Wednesday, March 7, 2018 1:58 PM

    yogi123 - Wednesday, March 7, 2018 1:22 PM

    Michael L John - Wednesday, March 7, 2018 1:15 PM

    What have you tried?  Does it work?
    What are the rules for multiple users with the same name? 
    In your example, James Doyel appears three times.  His name becomes James.Doyel1, 2, and 3. 

    How do you know when a second person with the same name may be added?
    For example, "Michael.John" is created as a user name.  Two weeks later, another Michael John needs to be added to the system.  Does the original get changed to Michael.John1, and the new persons user name becomes Michael.John2?

    Yes, 

    If Michael.John user name is created, week later same another Michael.John came then it will be Michael.John1..

    The Rule is, If user name is not there then it uses as FirstName.LastName. If User Name is there it need to add auto incremented by 1.

    Why not just add the user "ID" to everyone and call it a day?

    They are going to display on UI, so they need to have unique UserName, and they decide to increment by 1 if it exist.

    Heh... that's what happens when users do the design. 😀

    That's mean--but SO true... :hehe:

    So ironic too.  Developers say this over and over about users.  Yet when developers insist on "designing" tables without bothering with a true logical design, with no real normalization, with "automatic identity clustering keys", etc., and data modelers or DBAs try to call them out on it, they insist that, even with no full-time professional experience as data modelers, that they are as good (really better!) than the dms and DBAs.
    In short, when we say, "that's what happens when developers do the data/table design."

    This is not said just to be difficult.  I find it somewhat insulting and condescending when the implication is made that even after spending thousands of hours, full-time professionally dedicated to  data modeling / design, to be told by others with no full-time experience, who did it as a minor subset of their programming, that they're just as skilled as you are.

    True enough. However, one nitpick. Nothing wrong with using identities as a clustered and primary key. Mind you, my experience is designing "small to medium" OLTP systems (read, around 10 million records per table) so I can't speak to designing the true behemoths (1+ billion records), which I'm sure have far more severe performance constraints.

    I'm fully in agreement about normalization, though. The impedance mismatch between object oriented design and 3NF is often painful (3NF is viewed by many developers as horrifically antiquated). Part of that is undoubtedly the black-box view developers hold toward databases, but you'd think they'd be aware of SPOT as the data equivalent of DRY.

    It doesn't help when developers develop against "play" tables with a few dozen records either...and wonder why production performance is measured in geological eras...

    "Hey, you're the DBA! The database is the problem, fix it!" (rolling eyes)

    It's a pity that as a Lone Wolf I don't have that luxury! 😀

  • roger.plowman - Thursday, March 8, 2018 8:37 AM

    ScottPletcher - Thursday, March 8, 2018 7:53 AM

    roger.plowman - Thursday, March 8, 2018 7:47 AM

    Jeff Moden - Wednesday, March 7, 2018 2:14 PM

    yogi123 - Wednesday, March 7, 2018 2:04 PM

    Jeff Moden - Wednesday, March 7, 2018 1:58 PM

    yogi123 - Wednesday, March 7, 2018 1:22 PM

    Michael L John - Wednesday, March 7, 2018 1:15 PM

    What have you tried?  Does it work?
    What are the rules for multiple users with the same name? 
    In your example, James Doyel appears three times.  His name becomes James.Doyel1, 2, and 3. 

    How do you know when a second person with the same name may be added?
    For example, "Michael.John" is created as a user name.  Two weeks later, another Michael John needs to be added to the system.  Does the original get changed to Michael.John1, and the new persons user name becomes Michael.John2?

    Yes, 

    If Michael.John user name is created, week later same another Michael.John came then it will be Michael.John1..

    The Rule is, If user name is not there then it uses as FirstName.LastName. If User Name is there it need to add auto incremented by 1.

    Why not just add the user "ID" to everyone and call it a day?

    They are going to display on UI, so they need to have unique UserName, and they decide to increment by 1 if it exist.

    Heh... that's what happens when users do the design. 😀

    That's mean--but SO true... :hehe:

    So ironic too.  Developers say this over and over about users.  Yet when developers insist on "designing" tables without bothering with a true logical design, with no real normalization, with "automatic identity clustering keys", etc., and data modelers or DBAs try to call them out on it, they insist that, even with no full-time professional experience as data modelers, that they are as good (really better!) than the dms and DBAs.
    In short, when we say, "that's what happens when developers do the data/table design."

    This is not said just to be difficult.  I find it somewhat insulting and condescending when the implication is made that even after spending thousands of hours, full-time professionally dedicated to  data modeling / design, to be told by others with no full-time experience, who did it as a minor subset of their programming, that they're just as skilled as you are.

    True enough. However, one nitpick. Nothing wrong with using identities as a clustered and primary key. Mind you, my experience is designing "small to medium" OLTP systems (read, around 10 million records per table) so I can't speak to designing the true behemoths (1+ billion records), which I'm sure have far more severe performance constraints.

    I'm fully in agreement about normalization, though. The impedance mismatch between object oriented design and 3NF is often painful (3NF is viewed by many developers as horrifically antiquated). Part of that is undoubtedly the black-box view developers hold toward databases, but you'd think they'd be aware of SPOT as the data equivalent of DRY.

    It doesn't help when developers develop against "play" tables with a few dozen records either...and wonder why production performance is measured in geological eras...

    "Hey, you're the DBA! The database is the problem, fix it!" (rolling eyes)

    It's a pity that as a Lone Wolf I don't have that luxury! 😀

    Care to tell us what SPOT means?  I know what DRY (don't repeat yourself) is.  It is a pet peeve when people use acronyms without bothering to tell anyone what it means, in other words assuming that everyone already does.

  • Lynn Pettis - Thursday, March 8, 2018 9:14 AM

    roger.plowman - Thursday, March 8, 2018 8:37 AM

    ScottPletcher - Thursday, March 8, 2018 7:53 AM

    roger.plowman - Thursday, March 8, 2018 7:47 AM

    Jeff Moden - Wednesday, March 7, 2018 2:14 PM

    yogi123 - Wednesday, March 7, 2018 2:04 PM

    Jeff Moden - Wednesday, March 7, 2018 1:58 PM

    yogi123 - Wednesday, March 7, 2018 1:22 PM

    Michael L John - Wednesday, March 7, 2018 1:15 PM

    What have you tried?  Does it work?
    What are the rules for multiple users with the same name? 
    In your example, James Doyel appears three times.  His name becomes James.Doyel1, 2, and 3. 

    How do you know when a second person with the same name may be added?
    For example, "Michael.John" is created as a user name.  Two weeks later, another Michael John needs to be added to the system.  Does the original get changed to Michael.John1, and the new persons user name becomes Michael.John2?

    Yes, 

    If Michael.John user name is created, week later same another Michael.John came then it will be Michael.John1..

    The Rule is, If user name is not there then it uses as FirstName.LastName. If User Name is there it need to add auto incremented by 1.

    Why not just add the user "ID" to everyone and call it a day?

    They are going to display on UI, so they need to have unique UserName, and they decide to increment by 1 if it exist.

    Heh... that's what happens when users do the design. 😀

    That's mean--but SO true... :hehe:

    So ironic too.  Developers say this over and over about users.  Yet when developers insist on "designing" tables without bothering with a true logical design, with no real normalization, with "automatic identity clustering keys", etc., and data modelers or DBAs try to call them out on it, they insist that, even with no full-time professional experience as data modelers, that they are as good (really better!) than the dms and DBAs.
    In short, when we say, "that's what happens when developers do the data/table design."

    This is not said just to be difficult.  I find it somewhat insulting and condescending when the implication is made that even after spending thousands of hours, full-time professionally dedicated to  data modeling / design, to be told by others with no full-time experience, who did it as a minor subset of their programming, that they're just as skilled as you are.

    True enough. However, one nitpick. Nothing wrong with using identities as a clustered and primary key. Mind you, my experience is designing "small to medium" OLTP systems (read, around 10 million records per table) so I can't speak to designing the true behemoths (1+ billion records), which I'm sure have far more severe performance constraints.

    I'm fully in agreement about normalization, though. The impedance mismatch between object oriented design and 3NF is often painful (3NF is viewed by many developers as horrifically antiquated). Part of that is undoubtedly the black-box view developers hold toward databases, but you'd think they'd be aware of SPOT as the data equivalent of DRY.

    It doesn't help when developers develop against "play" tables with a few dozen records either...and wonder why production performance is measured in geological eras...

    "Hey, you're the DBA! The database is the problem, fix it!" (rolling eyes)

    It's a pity that as a Lone Wolf I don't have that luxury! 😀

    Care to tell us what SPOT means?  I know what DRY (don't repeat yourself) is.  It is a pet peeve when people use acronyms without bothering to tell anyone what it means, in other words assuming that everyone already does.

    SPOTSystème Pour l'Observation de la Terre (French remote sensing satellite)
    SPOTSatellite Personal Tracker
    SPOTSpotlight
    SPOTShared Product Object Tree
    SPOTSmart Personal Object Technology (Microsoft)
    SPOTSingle Point of Truth
    SPOTScreening of Passengers by Observation Techniques
    SPOTSatellite Probatoire d'Observation de la Terre
    SPOTSensor Placement Optimization Tool (drinking water research)
    SPOTSynchronized Predeployment and Operational Tracker (US Department of Defense program for trackingdeployed contractors)
    SPOTSpecial Purpose Operational Training (airlines)
    SPOTSingle Payment Options Trading (securities)
    SPOTSynchronized Pre-Deployment and Operational Tracker (bar-code system used to track travel/movement ofDoD contractors)
    SPOTSequential Proxy Optimization Technique
    SPOTSecondary-Location Point of Termination
    SPOTSociedad Puertorriqueña de Ortopedia y Traumatología
    SPOTSearching Peak of Tension (polygraph testing)
    SPOTStupid Previous Owner Trick (automotive)
    SPOTSensor Placement Orientation Tool
    SPOTSimply Protecting Our Tots
    SPOTSpace Station Proximity Operations Trainer
    SPOTSpeed Position and Track
    SPOTSprint Procurement Online Tool
    SPOTSignaling Point of Termination
    SPOTStrategic Programs of Technology (Sprint)
    SPOTSwiss Professional Officer Training Course

    Michael L John
    If you assassinate a DBA, would you pull a trigger?
    To properly post on a forum:
    http://www.sqlservercentral.com/articles/61537/

  • True enough. However, one nitpick. Nothing wrong with using identities as a clustered and primary key. Mind you, my experience is designing "small to medium" OLTP systems (read, around 10 million records per table) so I can't speak to designing the true behemoths (1+ billion records), which I'm sure have far more severe performance constraints.

    Roger.Plowman

    The clustered index is the single most important overall performance factor for that table.  Thus, it is wrong to just slap an identity on (nearly) every table and automatically make that the clustering key.  Major mistake.  And it's often done far too early in the design process, corrupting that process.  Candidate keys are never determined and evaluated -- why bother, when you've already determined the "key"?  But you can't verify that data within a table directly relates to "the key, the whole key and nothing but the key" if the key is just some meaningless number!

    Now, there is nothing wrong with having a "sequential number" in the logical design as the identifying attribute of an entity.  For example, a customer number (since it's easy to see that customer name nor email address is a unique or permanent key).  But it is not an "identity", because that is an implementation method, not a logical design feature.  The seq value could come from a sequence, or a pre-filled table of values, or any other number of ways.  That need not be determined at the logical phase, only that a seq num will be the identifier for that entity.

    SQL DBA,SQL Server MVP(07, 08, 09) A socialist is someone who will give you the shirt off *someone else's* back.

  • Michael L John - Thursday, March 8, 2018 10:15 AM

    Lynn Pettis - Thursday, March 8, 2018 9:14 AM

    roger.plowman - Thursday, March 8, 2018 8:37 AM

    ScottPletcher - Thursday, March 8, 2018 7:53 AM

    roger.plowman - Thursday, March 8, 2018 7:47 AM

    Jeff Moden - Wednesday, March 7, 2018 2:14 PM

    yogi123 - Wednesday, March 7, 2018 2:04 PM

    Jeff Moden - Wednesday, March 7, 2018 1:58 PM

    yogi123 - Wednesday, March 7, 2018 1:22 PM

    Michael L John - Wednesday, March 7, 2018 1:15 PM

    What have you tried?  Does it work?
    What are the rules for multiple users with the same name? 
    In your example, James Doyel appears three times.  His name becomes James.Doyel1, 2, and 3. 

    How do you know when a second person with the same name may be added?
    For example, "Michael.John" is created as a user name.  Two weeks later, another Michael John needs to be added to the system.  Does the original get changed to Michael.John1, and the new persons user name becomes Michael.John2?

    Yes, 

    If Michael.John user name is created, week later same another Michael.John came then it will be Michael.John1..

    The Rule is, If user name is not there then it uses as FirstName.LastName. If User Name is there it need to add auto incremented by 1.

    Why not just add the user "ID" to everyone and call it a day?

    They are going to display on UI, so they need to have unique UserName, and they decide to increment by 1 if it exist.

    Heh... that's what happens when users do the design. 😀

    That's mean--but SO true... :hehe:

    So ironic too.  Developers say this over and over about users.  Yet when developers insist on "designing" tables without bothering with a true logical design, with no real normalization, with "automatic identity clustering keys", etc., and data modelers or DBAs try to call them out on it, they insist that, even with no full-time professional experience as data modelers, that they are as good (really better!) than the dms and DBAs.
    In short, when we say, "that's what happens when developers do the data/table design."

    This is not said just to be difficult.  I find it somewhat insulting and condescending when the implication is made that even after spending thousands of hours, full-time professionally dedicated to  data modeling / design, to be told by others with no full-time experience, who did it as a minor subset of their programming, that they're just as skilled as you are.

    True enough. However, one nitpick. Nothing wrong with using identities as a clustered and primary key. Mind you, my experience is designing "small to medium" OLTP systems (read, around 10 million records per table) so I can't speak to designing the true behemoths (1+ billion records), which I'm sure have far more severe performance constraints.

    I'm fully in agreement about normalization, though. The impedance mismatch between object oriented design and 3NF is often painful (3NF is viewed by many developers as horrifically antiquated). Part of that is undoubtedly the black-box view developers hold toward databases, but you'd think they'd be aware of SPOT as the data equivalent of DRY.

    It doesn't help when developers develop against "play" tables with a few dozen records either...and wonder why production performance is measured in geological eras...

    "Hey, you're the DBA! The database is the problem, fix it!" (rolling eyes)

    It's a pity that as a Lone Wolf I don't have that luxury! 😀

    Care to tell us what SPOT means?  I know what DRY (don't repeat yourself) is.  It is a pet peeve when people use acronyms without bothering to tell anyone what it means, in other words assuming that everyone already does.

    SPOTSystème Pour l'Observation de la Terre (French remote sensing satellite)
    SPOTSatellite Personal Tracker
    SPOTSpotlight
    SPOTShared Product Object Tree
    SPOTSmart Personal Object Technology (Microsoft)
    SPOTSingle Point of Truth
    SPOTScreening of Passengers by Observation Techniques
    SPOTSatellite Probatoire d'Observation de la Terre
    SPOTSensor Placement Optimization Tool (drinking water research)
    SPOTSynchronized Predeployment and Operational Tracker (US Department of Defense program for trackingdeployed contractors)
    SPOTSpecial Purpose Operational Training (airlines)
    SPOTSingle Payment Options Trading (securities)
    SPOTSynchronized Pre-Deployment and Operational Tracker (bar-code system used to track travel/movement ofDoD contractors)
    SPOTSequential Proxy Optimization Technique
    SPOTSecondary-Location Point of Termination
    SPOTSociedad Puertorriqueña de Ortopedia y Traumatología
    SPOTSearching Peak of Tension (polygraph testing)
    SPOTStupid Previous Owner Trick (automotive)
    SPOTSensor Placement Orientation Tool
    SPOTSimply Protecting Our Tots
    SPOTSpace Station Proximity Operations Trainer
    SPOTSpeed Position and Track
    SPOTSprint Procurement Online Tool
    SPOTSignaling Point of Termination
    SPOTStrategic Programs of Technology (Sprint)
    SPOTSwiss Professional Officer Training Course

    See what I mean?  I am guessing, after reading all of these, that in this context SPOT is supposed to mean Single Point Of Truth.

  • 'm fully in agreement about normalization, though. The impedance mismatch between object oriented design and 3NF is often painful (3NF is viewed by many developers as horrifically antiquated).

    Roger.Plowman

    This is an interesting issue.  I'll just point out that developers often ignore the fact that:

    THE CODE IS WHAT IS TRANSIENT, AND WILL BE SUPPLANTED SOON ENOUGH, THE DATA LIVES FOREVER!

    Go back 20 years.  Is it the same code as today?  Not likely.  But s it the same core data as today?  For the most part, yes.

    Therefore, my view is that you don't corrupt the data design to match current programming methods.  The data needs to be resilient enough to go from COBOL (thrown in just for Celko) to System R to Oracle to whatever.  Other methods need to be used to model data for NoSQL and network dbs, but the overall thought is the same.  The current method of developing code should not interfere with design the data repository, which will outlive the code anyway.

    SQL DBA,SQL Server MVP(07, 08, 09) A socialist is someone who will give you the shirt off *someone else's* back.

  • Lynn Pettis - Thursday, March 8, 2018 9:14 AM

    roger.plowman - Thursday, March 8, 2018 8:37 AM

    ScottPletcher - Thursday, March 8, 2018 7:53 AM

    roger.plowman - Thursday, March 8, 2018 7:47 AM

    Jeff Moden - Wednesday, March 7, 2018 2:14 PM

    yogi123 - Wednesday, March 7, 2018 2:04 PM

    Jeff Moden - Wednesday, March 7, 2018 1:58 PM

    yogi123 - Wednesday, March 7, 2018 1:22 PM

    Michael L John - Wednesday, March 7, 2018 1:15 PM

    What have you tried?  Does it work?
    What are the rules for multiple users with the same name? 
    In your example, James Doyel appears three times.  His name becomes James.Doyel1, 2, and 3. 

    How do you know when a second person with the same name may be added?
    For example, "Michael.John" is created as a user name.  Two weeks later, another Michael John needs to be added to the system.  Does the original get changed to Michael.John1, and the new persons user name becomes Michael.John2?

    Yes, 

    If Michael.John user name is created, week later same another Michael.John came then it will be Michael.John1..

    The Rule is, If user name is not there then it uses as FirstName.LastName. If User Name is there it need to add auto incremented by 1.

    Why not just add the user "ID" to everyone and call it a day?

    They are going to display on UI, so they need to have unique UserName, and they decide to increment by 1 if it exist.

    Heh... that's what happens when users do the design. 😀

    That's mean--but SO true... :hehe:

    So ironic too.  Developers say this over and over about users.  Yet when developers insist on "designing" tables without bothering with a true logical design, with no real normalization, with "automatic identity clustering keys", etc., and data modelers or DBAs try to call them out on it, they insist that, even with no full-time professional experience as data modelers, that they are as good (really better!) than the dms and DBAs.
    In short, when we say, "that's what happens when developers do the data/table design."

    This is not said just to be difficult.  I find it somewhat insulting and condescending when the implication is made that even after spending thousands of hours, full-time professionally dedicated to  data modeling / design, to be told by others with no full-time experience, who did it as a minor subset of their programming, that they're just as skilled as you are.

    True enough. However, one nitpick. Nothing wrong with using identities as a clustered and primary key. Mind you, my experience is designing "small to medium" OLTP systems (read, around 10 million records per table) so I can't speak to designing the true behemoths (1+ billion records), which I'm sure have far more severe performance constraints.

    I'm fully in agreement about normalization, though. The impedance mismatch between object oriented design and 3NF is often painful (3NF is viewed by many developers as horrifically antiquated). Part of that is undoubtedly the black-box view developers hold toward databases, but you'd think they'd be aware of SPOT as the data equivalent of DRY.

    It doesn't help when developers develop against "play" tables with a few dozen records either...and wonder why production performance is measured in geological eras...

    "Hey, you're the DBA! The database is the problem, fix it!" (rolling eyes)

    It's a pity that as a Lone Wolf I don't have that luxury! 😀

    Care to tell us what SPOT means?  I know what DRY (don't repeat yourself) is.  It is a pet peeve when people use acronyms without bothering to tell anyone what it means, in other words assuming that everyone already does.

    SPOT = Single Point Of Truth (i.e. only store a piece of data in one place)

Viewing 15 posts - 16 through 30 (of 32 total)

You must be logged in to reply to this topic. Login to reply