# Creating a table for SQL of users

**URL:** <https://forum.inductiveautomation.com/t/creating-a-table-for-sql-of-users/58042>\
**Category:** Ignition\
**Created:** [April 5, 2022, 1:20pm UTC](https://forum.inductiveautomation.com/t/creating-a-table-for-sql-of-users/58042 "2022-04-05T13:20:20Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![zacharyw.larson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zacharyw.larson/32/23749_2.png) [@zacharyw.larson](https://forum.inductiveautomation.com/u/zacharyw.larson)\
**Post date:** [April 5, 2022, 1:20pm UTC](https://forum.inductiveautomation.com/t/creating-a-table-for-sql-of-users/58042/1 "2022-04-05T13:20:20Z")

</div>

Seems like tables with first and last names is a common thing people make, and I want to avoid common mistakes.

I think varchar(80) for user names seems good.  
Looks like industry standard varies from 60-300 characters from my research.

I remember vaguely having an issue with unentered data with one of the datatypes though, and I don’t remember which one it is.

Also, some people are giving me just last names. I was going to put last and first name in one column.

Right now I am just showing these names in one column on a report.

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [April 5, 2022, 1:27pm UTC](https://forum.inductiveautomation.com/t/creating-a-table-for-sql-of-users/58042/2 "2022-04-05T13:27:46Z")

</div>

I’m sorry but… What’s the question ? 😃

---

<div class="post-metadata">

**Author:** ![zacharyw.larson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zacharyw.larson/32/23749_2.png) [@zacharyw.larson](https://forum.inductiveautomation.com/u/zacharyw.larson)\
**Post date:** [April 5, 2022, 1:30pm UTC](https://forum.inductiveautomation.com/t/creating-a-table-for-sql-of-users/58042/3 "2022-04-05T13:30:42Z")

</div>

haha  
Is varchar(80) for one column of (lastname, firstname) an obvious mistake?

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [April 5, 2022, 1:39pm UTC](https://forum.inductiveautomation.com/t/creating-a-table-for-sql-of-users/58042/4 "2022-04-05T13:39:43Z")

</div>

You’re putting first name and last name in the same column ?  
I’d keep them in separate columns, and allow null for the first name if some people don’t provide it.  
80 should be fine for each one of them, but frankly I’m just assuming…

---

<div class="post-metadata">

**Author:** ![zacharyw.larson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zacharyw.larson/32/23749_2.png) [@zacharyw.larson](https://forum.inductiveautomation.com/u/zacharyw.larson)\
**Post date:** [April 5, 2022, 1:40pm UTC](https://forum.inductiveautomation.com/t/creating-a-table-for-sql-of-users/58042/5 "2022-04-05T13:40:17Z")

</div>

when you say allow null, what do you mean?

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [April 5, 2022, 1:49pm UTC](https://forum.inductiveautomation.com/t/creating-a-table-for-sql-of-users/58042/6 "2022-04-05T13:49:28Z")

</div>

When you set up the column, set it so that NULL values are allowed.

You can set up a column to either allow NULL or not. If it doesn’t and you try to insert or update a NULL value you will get a SQL Exception.

---

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [April 5, 2022, 1:51pm UTC](https://forum.inductiveautomation.com/t/creating-a-table-for-sql-of-users/58042/7 "2022-04-05T13:51:02Z")

</div>

Isn’t allow NULL default for most databases?

---

<div class="post-metadata">

**Author:** ![zacharyw.larson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zacharyw.larson/32/23749_2.png) [@zacharyw.larson](https://forum.inductiveautomation.com/u/zacharyw.larson)\
**Post date:** [April 5, 2022, 1:51pm UTC](https://forum.inductiveautomation.com/t/creating-a-table-for-sql-of-users/58042/8 "2022-04-05T13:51:27Z")

</div>

I have nulls all the time on the user input stuff and sometimes even the transaction groups

I hope it is default, or I really need to know how to set null allowed

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [April 5, 2022, 1:56pm UTC](https://forum.inductiveautomation.com/t/creating-a-table-for-sql-of-users/58042/9 "2022-04-05T13:56:30Z")

</div>

It is default for most databases that I am aware of, and if you’re adding a column to a table that already has data in it, I don’t think you can do it any other way.

I know for a fact it is the default for MS SQL.

---

<div class="post-metadata">

**Author:** ![peter](https://avatars.discourse-cdn.com/v4/letter/p/278dde/32.png) [@peter](https://forum.inductiveautomation.com/u/peter)\
**Post date:** [April 5, 2022, 2:06pm UTC](https://forum.inductiveautomation.com/t/creating-a-table-for-sql-of-users/58042/10 "2022-04-05T14:06:41Z")

</div>

You should take a look at [Falsehoods programmers believe about names](https://www.kalzumeus.com/2010/06/17/falsehoods-programmers-believe-about-names/) and then go cry in a corner when you realize how inadequate your planned system will be.

(But then feel a bit smug because you are not having to deal with [Falsehoods programmers believe about addresses](https://www.mjt.me.uk/posts/falsehoods-programmers-believe-about-addresses/))

---

<div class="post-metadata">

**Author:** ![zacharyw.larson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zacharyw.larson/32/23749_2.png) [@zacharyw.larson](https://forum.inductiveautomation.com/u/zacharyw.larson)\
**Post date:** [April 5, 2022, 2:12pm UTC](https://forum.inductiveautomation.com/t/creating-a-table-for-sql-of-users/58042/11 "2022-04-05T14:12:31Z")

</div>

Thanks

I very much appreciate the perspective

I am going to accept that this column will have issues and I will deal with them as they crop up

---

<div class="post-metadata">

**Author:** ![kcollins](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kcollins/32/19646_2.png) [@kcollins](https://forum.inductiveautomation.com/u/kcollins)\
**Post date:** [April 5, 2022, 2:13pm UTC](https://forum.inductiveautomation.com/t/creating-a-table-for-sql-of-users/58042/12 "2022-04-05T14:13:46Z")

</div>

One thing to consider as a possibility is to create an Ignition User Source of _Database_ type and point it to your database connection (probably make sure to customize the default prefix of `scada_` to your needs). Then add a user through the Gateway web UI, and Ignition will automatically create tables like below (example is MariaDB):

 ![2022-04-05 at 9.12 AM](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/2/22839175ff196b85ddae0d6ec9247d209f162d55.png)

One advantage to this is that you could use the Ignition functions (and components) for managing the user source. Just something to consider (if it happens to fit the need).
