472,779 Members | 1,843 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,779 software developers and data experts.

user defined fields best design

hi all(happy raksha bandhan day)

we have one of Automation software for sales running for a
customer.He was cool for the first month of product, but later popped
with adding some extra fields.no problems i added in database , put a
seperate code in my application for that field.but later every 2 days
he was adding new fields.....so i thought to put in some inbuilt logic
user defined fields.second his user defined fields are like shoudl be
numeric,string , length validation.But do not know whats the best way
to acheive this.I mean should i make seperate table where i define
field name, data types , validation and then in my application code a
general logic for it in my application code.Any one has prooven design
for user defined fields,just thinking if i can even get a idea.....
When i die i die programming........
Jul 20 '05 #1
2 5278
shivprasad koirala (sh**********@yahoo.com) writes:
we have one of Automation software for sales running for a
customer.He was cool for the first month of product, but later popped
with adding some extra fields.no problems i added in database , put a
seperate code in my application for that field.but later every 2 days
he was adding new fields.....so i thought to put in some inbuilt logic
user defined fields.second his user defined fields are like shoudl be
numeric,string , length validation.But do not know whats the best way
to acheive this.I mean should i make seperate table where i define
field name, data types , validation and then in my application code a
general logic for it in my application code.Any one has prooven design
for user defined fields,just thinking if i can even get a idea.....


I think the most important here is to get the requirements right. Do the
customer require to be able to add fields himself? And is he prepared to
pay for it?

One thing you could do is:

CREATE TABLE customfields (
fieldcode varchar(10) NOT NULL,
fielddescr varchar(80) NOT NULL,
typeofdata char(1) NOT NULL
CONSTRAINT ckc_cf_typeofdata CHECK -- Int, Date, Float, Varchar
(typeofdata IN ('I', 'D', 'F', 'V'))
minvalue sql_variant NULL,
maxvalue sql_variant NULL,
isnullable bit NOT NULL,
CONSTRIANT pk_customfields (fieldcode)
)

CREATE TABLE customfieldvaleus (
entityid int NOT NULL,
fieldcode varchar(10) NOT NULL,
value sql_variant NULL,
CONSTRAINT pk_customefieldvalues (entityid, fieldcode),
CONSTRAINT fk_entitityid FOREIGN KEY (entityid)
REFERENCES mainentitytable(id),
CONSTRINAT fk_fieldcode FOREIGN KEY (fieldcode)
REFERENCES customefields (fieldcode)
)

You could add more columns to customfields for validation rules.

Generally, tables like this example are more difficult to program
against. For instance, if you misspell a fieldcode in the SQL code,
the compiler won't tell you. I'd say that this structure is only
warranted when there truly is a requirement for custom-added fields.
There is one more case: when fields are added frequently, and most
accesses only are to a single field anyway. We have a couple of
tables of the latter kind in our database, and they are typically
parameter tables.

--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #2
thanks Erland Sommarskog for that 10000000000 worth advice

i has this design in my mind but just thought that was there any mroe
easy way.

take care

when i die i die programming
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Marc Walgren | last post by:
Greetings I have an ASP application to enter reservations. There are multiple user security settings that require some users to have a restricted list of client in a drop list on a form. I...
2
by: Les Stockton | last post by:
In VB6 you had a Type and End Type to define your own data types. Are the only ways to do this in VB.Net with enums, struct and class. How's the best way to define user defined types?
17
by: Steve R. Hastings | last post by:
I have been studying Python recently, and I read a comment on one web page that said something like "the people using Python for heavy math really wish they could define their own operators". The...
1
by: Bob Alston | last post by:
Anyone have experience in building Access apps with user definable fields? (Not the kind of fields where you just let the user define the label for a pre set number of predefined fields.) I...
37
by: Joergen Bech | last post by:
(Slightly religious question): Suppose I have the following class: ---snip--- Public Class MyClass Private _MyVariable As Integer Public Property MyVariable() As Integer Get
5
by: Tony Johansson | last post by:
Hello! I have one solution file that consist of three project. One project that build the exe file called A One project that build a user control dll. Here we have a class called B One project...
12
by: M G Henry | last post by:
I have a tabbed form that contains 12 different "pages" and when I try and run the form I get the error message too many fields defined --- which I believe is the 255 field limit in the record...
0
FishVal
by: FishVal | last post by:
Hereby I'm proposing a way of convinient work with properties containing SQL Select statements, particulary RowSource property of ComboBox and ListBox. The usual way is the following. Private...
9
by: happyse27 | last post by:
Hi All, In perl script(item b below) where we check if html registration form are filled in properly without blank with the necessary fields, how to prompt users that the field are incomplete...
0
by: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.