473,395 Members | 1,530 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Is it wrong to allow user initiated DDL commands to facilitate an extensible schema

I have a client who wants to build a database with a user extensible
schema.

The client wants to model an entity with about 100 numeric attributes.
As time goes on, more numeric attributes will be added. The client
wants an admin function that will allow him to add these attributes
when needed.

My instinct is that this is wrong and that bad things will happen if
we build this. However, when I went to write up the reasons, all I
could come up with was that
* we would need to write dynamic SQL to handle the changing table
structure,
* that table locking would result from field additions
* and that it was "non-standard"

One alternative is to create a table containing field-name/value
pairs. This is ugly and breaks the ER modelling rules that tell me yo
put attributes of an item into the same row. All the same, I would
prefer this method to the first approach.

This problem does not arise on database projects that follow the
pattern of only allowing DDL commands to be issued during the initial
development phase and during subsequent change requests.

Have any of you been faced with a similar problem? What should I do?

Karen
Jul 20 '05 #1
4 1437
Karen Sundquist (ka********@yahoo.com) writes:
One alternative is to create a table containing field-name/value
pairs. This is ugly and breaks the ER modelling rules that tell me yo
put attributes of an item into the same row. All the same, I would
prefer this method to the first approach.


This would be my preference too.

Of course, neither this is going to be fun if you want reports with
these attributes as columns. You could define views that twisted
the rows as columns, but with over 100 columns that will be a horrible
self-join if all attributes are to be included.
--
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
Actually, the grotesque-looking aggregation of the attribute/value table
is reasonably fast.
It also gives you a way to enforce TYPES on the values,
which is another real issue with attribute/value format.
The underlying table is still amazingly spacewasteful,
but if you HAVE to ....

CREATE VIEW Normal AS
SELECT key1, key2, ...
min(case when attribute = 'name' then value end) as name,
min(case when attribute = 'asof' then cast(value as
datetime) end) as asof,
...
FROM Abnormal
GROUP BY key1, key2, ...

I can't speak for the MSSQL engine, but proper dragging and beating
in the query tree ought to eliminate any processing to support
unused columns (MIN(...) expressions) when making reference
to the view.

"Erland Sommarskog" <es****@sommarskog.se> wrote in message
news:Xn*********************@127.0.0.1...
Karen Sundquist (ka********@yahoo.com) writes:
One alternative is to create a table containing field-name/value
pairs. This is ugly and breaks the ER modelling rules that tell me yo
put attributes of an item into the same row. All the same, I would
prefer this method to the first approach.


This would be my preference too.

Of course, neither this is going to be fun if you want reports with
these attributes as columns. You could define views that twisted
the rows as columns, but with over 100 columns that will be a horrible
self-join if all attributes are to be included.
--
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 #3
Mischa and Erland, thanks for your advice. I am going to go with the
field/value pairs, as I did the last time I had this problem.
Karen
Jul 20 '05 #4
Mischa Sandberg (mi*************@telus.net) writes:
It also gives you a way to enforce TYPES on the values,
which is another real issue with attribute/value format.


Apparently in Karen's case, the attributes were numeric, so maybe it's
issue this time.

In the general case where attributes are of mixed types, you can use the
the sql_variant datatype, and supplement with a column which defines
the datatype. Then you have a constraint which goes like this:

sql_variant_property(value, 'Basetype') =
CASE typeofdata
WHEN 'B' THEN bit
WHEN 'D' THEN datetime
...
END

--
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 #5

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

Similar topics

4
by: Mark Wilson CPU | last post by:
A colleague has written a prototype program in PHP, using a MySQL database. It's a relatively simple app, with a restricted set of mysql commands used (see below). The MySQL DB is being replaced...
2
by: Fran Tirimo | last post by:
I am developing a small website using ASP scripts to format data retrieved from an Access database. It will run on a Windows 2003 server supporting FrontPage extensions 2002 hosted by the company...
0
by: Florian von Savigny | last post by:
Hi there, I am having a hard time in grasping how the TBX (TermBase eXchange format), authored by LISA (http://www.lisa.org/tbx/) exactly works. What I seem to have understood is the...
88
by: Mike | last post by:
Is there a way to determine what a user's default email client is? I read a post from 3 years ago that said no. I guess I'm hoping something has come along since then.
7
by: Stefan Mueller | last post by:
I choose 'Entry 4' and click then on the button 'Set' to set the index to 'Entry 2'. If you press now the cursor down key 'Entry 5' instead of 'Entry 3' shows up with Mozilla Firefox. With Internet...
4
by: d0wsdkn02 | last post by:
I have an ASP.NET application that performs ADO.NET commands that cause triggers to be run in SQL Server 2000. My question is how would I best access the user ID from my custom .NET Principal in...
3
by: xeroxero | last post by:
I would like to prevent people from downloading a .zip from a ASP.NET 2.0 web site, but still allow people to touch a .aspx page in the same directory. I also want to set things so if a user clicks...
2
by: Nosferatum | last post by:
This script is meant to limit access by sessions, using username and password from mysql db and redirect users after login according to a given value belonging to each user in the db (10,20,30,40)....
3
by: Rahul B | last post by:
Hi, I have a user UCLDEV1 which is a part of staff and a group(db2schemagrp1) to which i have not given any permissions. The authorizations of that user are shown as db2 =get authorizations...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.