Is there a way that we can dynamically add column in the smartforms based on the record on the internal table?
Best Regards
There is no direct way to do it, but I can imagine a couple of workarounds you can try:
Put a condition in a table node column
This will hide the column if the record meets the condition, but leave there an empty space
Create two templates with different number of columns and show them using the alternative element.
This will make a clean solution when there will not be neither column nor empty space.
Related
i'm wondering if there is a way to relate between rows in the same table.
for example: i want to store a keywords in the database and make every single keyword points to others which are related to it. (instead of creating a table to every single keyword and add related keywords to it)
if not, hope anyone can suggest an idea to store keyword and relate between them with minimum size.
Thanks,
Is it good practice to add some placeholder columns when creating a database table with millions of rows, in case the schema gets changed later? More efficient to rename a column than to insert a new one?
There are many problems with adding "placeholder" columns to a table.
These columns may take up useless space, and appear "sloppy".
You may create too many columns now, and have columns that will never be used.
You may not create enough columns now, and will have to end up creating more anyways.
You don't know what the column data types will be at this time.
Always remember that if a column needs added at a later date and will not be used for any of the current rows in the table, you can still keep the table normalized by creating a smaller table that holds this information, then link them by using the primary key.
Let me know if you have any questions about this. I hope this helps!
The scenario is that, I have 2 database tables A and B. The table B is an upgraded version of the table A. (ie It might possibly have different field names and some extra fields). I need to compare these 2 tables to inform the user about these extra fields and propose to him a mapping of the fields between the tables.
Currently I am thinking of comparing them using info like field name, data element and domain in that order.
Is there a standard way to do this? Thanks in advance.
There is no standard tool to do this - why would you want to do it this way anyway? The canonical way is to extend the original table and fill the new fields in place.
I want to create a reference table. The number of rows and columns can grow (and become redundant) over time. The column names may change over time as well. Lets asume the value in Column 'Position' is 'IT Engineer', in row(n). For that specific row(n) further down in the column structure, lets say in column 'Behind Sheds', is a value I need to retrieve. If the number of columns was fixed, it was no issue, but now the columns are added dynamically with T-SQL, which is fairly easy to do, even renaming these columns. My question is, is it good practice to add columns dynamicaly for the example above, or is there an better alternative, and how?
Thanks.
may be better use something like addition table with fields: person_id (forign key to main table), person_param (as example 'Position'), person_value (as example 'IT Engineer')?
I believe your issue is the right for implementing the EAV model.
Basically instead of having 20 columns, you have 3:
Entity
Attribute (otherwise known as column name)
Value (might actually be more values, of different types, and you just populate the right one)
That way, for 10 entities in the database, having 20 columns each, you populate 200 rows of data in an EAV table. It has less performance, it's harder to query, but it does allow flexibility, so you can make each entity have different sets of attributes even.
The user wants to add new fields in UI dynamically. This new field should get stored in database and they should be allowed to perform CRUD on it.
Now I can do this by specifying a XML but I wanted a better way where these new columns are searchable. Also the idea of firing ALTER statement and adding a new column seems wrong.
Can anyone help me with a design pattern on database server side of how to solve this problem?
This can be approached using a key value system. You create a table with the primary key column(s) of the table you want to annotate, a column for the name of the attribute, and a column for its value. When you user wants to add an attribute (say height) to the record of person 123 you add a row to the new table with the values (123, 'HEIGHT', '140.5').
In general you cast the values to TEXT for storage but if you know all the attributes will be numeric you can choose a different type for the value column. You can also (not recommended) use several different value columns depending on the type of the data.
This technique has the advantage that you don't need to modify the database structure to add new attributes and attributes are only stored for those records that have them. The disadvantage is that querying is not as straightforward as if the columns were all in the main data table.
There is no reason why a qualified business user should not be allowed to add a column to a table. It is less likely to cause a problem than just about anything else you can imagine including adding a new row to a table or changing. the value of a data element.
Using either of the methods described above do not avoid any risk; they are simply throwbacks to COBOL filler fields or unnecessary embellishments of the database function. The result can still be unnormalized and inaccurate.
These same business persons add columns to spreadsheets and tables to Word documents without DBAs getting in their way.
Of course, just adding the column is the smallest part of getting an information system to work, but it is often the case that it is perceived to be an almost insurmountable barrier. It is in fact 5 min worth of work assuming you know where to put it. Adding a column to the proper table with the proper datatype is easy to do, easy to use, and has the best chance of encouraging data quality.
Find out what the maximum number of user-added fields will be and add them before hand. For example 'User1', 'User2', 'User3', 'User4'...etc. You can then enable the fields on the UI based on some configurable settings.