Showing posts with label design. Show all posts
Showing posts with label design. Show all posts

Wednesday, March 7, 2012

Desining a database question

Hi,

i need store relation between people... (friends, family)

i have a table with list of users.

i need to design a table where i would like to store relation between users. i.e. who are friends of xx etc.

will really appreciate if someone can guide me how to create such table.

Here is how I would set it up:

TUsers
intUserID
strUsername
strPassword
strFirstName
strLastName
strAddressLine1
strAddressLine2
strCity
strState
strZipCode

TUserFriends
intUserID
intFriendID
intUserFriendRelationshipID

TUserFriendRelationShips
intUserFriendRelationshipID
strUserFriendRelationship

|||

thanks a lot,

Designing SQL2K RS reports using VS 2005 Express

Anyone:
Is it possible to install the SQL Server 2000 Reporting Services design
component for Visual Studio 2003 into Visual Studio 2005 Express to design
reports that will be deployed to Reporting Services running on SQL Server
2000? Thank you in advance for your time.No, this is not possible. RS 2000 Report Designer requires VS 2003.
--
Albert Yen
SQL Server Reporting Services
This posting is provided "AS IS" with no warranties, and confers no rights.
"Nikolai Sonin" <NikolaiSonin@.discussions.microsoft.com> wrote in message
news:B5728FFD-6C1A-4C59-A3A7-C415C4436DFD@.microsoft.com...
> Anyone:
> Is it possible to install the SQL Server 2000 Reporting Services
> design
> component for Visual Studio 2003 into Visual Studio 2005 Express to design
> reports that will be deployed to Reporting Services running on SQL Server
> 2000? Thank you in advance for your time.|||I have an MSDN subscription and just installed both SQL Server 2005 Beta
tools and Visual Studio 2005 Beta 2 - I'm assuming:
1.) That SQL Server 2005 has a Report Designer
2.) That the SQL Server 2005 Report Designer will plug into Visual
Studio 2005
3.) That the SQL Server 2005 Report Designer inside of Visual Studio
2005 will work on SQL Server 2000 Databases
4.) That there is some way of importing reports designed in SQL Server
2000 Report Designer into the SQL Server 2005 Report Designer.
Could you tell me which of these are true?
"Albert Yen [MSFT]" wrote:
> No, this is not possible. RS 2000 Report Designer requires VS 2003.
> --
> Albert Yen
> SQL Server Reporting Services
> This posting is provided "AS IS" with no warranties, and confers no rights.
> "Nikolai Sonin" <NikolaiSonin@.discussions.microsoft.com> wrote in message
> news:B5728FFD-6C1A-4C59-A3A7-C415C4436DFD@.microsoft.com...
> > Anyone:
> > Is it possible to install the SQL Server 2000 Reporting Services
> > design
> > component for Visual Studio 2003 into Visual Studio 2005 Express to design
> > reports that will be deployed to Reporting Services running on SQL Server
> > 2000? Thank you in advance for your time.
>
>

Saturday, February 25, 2012

designing history tables

Could some one please point me to a good resource on how to design history
tables in a dataware house situation'
For example, in the case of products table, if product description got
changed over time after the product was purchased. The old invoice still
shows the old description but the table reflects the new one.
How could some one keep track of both descriptions?
What would be a good design/architecture'
TIA...Well, the invoices table should contain a relatively permanent piece of
data, such as a ProductID of some kind, not a much more flexible piece of
information like a description.
That said, it may still be useful to store the history of a product.
Probably the simplest in this very specific case would be:
CREATE TABLE dbo.ProductDescriptionHistory
(
ProductID INT NOT NULL
FOREIGN KEY REFERENCES dbo.Products(ProductID),
Description VARCHAR(255),
EffectiveDate SMALLDATETIME
)
This will allow you to reconstruct invoices from the past, with the correct
"at the time" description, without bloating the invoices table with a big
VARCHAR that will usually be redundant.
You will probably come across the same dilemma with price... do you store
price data for products where the price may or may not change, or do you
just reference the productID?
Your exact solution will at least partially depend on some of the
information you haven't provided, such as exactly why you need the historic
descriptions, what you're going to do with them, and how often they actually
change.
"sqlster" <nospam@.nospam.com> wrote in message
news:3F41C612-B1AB-441F-AED7-26F4C7ABEA09@.microsoft.com...
> Could some one please point me to a good resource on how to design history
> tables in a dataware house situation'
> For example, in the case of products table, if product description got
> changed over time after the product was purchased. The old invoice still
> shows the old description but the table reflects the new one.
> How could some one keep track of both descriptions?
> What would be a good design/architecture'
> TIA...|||<Aaron>
Your exact solution will at least partially depend on some of the
information you haven't provided, such as exactly why you need the historic
descriptions, what you're going to do with them, and how often they actually
change.
</Aaron>
I need the historic descriptions for the reporting purposes only. Some of
the values could change 10 - 15 times a month.
Thanks
"Aaron Bertrand [SQL Server MVP]" wrote:

> Well, the invoices table should contain a relatively permanent piece of
> data, such as a ProductID of some kind, not a much more flexible piece of
> information like a description.
> That said, it may still be useful to store the history of a product.
> Probably the simplest in this very specific case would be:
> CREATE TABLE dbo.ProductDescriptionHistory
> (
> ProductID INT NOT NULL
> FOREIGN KEY REFERENCES dbo.Products(ProductID),
> Description VARCHAR(255),
> EffectiveDate SMALLDATETIME
> )
> This will allow you to reconstruct invoices from the past, with the correc
t
> "at the time" description, without bloating the invoices table with a big
> VARCHAR that will usually be redundant.
> You will probably come across the same dilemma with price... do you store
> price data for products where the price may or may not change, or do you
> just reference the productID?
> Your exact solution will at least partially depend on some of the
> information you haven't provided, such as exactly why you need the histori
c
> descriptions, what you're going to do with them, and how often they actual
ly
> change.
>
> "sqlster" <nospam@.nospam.com> wrote in message
> news:3F41C612-B1AB-441F-AED7-26F4C7ABEA09@.microsoft.com...
>
>|||Keep who changed the rows and when in separate columns in the archive table.
You might also want to keep a record of whether the row in the main table wa
s
updated or deleted.
E.g.:
Main table:
Col1 : Col2 : ... : ColN
Archive table:
Col1 : Col2 : ... : ColN : ChangedDateTime : ChangedBy : ChangeType
Of course changes are propagated to the archive table via triggers on the
main table (for update and for delete).
For a more elaborate solution, please at least provide DDL.
ML
http://milambda.blogspot.com/|||ML,
I am just looking for some books/websites/articles that address good history
table design. The example that I brought up is just a hypothetical example s
o
I don't have any DDL.
TIA..
"ML" wrote:

> Keep who changed the rows and when in separate columns in the archive tabl
e.
> You might also want to keep a record of whether the row in the main table
was
> updated or deleted.
> E.g.:
> Main table:
> Col1 : Col2 : ... : ColN
> Archive table:
> Col1 : Col2 : ... : ColN : ChangedDateTime : ChangedBy : ChangeType
> Of course changes are propagated to the archive table via triggers on the
> main table (for update and for delete).
> For a more elaborate solution, please at least provide DDL.
>
> ML
> --
> http://milambda.blogspot.com/

Designing Database Diagramm

Hi,
i am looking for a tool to design den model of a database.
i took a look at powerdesigner, embacadero..
which one do you prefer to design the model.
i am using SQL SERVER 2005.
Message posted via webservertalk.com
http://www.webservertalk.com/Uwe/Forum...amming/200602/1HI,
There are quite a few out there,
Erwin,
Visio,
Case Studio
Datanamics Dezign
All depends on the indivisual, the project, what you like, what you want to
do.
I use both case studio and dezign, because it fits my needs and I can afford
it.
Robert
"fantasimus via webservertalk.com" <u16093@.uwe> wrote in message
news:5bf54d8709c30@.uwe...
> Hi,
> i am looking for a tool to design den model of a database.
> i took a look at powerdesigner, embacadero..
> which one do you prefer to design the model.
> i am using SQL SERVER 2005.
> --
> Message posted via webservertalk.com
> http://www.webservertalk.com/Uwe/Forum...amming/200602/1

Designing Crystal Report with Brought forward value

Please i am new to crystal report design even though I have been able to design some simple reports. I would appreciate your kind assistance.

I have a crystal report from VB.Net that has series of columns (fields) generated from the following two tables.

1. tblAgt - Table
fconsole (float field)
fagent
B1

2. tblDebit - Table
fmending (Date field)
ActNo
fagent
ftrans
fgrssprem (float field)
Comm
The report has the following format

Date: 01/01/2004 To 31/12/2004
Account No: 38000 To 38092

Balance bf: 00.00

fmending ActNo Fagent ftr fgrssprem Comm. Net Amt
02/02/04 38837 db001 DR 5,000.00 350.00 4,650
02/07/04 38838 db002 CR 15,000.30 200.00 15,200.30
03/02/02 29388 db003 pyt 2,000.00 100.00 1,900.00
--------------------------

The Date and the Accounts Group header were generated with the parameter fields (Range)

The Date Range (StartDate & EndDate) header
The Account Range (StartAcct & EndAcct) header

The DB or CR or Pyt entry determines whether the fgrssprm is negative or positive e.g. To get the Netamt

if ftrans = CR, then Comm is added
if ftrans = DR, then Comm is deducted

The Balance bf: is where I am having a problem with because it is suppose
to be generated from all fgrssprem that falls before StartDate eg. 1/01/2004
ie. fmending(tablefield) < startdate (parameter field)

Balance bf = sum(fgrssprem(tbldebit) is added to fconsole in table (tblagt) ie. Balance bf = fgrssprem + fconsole

I am trying to filter for all the dates that is less than startdate and to get the sum of fgrssprem is giving me 0.00 as my result.

I would be greatful if you could put me through.

Thanks

fieYou need to write a query in the Back end and design the report using that query which you should store it as Stored Procedure. What is the Database you are using?

Designing category system

Hi,

I am trying to design tables for managing category system.

In my inventory management system, I have a receive form, where I have to enter a product from a subcategory of a category.

I can't figuire out how should i design my tables. Am I correct with these tables -

Products Table - ProdID, ProdName, CatID, SCatID
Category Table - CatID, CatName
SubCategory Table - SCatID, SCatName

I can't show only the subCategories associated with a Category. What will be the design?

Also in the Receive form, which one will be logical? Should I select a category first, and related subCategories appears, and then product list form that subcategory appear?

Or should I select the product first, then categories and subCategories should appear?

Thanx a lot in advance for your help.

Regards
Kapalic

It depends how your hierarchy is,
suppose if your hierarchy follows ,

Category
|- Sub-Category
|- Product


Then you can go for following design,

Category -> CatId, CatName, ParentCatId
Where
CatId Primary key
ParentCatId foreign Key of CatId

(if ParentCatid is null then Category otherwise Sub Category)

Product -> ProductId, CatId
Where
CatId is Foregitn key of Category(CatId)

Regarding selection,
Product -> Sub-Category is ONE ON ONE relation
Sub-Cateogry -> Category is ONE ON ONE Relation

But,
Category -> Sub-Category is ONE To MANY relation
Sub-Cateogry -> Product is ONE ON MANY relation

Again its depends how your business rules defines.

|||

Hi ManiD,

Thnx for your reply! I will use the table structure u provided. This is much more logical.

And regarding to choosing fields, i do not have any binding other than existance of category and subcategory id. I just want an expert openion on which approach will be better for the users and developers perspective.

Regards
Kapalic

Designing calendar databases

Is there a best practice/sample database design for creating database applications for scheduling events?

I am looking at creating an online work schedule using the .net calendar control tied back to a SQL Server database (think Outlook Calendar). I am at a loss as to how to efficiently design the database. Will I need to create an entry for every day? Is it prudent to use a datetime value for a primary key (I would have to whack the time portion)? How does one handle the number of days in a month/year?

Anyhoo... I would greatly appreciate any ideas/resources on how to design a database of this type.

Thanks in advance.I can't see any reason to have an entry for every day. Why have an entry if no events are scheduled for a certain day? Just store the events in an event table with a date as one of the columns.|||I am also, have you had any luck?|||You probably have a solution to this, but I was tasked with creating a calendar to schedule meeting rooms as one of my first projects for my current employer.

My table calendar has the following design.

CalendarID, int, autoinc
calendarDateTime, datetime
Appointment, varchar, 50
Reservedby, varchar, 50
Duration, varchar, 50
Freetime, varchar, 50
RoomValues, varchar, 50
AppointmentTime, varchar, 50

Each appointment is it's own row. The asp.net pages check to see if a appointment exists at the time the user selects, if not, it checks the duration which is in 1/2 hour increments if there is an overlap it won't enter the appointment. Otherwise if the time is free it inserts the record. I then query all the appointments for the day and build a table to display the information in a graphical way, Green background for free time, and yellow for occupied. I only display from 8:00AM to 5:00PM on the webpage, but allow scheduling to be anytime.

I hope this helps. BTW, it has been working like a charm since the first week I started here back in March.

Greg

Designing application using access 2000

I desperately need help. I am new to database design and I am using John viescas book Building microsoft access applications. Idon't know where or how to implement the codes in order to create an application.

The book does not give practical examples as to how to actually design the individual function of the database. Any ideas will be greatly welcomed as I am getting quite frustrated just reading meaningless text.

Hi,

this is no Acess group the "SQL Server Data Access" title mean Data Access to SQL Server. I think you are better occupied posting in a Access group like the one which can be found on the public Microsoft newsservers.

HTH, jens Suessmeyer.

http://www.sqlserver2005.de|||if you want to do database design with sql server. BOL or books online which ships with the product is a good place to start.

Designing Aggregations

I have a fairly large partition (100M rows, 30 measures) and am attempting to create aggregations through the Aggregation Design Wizard. Regardless of the option I select, either percent or file size, the wizard always completes after designing only about 50 aggregtions for 0% and only 200kb. I cannot believe that to be right. On a much smaller partition I created about 600 aggregations to 30% for 2GB.

I've double checked to ensure I have all of my dimension attribute relationships defined.

Any ideas why I cannot get the large partition to build the aggregations or why it completes after building about 50? I have plenty of disk space and and cube processing time is not an issue, so I would like to create up to 25-30GB of aggregations.

Thanks

Have you established your attribute relationships?

WIthout them the system does not know that natural hierarchies may be available and by default it only creates aggregations along natural hierarchies.

_-_-_ Dave

|||

Thanks Dave, but I have established the attribute relationships. What confuses me is that the wizard shows that it will create about 250 aggregations, 0%, 125kb. I use the option to manually stop the aggregation design (but never do. I let if finish on its own) and it always comes out roughly the same.

When I process the partition I can see that the aggregations are being created. When I look in the file system I see a bunch of .tmp files being created (e.g. AggMerge_5800_54_8s64d_28.tmp), all of them for about 1.5GB. I eventually run out of space on the drive and the processing fails.

All together these .tmp files take about 150GB. The source database is only about 200GB.

Any thoughts? Ideas? The aggregation design wizard tells me the aggregations will take up about 125kb, but the .tmp files tell me something different.

Designing a database within a database... design question storing data...

I have a system that basically stores a database within a database (I'm
sure lots have you have done this before in some form or another).

At the end of the day, I'm storing the actual data generically in a
column of type nvarchar(4000), but I want to add support for unlimited
text. I want to do this in a smart fashion. Right now I am leaning
towards putting 2 nullable Value fields:

ValueLong ntext nullable
ValueShort nvarchar(4000) nullable

and dynamically storing the info in one or the other depending on the
size. ASP.NET does this exact very thing in it's Session State model;
look at the ASPStateTempSessions table. This table has both a
SessionItemShort of type varbinary (7000) and a SessionItemLong of type
Image.

My question is, is it better to user varbinary (7000) and Image? I'm
thinking maybe I should go down this path, simply because ASP.NET does,
but I don't really know why. Does anyone know what would be the benifit
of using varbinary and Image datatypes? If it's just to allow saving of
binary data, then I don't really need that right now (and I don't think
ASP.NET does either). Are there any other reasons?

thanks,
dave>I have a system that basically stores a database within a database (I'm
> sure lots have you have done this before in some form or another).

Please explain. What form is the data you are storing? If it isn't
represented relationally then why use SQL Server?

--
David Portas
SQL Server MVP
--|||Dave (chakachimp@.yahoo.com) writes:
> My question is, is it better to user varbinary (7000) and Image? I'm
> thinking maybe I should go down this path, simply because ASP.NET does,
> but I don't really know why. Does anyone know what would be the benifit
> of using varbinary and Image datatypes? If it's just to allow saving of
> binary data, then I don't really need that right now (and I don't think
> ASP.NET does either). Are there any other reasons?

Depends on the data you are storing. Since you talk about a "database with
a database", my initial reaction was you would use image, since I assumed
that the database is a binary file, complete with indexes, integer numbers,
and whatever.

But if the "database" is represented in text, for instance an XML document,
then there is no reason to use binary datatypes.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||I'm sorry, I need to elaborate. When I say database within a database,
I don't meen storing the actual database in a binary column or storing
XML in a column, instead I mean defining the structure of data within a
set of tables.

Instead of a concrete table such as Member with 3 columns: MemberID
int, FirstName varchar(25), LastName varchar(25), it is defined as an
abstract table that's defined across a series of tables. One row of any
of my abstract table actually lives (potentially) in several rows of a
sort of "Value" table. This "Value" table contains one column
(Varchar(4000)) that actually stores the value of the data item.

In our system we have over 15 abstract objects (Member being one of
them), so I know people will begin to question the architecture, but
that is not my point here... We do this for many reasons

1) We must store history on all changes (we write medical software)
2) We must encrypt the data and this allows a generic way to do this
(just flip a bit)
3) Our application will soon allow it's users to create user-defined
table and this is set up perfectly for that since it would only require
DML to achieve this (not DDL)
4) Speed isn't that important, right now our product has 10 users max.
Even if it became an issue we could solve this easily...

thanks,
dave|||Dave (chakachimp@.yahoo.com) writes:
> I'm sorry, I need to elaborate. When I say database within a database,
> I don't meen storing the actual database in a binary column or storing
> XML in a column, instead I mean defining the structure of data within a
> set of tables.
> Instead of a concrete table such as Member with 3 columns: MemberID
> int, FirstName varchar(25), LastName varchar(25), it is defined as an
> abstract table that's defined across a series of tables. One row of any
> of my abstract table actually lives (potentially) in several rows of a
> sort of "Value" table. This "Value" table contains one column
> (Varchar(4000)) that actually stores the value of the data item.
> In our system we have over 15 abstract objects (Member being one of
> them), so I know people will begin to question the architecture, but
> that is not my point here... We do this for many reasons
> 1) We must store history on all changes (we write medical software)
> 2) We must encrypt the data and this allows a generic way to do this
> (just flip a bit)
> 3) Our application will soon allow it's users to create user-defined
> table and this is set up perfectly for that since it would only require
> DML to achieve this (not DDL)
> 4) Speed isn't that important, right now our product has 10 users max.
> Even if it became an issue we could solve this easily...

Thanks for the elaboration, but I am not sure that this really provided
any more actual useful information to answer the question. "The database
within in a database", is thuse some sort of object that cannot be described
in a single table - nothing strange with that Order + OrderDetails is a
classic example.

But if I remove the veil about databases within database, and just take
the core question of yours: what datatype should use to save text data,
the answer is (n)varchar or (n)text, depening on your need to support
Unicode and the size limits of the data.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||Let me completely rephrase my approach...

If you've ever installed the sql data model for ASP.NET that resides in
sql server, you'll notice that Microsoft has a table called
ASPStateTempSessions. There are two columns that hold the encrypted
session data of the user. These two columns are:

varbinary(7000)
Image

and they are each nullable. Depending on the size of the Session data,
one or the other column is used since Blob columns (such as Image,
Text, etc...) are inefficient. Using the Session in ASP.NET you'll
notice that it consists of strings only, so why did Microsoft decide to
use these types? Is there some effieciency thing? Or were they planning
on simply supporting possible binary data in the future.

-dave|||Dave (chakachimp@.yahoo.com) writes:
> If you've ever installed the sql data model for ASP.NET that resides in
> sql server, you'll notice that Microsoft has a table called
> ASPStateTempSessions. There are two columns that hold the encrypted
> session data of the user. These two columns are:
> varbinary(7000)
> Image
> and they are each nullable. Depending on the size of the Session data,
> one or the other column is used since Blob columns (such as Image,
> Text, etc...) are inefficient. Using the Session in ASP.NET you'll
> notice that it consists of strings only, so why did Microsoft decide to
> use these types? Is there some effieciency thing? Or were they planning
> on simply supporting possible binary data in the future.

Sorry, I have zero knowledge about ASP .Net, so I cannot answer any
question about its design.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||Been Working on the AspState database, some information indicates that
the transfer of the string data is being done as a binary stream for
efficiency, thus requiring a binary db datatype to store it.

*** Sent via Developersdex http://www.developersdex.com ***

Design: multiple columns for primary key

Hi,
A very basic question:
Imagine I have a table with multiple fields, some strings, some integers
etc.
None of these fields are unique on their own, but all fields together is
unique per record and thus can be used as the primary key.
However, referring to a record based on all these columns is quite
cumbersome (and not efficient, or does indexing take care of this nearly
entirely compared to a single identity field?), so how is this situation
best solved in practice.
Do I use an ugly IDENTITY column just for 'convenience' or continue to use
all fields, resulting in huge queries that lose legibility, or is there
another way?
LisaLisa Pearlson wrote:

> Do I use an ugly IDENTITY column just for 'convenience' or continue
> to use all fields, resulting in huge queries that lose legibility, or
> is there another way?
I would use "an ugle IDENTITY column" without doubt! Maybe others have
different opinions. It'll make your life a less easier. Otherwise if
you want to refer to that row in a foreign key you need to include all
the columns of the key which isn't really doable.
Kind regards,
Stijn Verrept.|||Lisa Pearlson (no@.spam.plz) writes:
> A very basic question:
> Imagine I have a table with multiple fields, some strings, some integers
> etc.
> None of these fields are unique on their own, but all fields together is
> unique per record and thus can be used as the primary key.
> However, referring to a record based on all these columns is quite
> cumbersome (and not efficient, or does indexing take care of this nearly
> entirely compared to a single identity field?), so how is this situation
> best solved in practice.
> Do I use an ugly IDENTITY column just for 'convenience' or continue to use
> all fields, resulting in huge queries that lose legibility, or is there
> another way?
It doesn't have to be IDENTITY, you can roll your own as well. But judging
from the shallow description you give, it appears that this could be a
solution. But you should add UNIQUE constraint on the other columns as well
to ensure their uniqueness.
I like to point out that adding a surrogate key does not always make things
simpler. I had a table with a four-column key, and then I needed to add a
sub-table with two more keys. Since a six-column key sounded too much, I
added a surrogate key to the main table. Years later I had reason to
write code to maintain these tables. Turned out that the surrogate key
made this a whole lot more complex. So the next time I had revise those
tables, I removed the surrogate key. (I was also able to remove one the
columns in the four-column key, and one of the keys in the sub-table.)
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx|||Using the terms "field" and "record" will bring down the wrath of Celko!
I use IDENTITY for a number of reasons, and none of them are for
convenience:
(1) An IDENTITY value is immutable.
(2) Cascading updates are not required to maintain integrity.
(3) IDENTITY reduces redundancy.
(4) Joins generally perform better on IDENTITY values.
(5) IDENTITY reduces lock contention.
There are other reasons, and I could expound further on the merits of each
of the above.
It is not unusual in a logical database design to have tables with compound
primary keys; however, when it comes time to implement the design,
surrogates--including IDENTITY--make a lot more sense.
One more thing: if you do use an IDENTITY PRIMARY KEY, be sure to create a
UNIQUE constraint or index on the combination of columns that are together
unique per row. Alternate keys should be enforced by the database with a
UNIQUE constraint.
"Lisa Pearlson" <no@.spam.plz> wrote in message
news:%23hOXsSz9FHA.3928@.TK2MSFTNGP11.phx.gbl...
> Hi,
> A very basic question:
> Imagine I have a table with multiple fields, some strings, some integers
> etc.
> None of these fields are unique on their own, but all fields together is
> unique per record and thus can be used as the primary key.
> However, referring to a record based on all these columns is quite
> cumbersome (and not efficient, or does indexing take care of this nearly
> entirely compared to a single identity field?), so how is this situation
> best solved in practice.
> Do I use an ugly IDENTITY column just for 'convenience' or continue to use
> all fields, resulting in huge queries that lose legibility, or is there
> another way?
> Lisa
>|||I understand 3, 4 and take 5 for granted (some internal DBMS matter I
presume), but could you elaborate a bit on 1 and 2?
1) immutable means you can't do UPDATE MyTable SET identcol=123 WHERE
identcol=456 ?
2) What does cascading have to do with it? (as I understand cascading, it's
like triggers where change in one record triggers changes in other
tables/records?)
"Brian Selzer" <brian@.selzer-software.com> wrote in message
news:OIHDWpz9FHA.3168@.TK2MSFTNGP10.phx.gbl...
> Using the terms "field" and "record" will bring down the wrath of Celko!
> I use IDENTITY for a number of reasons, and none of them are for
> convenience:
> (1) An IDENTITY value is immutable.
> (2) Cascading updates are not required to maintain integrity.
> (3) IDENTITY reduces redundancy.
> (4) Joins generally perform better on IDENTITY values.
> (5) IDENTITY reduces lock contention.
> There are other reasons, and I could expound further on the merits of each
> of the above.
> It is not unusual in a logical database design to have tables with
> compound primary keys; however, when it comes time to implement the
> design, surrogates--including IDENTITY--make a lot more sense.
> One more thing: if you do use an IDENTITY PRIMARY KEY, be sure to create a
> UNIQUE constraint or index on the combination of columns that are together
> unique per row. Alternate keys should be enforced by the database with a
> UNIQUE constraint.
>
> "Lisa Pearlson" <no@.spam.plz> wrote in message
> news:%23hOXsSz9FHA.3928@.TK2MSFTNGP11.phx.gbl...
>|||Lisa Pearlson (no@.spam.plz) writes:
> I understand 3, 4 and take 5 for granted (some internal DBMS matter I
> presume), but could you elaborate a bit on 1 and 2?
> 1) immutable means you can't do UPDATE MyTable SET identcol=123 WHERE
> identcol=456 ?
> 2) What does cascading have to do with it? (as I understand cascading,
> it's like triggers where change in one record triggers changes in other
> tables/records?)
Actually, I think of the reasons that Brian listed, only 5 is really
applicable to IDENTITY columns, although 1 has a touch to it: if you
have an IDENTITY property on the key, you know that the value cannot
be updated, not even by mistake.
Points 2-4 applies to surrogate keys in general, no matter if they have
IDENTITY or not.
I guess what Brian means with cascading is that if you use entirely
natural keys these can change. Say that you get the idea to use the
stock symbol as the key for financial instruments. Then the company changes
the name, and gets a new symbol. With the symbol as key, you have to update
all tables where the symbol appears. With a surrogate key, there is no
need to.
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx|||Immutable primary keys yield many benefits.
A mutable primary key will make your code less stable. It's possible in a
concurrent environment to read a row with a particular primary key value and
while you're working on it for another transaction or transactions to make
changes so that when you initiate your update, it appears that the row no
longer exists, or even worse, that the row exists even though it's really
another row. Here's a simple example: Assume that you're tracking a part
as it moves from machine to machine on an assembly line. Assume also that
only one part can be manipulated by one machine at one time. The mutable
primary key is this example is {PartNo, Location}. Now, you read the row
with key {'45G', 'PRESS01'} prior to some manipulation. While you're
working on the row, the part is moved from 'PRESS01' to 'FORMER01', so it
now appears to you that the row no longer exists. If another part '45G' is
moved onto 'PRESS01' prior to your update, then it will appear to you that
the row still exists even though it's a different part, and you may
erroneously update the row for the wrong part. To counter this, you must
either lock and hold the row when you read it (not a very attractive
prospect because it will severely reduce concurrency and will preclude the
use of disconnected datasets, message queues, etc.), or write a ton of code
on the client end to detect the change--which may not always be possible or
practical. Note that this problem increases in complexity when there are
related tables, because it's possible for a row to look the same on the
primary key table, but to actually refer to a different row with a different
set of related rows. With an IDENTITY primary key, as each part is placed
in production a new row is added and a new IDENTITY value is generated.
Because that value cannot change, when you go to perform your update, you
can determine not only that the part has moved, but exactly where it is now.
In addition, the problem with related tables cannot occur, because the
related rows refer to a value that cannot change.
Another problem lies with UPDATE triggers that are used for auditing or to
implement transition constraints. SQL Server update triggers have two
pseudotables, deleted and inserted, which contain the old and new values for
each row that was updated. When an update affects more than one row, there
is no supported mechanism to determine which row in the inserted pseudotable
corresponds to each row in the deleted pseudotable. (Oracle has a FOR EACH
ROW trigger, which I've been begging Microsoft to implement.) IDENTITY
solves this problem because since the key cannot change, you can join the
deleted and inseted pseudotables on the IDENTITY column and determine
exactly what happened to each row.
Cascading updates cause more problems than they're worth.
The most common form of avoidable deadlock is caused by multiple
transactions obtaining and holding locks on rows in more than one table in a
different order. To combat this, you must make sure that you obtain locks
on tables in the same order in every procedure, function, trigger, and
batch. Cascading updates throw a wrench into this. There is no way to
determine with any degree of certainty the order in which related rows will
be locked when there is a cascading heirarchy present. This makes it much
more difficult--if not impossible--to determine a locking order that will
eliminate avoidable deadlocks.
Another problem with cascading updates is that whenever a change is made,
the rowversion (timestamp) on each affected row is updated. Do you really
want to indicate that a Sales Order has been changed when only the
salesperson's employee number has been changed? It makes sense to indicate
a change when the Sales Order is assigned to another salesperson, but in
this case the change is cosmetic, not material, and in my opinion should not
occur.
This brings up another problem: triggers on every affected table throughout
the cascading heirarchy also fire. It's much more difficult to determine
whether they fired for simply a cosmetic change, or if there is a material
change that should be validated against business rules.
All of these problems occur because a database that uses natural primary
keys is riddled with redundancy. For this reason among others, I advocate
the use of surrogate keys and in particular, IDENTITY at the physical level.
"Lisa Pearlson" <no@.spam.plz> wrote in message
news:%23nPAi%2309FHA.3884@.TK2MSFTNGP10.phx.gbl...
>I understand 3, 4 and take 5 for granted (some internal DBMS matter I
>presume), but could you elaborate a bit on 1 and 2?
> 1) immutable means you can't do UPDATE MyTable SET identcol=123 WHERE
> identcol=456 ?
> 2) What does cascading have to do with it? (as I understand cascading,
> it's like triggers where change in one record triggers changes in other
> tables/records?)
> "Brian Selzer" <brian@.selzer-software.com> wrote in message
> news:OIHDWpz9FHA.3168@.TK2MSFTNGP10.phx.gbl...
>|||>> Let's get back to the basics of an RDBMS. Rows are not records; fields ar
e not columns; tables are not files.
If (a,b,c) is a key in the data model, then you have to make it a key
in the schema. Well, you want things screwed.
Ignoring that BY DEFINITION, the proprietary IDENTITY is not a data
type, not a relational and not verifiable, it is redundant in the face
of a real key.
How do you guarantee that you have the IDENTITY and the real key in
synch? Most "ID-iots" do not bother with a real key (they mimic a
sequential file and pointer chains instead) and get redundant rows when
someone posts the same data multiple times.
Answer: it is impossible and therefore data integrity is impossible. I
am just starting to do some SOX consulting work; I will flunk your
database for this. There was some discussion of this at CA a few ws
ago.
A good RDBMS will handle the access for you, so that you do not have to
drop down to that level.|||--CELKO-- (jcelko212@.earthlink.net) writes:
> Ignoring that BY DEFINITION, the proprietary IDENTITY is not a data
> type, not a relational and not verifiable, it is redundant in the face
> of a real key.
New readers should note that this is Joe Celko's private definition, and
thus nothing to bother about.
I could say that by definition Joe Celko is always wrong, but that would
not be a very strong argument. A much stronger argument is that far too many
of his posts consists of inaccurate standard rants, and where the main
rationale for the post is to insult the person who asked.

> How do you guarantee that you have the IDENTITY and the real key in
> synch?
In Lisa's case, it appears to be simple: she should have a UNIQUE
cosntraints on the real key. However, there are plentyful of cases where
there is no real key, or where any "real key" is far beyond being
practically usable.
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx|||So, DB2, Oracle, Sybase and Microsoft SQL Server are not 'good RDBMS'? Seems
the market disagrees.
The whole point about using a surrogate key with the IDENTITY property is so
that you gain better performance, reduce complexity for backups, security
etc... as well as being able to change your natural key without having to
build a horrendous transaction of multiple update statements that will lock
up your tables while its being done - usually people cluster on the primary
key (natural key).
People only get redundant rows if they forget to add constraints to their
table, the surrogate key definition would be,..
create table individual (
id int not null identity constraint sk_individual unique
clustered,
last_name varchar(50) not null,
first_name varchar(50) not null,
dob int not null,
constraint pk_individual primary key nonclustered( last_name,
first_name, dob )
)
Mind you, we both know that the natural key on individual isn't the above,
in fact their isn't an easy one - consider a user group like my own, do you
want me to ask people for the NI (social security) number ? I wouldn't get
many members, I'd probably not even get my registration under the Data
Protection act here in the UK passed either.
Well fud - go out and get some bloody experience on real systems please!
Tony Rogerson
SQL Server MVP
http://sqlserverfaq.com - free video tutorials
"--CELKO--" <jcelko212@.earthlink.net> wrote in message
news:1133661996.695550.257580@.o13g2000cwo.googlegroups.com...
> If (a,b,c) is a key in the data model, then you have to make it a key
> in the schema. Well, you want things screwed.
> Ignoring that BY DEFINITION, the proprietary IDENTITY is not a data
> type, not a relational and not verifiable, it is redundant in the face
> of a real key.
> How do you guarantee that you have the IDENTITY and the real key in
> synch? Most "ID-iots" do not bother with a real key (they mimic a
> sequential file and pointer chains instead) and get redundant rows when
> someone posts the same data multiple times.
> Answer: it is impossible and therefore data integrity is impossible. I
> am just starting to do some SOX consulting work; I will flunk your
> database for this. There was some discussion of this at CA a few ws
> ago.
> A good RDBMS will handle the access for you, so that you do not have to
> drop down to that level.
>

Design: bit on or off?

I'm asking lots of design questions here.. but they are little ones,
sometimes matter of taste, sometimes more than that.
Imagine I have a table of "Keys". Some of these keys will be "active" and
some will be "blocked".
I'm trying to decide whether I should use a BIT column and call this
"active" or "blocked".
So should bit 1 mean "active" or mean "blocked" ? There will almost
certainly be more active than blocked keys. Which one is more intuitive or
likely convenient in practice?
Of course I could use a set "yes/no" or "active/disabled" but for only 2
possibilities, a bit seems more efficient and convenient in front en back
end. What are your recommendations/tastes?
LisaHi, Lisa
If you use a bit column, 1 should represent true and 0 should represent
false. So, if the column name is "active", 1 means that the key is
active, 0 means that it's blocked.
However, you should consider using a char(1) column with a constraint
like "Status IN ('A','B')", because it is possible that sometime in the
future you may want another status value, for example "pending". If you
use a codification on a char(1), make sure that it's meaning is well
documented (for example in the Description of the column, if you use
Enterprise Manager).
Razvan|||If "active" basically means "enabled" or "on" or "true", then use 1 and 0
for "blocked".
"Lisa Pearlson" <no@.spam.plz> wrote in message
news:u5kVzK09FHA.4004@.TK2MSFTNGP14.phx.gbl...
> I'm asking lots of design questions here.. but they are little ones,
> sometimes matter of taste, sometimes more than that.
> Imagine I have a table of "Keys". Some of these keys will be "active" and
> some will be "blocked".
> I'm trying to decide whether I should use a BIT column and call this
> "active" or "blocked".
> So should bit 1 mean "active" or mean "blocked" ? There will almost
> certainly be more active than blocked keys. Which one is more intuitive or
> likely convenient in practice?
> Of course I could use a set "yes/no" or "active/disabled" but for only 2
> possibilities, a bit seems more efficient and convenient in front en back
> end. What are your recommendations/tastes?
> Lisa
>|||Lisa Pearlson wrote:
> I'm asking lots of design questions here.. but they are little ones,
> sometimes matter of taste, sometimes more than that.
> Imagine I have a table of "Keys". Some of these keys will be "active" and
> some will be "blocked".
> I'm trying to decide whether I should use a BIT column and call this
> "active" or "blocked".
> So should bit 1 mean "active" or mean "blocked" ? There will almost
> certainly be more active than blocked keys. Which one is more intuitive or
> likely convenient in practice?
> Of course I could use a set "yes/no" or "active/disabled" but for only 2
> possibilities, a bit seems more efficient and convenient in front en back
> end. What are your recommendations/tastes?
> Lisa
I'd prefer to use a CHAR or maybe an INT status code. That way, you can
add more statuses if you need to, you can use a meaningful readable
code that everyone can understand and you avoid some of the peculiar
quirks of the BIT type (for example some numeric operators are valid
for BIT and others aren't).
David Portas
SQL Server MVP
--

Design/Modeling books and or advise wanted.

I posted this question long ago to several groups but it didn't generate a
lot of interest so I thought I would try again.
I have been looking for books on database design and or modeling but can't
determine which method or approach would best suite my needs.
I guess this comes from the fact that I'm not sure what the difference is in
the different types of modeling and or design approaches, or for that matter
what possible methods are available. ER, UML ORM....are there others? Are
these different ways to model? Are there other methods? Why should I choose
one over the other?
I mean I'm just the db guy truing to design the best database for our
application. If you can also point out any good books to build up on your
suggestions it would be helpful.
Thanks,
CharlieThere are a couple of suggestions here
http://vyaskn.tripod.com/sqlbooks.htm#rdbms
I personally enjoyed Louis Davidson's "Professionsal SQL Server 2000
Database Design"
Recommendations from "Inside Microsoft SQL Server 2000" by Kalen Delaney:
(from post by B.P.Margolin)
An Introduction to Database Systems, 7th Edition, by C. J. Date
(Addison-Wesley, 1999). A new revision of a classic book, written by a giant
in the field, that covers general relational database concepts. A must-read
for everyone in the database industry.
Database Design for Mere Mortals by Michael J. Hernandez (Addison-Wesley,
1997). A very readable approach to the daunting task of designing a
relational database to solve real-world problems. The book is written in a
database-independent format, so the details can be applied to SQL Server as
well as to other RDMSs you might use.
Handbook of Relational Database Design by Candace C. Fleming and Barbara
Vonhalle (Addison-Wesley, 1988). A fine book that discusses general logical
database design and data modeling approaches and techniques.
SAMS Teach Yourself Microsoft SQL Server 2000 in 21 Days by Richard Waymire
and Rick Sawtell (SAMS Publishing, 2000). A good first book on SQL Server
2000 in tutorial format that gets readers up to speed quickly. One of the
coauthors is a program manager on the SQL Server development team. This
title includes self-test questions for each of the 21 "days."
Database: Principles, Programming, Performance by Patrick O'Neil (Morgan
Kaufmann Publishers, 1994). This thorough textbook provides excellent
introductory materials, so I've placed it high on the list. It also
carefully details a broad spectrum of database topics, including buffer
management and transaction semantics.
--
Allan Mitchell (Microsoft SQL Server MVP)
MCSE,MCDBA
www.SQLDTS.com
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org
"Charlie" <cdeaton@.corp.realcomp.com> wrote in message
news:%23$EQz$4hDHA.2296@.TK2MSFTNGP09.phx.gbl...
> I posted this question long ago to several groups but it didn't generate a
> lot of interest so I thought I would try again.
> I have been looking for books on database design and or modeling but can't
> determine which method or approach would best suite my needs.
> I guess this comes from the fact that I'm not sure what the difference is
in
> the different types of modeling and or design approaches, or for that
matter
> what possible methods are available. ER, UML ORM....are there others? Are
> these different ways to model? Are there other methods? Why should I
choose
> one over the other?
> I mean I'm just the db guy truing to design the best database for our
> application. If you can also point out any good books to build up on your
> suggestions it would be helpful.
> Thanks,
> Charlie
>|||Thanks Allen,
Can anyone else comment on approaches to design (ER,UML,ORM').
"Allan Mitchell" <allan@.no-spam.sqldts.com> wrote in message
news:eDIf6m%23hDHA.2512@.TK2MSFTNGP09.phx.gbl...
> There are a couple of suggestions here
> http://vyaskn.tripod.com/sqlbooks.htm#rdbms
> I personally enjoyed Louis Davidson's "Professionsal SQL Server 2000
> Database Design"
> Recommendations from "Inside Microsoft SQL Server 2000" by Kalen Delaney:
> (from post by B.P.Margolin)
> An Introduction to Database Systems, 7th Edition, by C. J. Date
> (Addison-Wesley, 1999). A new revision of a classic book, written by a
giant
> in the field, that covers general relational database concepts. A
must-read
> for everyone in the database industry.
> Database Design for Mere Mortals by Michael J. Hernandez (Addison-Wesley,
> 1997). A very readable approach to the daunting task of designing a
> relational database to solve real-world problems. The book is written in a
> database-independent format, so the details can be applied to SQL Server
as
> well as to other RDMSs you might use.
> Handbook of Relational Database Design by Candace C. Fleming and Barbara
> Vonhalle (Addison-Wesley, 1988). A fine book that discusses general
logical
> database design and data modeling approaches and techniques.
> SAMS Teach Yourself Microsoft SQL Server 2000 in 21 Days by Richard
Waymire
> and Rick Sawtell (SAMS Publishing, 2000). A good first book on SQL Server
> 2000 in tutorial format that gets readers up to speed quickly. One of the
> coauthors is a program manager on the SQL Server development team. This
> title includes self-test questions for each of the 21 "days."
> Database: Principles, Programming, Performance by Patrick O'Neil (Morgan
> Kaufmann Publishers, 1994). This thorough textbook provides excellent
> introductory materials, so I've placed it high on the list. It also
> carefully details a broad spectrum of database topics, including buffer
> management and transaction semantics.
>
> --
> --
> Allan Mitchell (Microsoft SQL Server MVP)
> MCSE,MCDBA
> www.SQLDTS.com
> I support PASS - the definitive, global community
> for SQL Server professionals - http://www.sqlpass.org
> "Charlie" <cdeaton@.corp.realcomp.com> wrote in message
> news:%23$EQz$4hDHA.2296@.TK2MSFTNGP09.phx.gbl...
> > I posted this question long ago to several groups but it didn't generate
a
> > lot of interest so I thought I would try again.
> >
> > I have been looking for books on database design and or modeling but
can't
> > determine which method or approach would best suite my needs.
> >
> > I guess this comes from the fact that I'm not sure what the difference
is
> in
> > the different types of modeling and or design approaches, or for that
> matter
> > what possible methods are available. ER, UML ORM....are there others?
Are
> > these different ways to model? Are there other methods? Why should I
> choose
> > one over the other?
> >
> > I mean I'm just the db guy truing to design the best database for our
> > application. If you can also point out any good books to build up on
your
> > suggestions it would be helpful.
> >
> > Thanks,
> > Charlie
> >
> >
>|||UML is for designing software and will produce code that doesn't fit well to
a relational database design. Unfortunately that's just the nature of OOP,
and unless you want to use an object oriented database, you just need to
deal with translating the data into your software.
ER and ORM I consider to be complementary techiques. I prefer designing in
ORM and looking at other people's design as ER diagrams. I find that ORM
gives me more insight into my goals for storing the data, while ER requires
me to focus too much on the actual layout of the data, sometimes losing
sight of the goals for storing it in the first place. Fortunately it's
possible to go back and forth between ER and ORM (at least with Visio, and
if it did a better job of syncing to the database you could even add the
implementation to the mix). I initially learned ORM by going back and forth
between ER and ORM design, until I was comfortable enough with ORM to drop
ER from the initial design process.
I'd also just like to mention that "Handbook of Relational Database" was the
very first book I ever read on database design (that was when I showed up on
my first day of my university work term with no database experience -- not
even DB-III -- to find a FoxPro box on my desk and a request to "build us an
inventory management system"). I still consider it the most useful book I've
ever read on relational databases.
Colin
"Charles Deaton" <mssql@.mssql.com> wrote in message
news:%23PyUhsBiDHA.2296@.TK2MSFTNGP09.phx.gbl...
> Thanks Allen,
> Can anyone else comment on approaches to design (ER,UML,ORM').
> "Allan Mitchell" <allan@.no-spam.sqldts.com> wrote in message
> news:eDIf6m%23hDHA.2512@.TK2MSFTNGP09.phx.gbl...
> > There are a couple of suggestions here
> >
> > http://vyaskn.tripod.com/sqlbooks.htm#rdbms
> >
> > I personally enjoyed Louis Davidson's "Professionsal SQL Server 2000
> > Database Design"
> >
> > Recommendations from "Inside Microsoft SQL Server 2000" by Kalen
Delaney:
> > (from post by B.P.Margolin)
> >
> > An Introduction to Database Systems, 7th Edition, by C. J. Date
> > (Addison-Wesley, 1999). A new revision of a classic book, written by a
> giant
> > in the field, that covers general relational database concepts. A
> must-read
> > for everyone in the database industry.
> >
> > Database Design for Mere Mortals by Michael J. Hernandez
(Addison-Wesley,
> > 1997). A very readable approach to the daunting task of designing a
> > relational database to solve real-world problems. The book is written in
a
> > database-independent format, so the details can be applied to SQL Server
> as
> > well as to other RDMSs you might use.
> >
> > Handbook of Relational Database Design by Candace C. Fleming and Barbara
> > Vonhalle (Addison-Wesley, 1988). A fine book that discusses general
> logical
> > database design and data modeling approaches and techniques.
> >
> > SAMS Teach Yourself Microsoft SQL Server 2000 in 21 Days by Richard
> Waymire
> > and Rick Sawtell (SAMS Publishing, 2000). A good first book on SQL
Server
> > 2000 in tutorial format that gets readers up to speed quickly. One of
the
> > coauthors is a program manager on the SQL Server development team. This
> > title includes self-test questions for each of the 21 "days."
> >
> > Database: Principles, Programming, Performance by Patrick O'Neil (Morgan
> > Kaufmann Publishers, 1994). This thorough textbook provides excellent
> > introductory materials, so I've placed it high on the list. It also
> > carefully details a broad spectrum of database topics, including buffer
> > management and transaction semantics.
> >
> >
> > --
> > --
> >
> > Allan Mitchell (Microsoft SQL Server MVP)
> > MCSE,MCDBA
> > www.SQLDTS.com
> > I support PASS - the definitive, global community
> > for SQL Server professionals - http://www.sqlpass.org
> >
> > "Charlie" <cdeaton@.corp.realcomp.com> wrote in message
> > news:%23$EQz$4hDHA.2296@.TK2MSFTNGP09.phx.gbl...
> > > I posted this question long ago to several groups but it didn't
generate
> a
> > > lot of interest so I thought I would try again.
> > >
> > > I have been looking for books on database design and or modeling but
> can't
> > > determine which method or approach would best suite my needs.
> > >
> > > I guess this comes from the fact that I'm not sure what the difference
> is
> > in
> > > the different types of modeling and or design approaches, or for that
> > matter
> > > what possible methods are available. ER, UML ORM....are there others?
> Are
> > > these different ways to model? Are there other methods? Why should I
> > choose
> > > one over the other?
> > >
> > > I mean I'm just the db guy truing to design the best database for our
> > > application. If you can also point out any good books to build up on
> your
> > > suggestions it would be helpful.
> > >
> > > Thanks,
> > > Charlie
> > >
> > >
> >
> >
>|||You might as well have posted a message asking what is the best
religion ;-)
Your questions are so broad, that there's no way to answer
themsuccinctly. So I'm not surprised your previous posting along the
same lines generated little interest.
I'd do a groups.googlecom search and look for discussions on the
topics that interest you so that you can garner a wide range of
previously-expressed opinions. Amazon.com is a good place to search
for books since they post reviews.
-- Mary
MCW Technologies
http://www.mcwtech.com
On Tue, 30 Sep 2003 16:17:56 -0400, "Charlie"
<cdeaton@.corp.realcomp.com> wrote:
>I posted this question long ago to several groups but it didn't generate a
>lot of interest so I thought I would try again.
>I have been looking for books on database design and or modeling but can't
>determine which method or approach would best suite my needs.
>I guess this comes from the fact that I'm not sure what the difference is in
>the different types of modeling and or design approaches, or for that matter
>what possible methods are available. ER, UML ORM....are there others? Are
>these different ways to model? Are there other methods? Why should I choose
>one over the other?
>I mean I'm just the db guy truing to design the best database for our
>application. If you can also point out any good books to build up on your
>suggestions it would be helpful.
>Thanks,
>Charlie
>

Design/load question

Hi. I am redesigning a database to be more normalized. There are 4 columns that appear in many of the tables that I plan to add to a new table. Here is what the database looks like now:

table1
uniquecolumn1
uniquecolumn2
uniquecolumn3
samecolumn1
samecolumn2
samecolumn3
samecolumn4
uniquecolumn4
etc.

table2
uniquecolumn1
uniquecolumn2
uniquecolumn3
samecolumn1
samecolumn2
samecolumn3
samecolumn4
uniquecolumn4
etc.

table3
uniquecolumn1
uniquecolumn2
uniquecolumn3
samecolumn1
samecolumn2
samecolumn3
samecolumn4
uniquecolumn4
etc.

If I add a 4th table with the columns that are the same in each of the tables, I'd have this:

table1
uniquecolumn1
uniquecolumn2
uniquecolumn3
uniquecolumn4
etc.

table2
uniquecolumn1
uniquecolumn2
uniquecolumn3
uniquecolumn4
etc.

table3
uniquecolumn1
uniquecolumn2
uniquecolumn3
uniquecolumn4
etc.

table4
samecolumn1
samecolumn2
samecolumn3
samecolumn4

To link table4 to the other tables, I'd define foreign keys on table4 that reference the primary keys of tables 1-3. What I'd like to avoid is having a composite key on table4 made up of the primary keys of tables 1-3. That doesn't sound correct. How do I do this? Also when it comes time to load data, I know that I need to populate tables 1-3 first, but how do I then uniquely identify the rows in tables 1-3 that must go into table4? Thanks for the help!

Byron,

Could you please be more specific on the column names for each table?

Steve

|||Steve,

Thanks for the response. Here's what you asked for:

LodgingSummary (table1)
LodgingSummaryID
LoadTransactionCode
AccountNumber
PostingDate
TransactionReferenceNumber
SequenceNumber
NoShowIndicator
CheckInDate
DailyRoomRate
TotalOtherCharges
TotalTaxAmount
TotalFoodBeverageCharges
TotalPrepaidExpenses

CardTransaction (table2)
LoadTransactionCode
AccountNumber
PostingDate
TransactionReferenceNumber
SequenceNumber
Period
AcquiringBIN
CardAcceptorID
SupplierName
SupplierCity
SupplierStateProvinceCode

FleetService (table3)
FleetServiceID
LoadTransactionCode
AccountNumber
PostingDate
TransactionReferenceNumber
SequenceNumber
PurchaseType
FuelType
FuelUnitMeasureCode
FuelQuantity
FuelUnitCost
FuelGrossAmount

AccountInfo (table4)
AccountNumber

PostingDate

TransactionReferenceNumber

SequenceNumber

|||

Byron,


CREATE TABLE AccountInfo
(
AccountNumber (PK)
PostingDate
TransactionReferenceNumber
SequenceNumber
)


CREATE TABLE CardTransaction
(
LoadTransactionCode (PK)
LodgingSummaryID(FK)--allow nulls
FleetServiceID (FK) --allow nulls
Period
AcquiringBIN
CardAcceptorID
SupplierName
SupplierCity
SupplierStateProvinceCode
)

CREATE TABLE LodgingSummary
(
LodgingSummaryID (PK)
AccountNumber
NoShowIndicator
CheckInDate
DailyRoomRate
TotalOtherCharges
TotalTaxAmount
TotalFoodBeverageCharges
TotalPrepaidExpenses
)


CREATE TABLE FleetService
(
FleetServiceID (PK)
PurchaseType
FuelType
FuelUnitMeasureCode
FuelQuantity
FuelUnitCost
FuelGrossAmount
)

|||

CREATE TABLE AccountInfo
(
AccountNumber (PK)
PostingDate
TransactionReferenceNumber
SequenceNumber
)

If you do this, then that person can never use this account again. Better off making a surrogate for this data:

CREATE TABLE AccountInfo
(
AccountInfoId int identity(1,1) primary key, --I don't care about the value of this, it is just a surrogate for:

AccountNumber
PostingDate
TransactionReferenceNumber
SequenceNumber
UNIQUE (accountNumber, PostingDate, TransactionReferenceNumber, SequenceNumber)
)

I find that I am a bit wary of the data here. Is AcctNumber and TransactionRefNumber not unique in and of itself? Same with it and SequenceNumber. Make sure that your alt key(s) really define with is actually unique, and not just a blob like this (unless the same tranNumber and sequenceNumber might be repeated for the same account, but just on different days.

I am rarely happy when a date is part of a key that is not representing an Event of some sort (like if I had a table that recorded when I got gas for my car, it would have a date as the key.) I don't know your data, so I am not sure of course :)

|||Thanks for the response, Louis. I added my responses is blue.

"CREATE TABLE AccountInfo

(
AccountNumber (PK)
PostingDate
TransactionReferenceNumber
SequenceNumber
)

If you do this, then that person can never use this account again. Better off making a surrogate for this data:"

This is correct. There will be multiple transactions for the same account number.

"CREATE TABLE AccountInfo
(
AccountInfoId int identity(1,1) primary key, --I don't care about the value of this, it is just a surrogate for:

AccountNumber
PostingDate
TransactionReferenceNumber
SequenceNumber
UNIQUE (accountNumber, PostingDate, TransactionReferenceNumber, SequenceNumber)
)

I find that I am a bit wary of the data here. Is AcctNumber and

TransactionRefNumber not unique in and of itself? Same with it and

SequenceNumber. Make sure that your alt key(s) really define with is

actually unique, and not just a blob like this (unless the same

tranNumber and sequenceNumber might be repeated for the same account,

but just on different days.

I am rarely happy when a date is part of a key that is not

representing an Event of some sort (like if I had a table that recorded

when I got gas for my car, it would have a date as the key.) I don't

know your data, so I am not sure of course :)"

There are many more tables that could have transactions related to travel, lodging, purchases, etc. These are all in different tables according to the data spec I have to live with. TransactionRefNumber should be unique, but there is no guarantee. When you said:

"UNIQUE (accountNumber, PostingDate, TransactionReferenceNumber, SequenceNumber)"

What is this? Are you creating a unique constraint here? Thanks.|||One more thing, please. Now when I want to load my values into my newly normalized table (LodgingSummary), how do I select each row individually? LodgingSummary will have the primary key of AccountInfo as a foreign key. Let's look at a real table:

Table: LodgingSummary (the newly normalized table)
LodgingSummaryID (PK)
AccountInfoID (FK) <-- This is the primary key of AccountInfo
NoShowIndicator
CheckInDate
DailyRoomRate
TotalOtherCharges
TotalTaxAmount
TotalFoodBeverageCharges
TotalPrepaidExpenses

Table: AccountInfo (the table I'm "normalizing" to)
AccountInfoID (PK)
AccountNumber <--moved from tbl LodgingSummary to tbl AccountInfo
PostingDate <--moved from tbl LodgingSummary to tbl AccountInfo
TransactionReferenceNumber <--moved from tbl LodgingSummary to tbl AccountInfo
SequenceNumber <--moved from tbl LodgingSummary to tbl AccountInfo

After the load, there will be a 1:1 relationship between the rows in the two tables (primary key to foreign key). My datasource for the load is the original de-normalized table:

Table load_LodgingSummary
LodgingSummaryID (PK)
AccountNumber
PostingDate
TransactionReferenceNumber
SequenceNumber
NoShowIndicator
CheckInDate
DailyRoomRate
TotalOtherCharges
TotalTaxAmount
TotalFoodBeverageCharges
TotalPrepaidExpenses

Here's my current code to load the normalized table:

[CODE]
set identity_insert lodgingsummary on
insert into lodgingsummary
(
LodgingSummaryID,
AccountInfoID,
LoadTransactionCode,
NoShowIndicator,
CheckInDate,
DailyRoomRate,
TotalOtherCharges,
TotalTaxAmount,
TotalFoodBeverageCharges,
TotalPrepaidExpenses
)
select
LodgingSummaryID,
(select ai.accountinfoID AccountInfoID from accountinfo ai,
load_LodgingSummary ll
where ai.accountnumber=ll.accountnumber and ai.postingdate=ll.postingdate
and
ai.TransactionReferenceNumber=ll.TransactionReferenceNumber
and ai.sequencenumber=ll.sequencenumber),
LoadTransactionCode,
NoShowIndicator,
CheckInDate,
DailyRoomRate,
TotalOtherCharges,
TotalTaxAmount,
TotalFoodBeverageCharges,
TotalPrepaidExpenses
from load_lodgingsummary
set identity_insert lodgingsummary off
[/CODE]

The subquery in the INSERT will return more than 1 AccountInfoID. Is there any way to write a statement that will load each row individually or do I need to build a recordset and individually insert each row of the recordset?

Design without SSL, publish with SSL

Riddle me this...
Can I design my reports onto a development server that does not have SSL in
the mix and then use the rs utility to publish them to a live server that has
SSL?
Well I did but I had to change \Program Files\Microsoft SQL
Server\MSSQL\Reporting Services\ReportServer\RSReportServer.config
file with the attribute SecureConnectionLevel from 2 to 0 in order to do this.
Otherwise I received an error in the cmd window:
"The operation you are attempting requires a secure connection. (HTTPS)."
So, I can see the reports if I leave the SecureConnectionLevel setting at 0
but not when it is set to 2 (which I want to utilize SSL).Hmm.. setting SecureConnectionLevel to 0 stops rs from requireing SSL
connection at all. You don't want to do this :-).
Regariding rs.exe - you can simply specify in on your command https:// for
the path to report server. The tool should the estabilish an SSL
connection.
-Lukasz
This posting is provided "AS IS" with no warranties, and confers no rights.
"Greg Allan" <GregAllan@.discussions.microsoft.com> wrote in message
news:519624D0-C307-45EF-867A-D2F1DA8ADA78@.microsoft.com...
> Riddle me this...
> Can I design my reports onto a development server that does not have SSL
> in
> the mix and then use the rs utility to publish them to a live server that
> has
> SSL?
> Well I did but I had to change \Program Files\Microsoft SQL
> Server\MSSQL\Reporting Services\ReportServer\RSReportServer.config
> file with the attribute SecureConnectionLevel from 2 to 0 in order to do
> this.
> Otherwise I received an error in the cmd window:
> "The operation you are attempting requires a secure connection. (HTTPS)."
> So, I can see the reports if I leave the SecureConnectionLevel setting at
> 0
> but not when it is set to 2 (which I want to utilize SSL).

Friday, February 24, 2012

Design with the best space allocation.

We are getting ready to setup the gov's death file on a sql server. I would
like thoughts on the table design to optimize space. This is the data spec's
https://dmf.ntis.gov/recordlayout.pdf
The master file doesn't have the first column. So here is where I was headed
for the main table. The column's with asterisk are possibly empty. The
file updates will be done based off SSN column.
CREATE TABLE [dbo].[tblDMFile] (
[SSN] [char] (9) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[LastName] [varchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
*[NameSuffix] [varchar] (4) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[FirstName] [varchar] (15) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
*[MiddleName] [varchar] (15) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
*[StatusCode] [char] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[DeathDate] [smalldatetime] NULL ,
[BirthDate] [smalldatetime] NULL ,
*[ResidentCode] [char] (2) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
*[ZipLastResident] [varchar] (5) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
,
*[ZipLumpSumPaymt] [varchar] (5) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[tblDMFile] WITH NOCHECK ADD
CONSTRAINT [PK_tblDMFile] PRIMARY KEY CLUSTERED
(
[SSN]
) ON [PRIMARY]
GO
CREATE INDEX [IX_tblDMFile] ON [dbo].[tblDMFile]([LastName], [FirstName])
ON [PRIMARY]
GO
TIA
CDMy understanding (could be wrong) is that SSNs of deceased persons are
reused, (or can be resused) so, if that is in fact true, then your use of SS
N
as single column Primary Key might be an issue. If true, you could add
DeathDate as well, (make it non null) I would assume since this is Death
File, every record will have to have a Death Date?
CONSTRAINT [PK_tblDMFile] PRIMARY KEY CLUSTERED
([DeathDate],[SSN]) ON [PRIMARY]
That will handle the issue...
Also, suggest you put DeathDate first in the Index, and make this the
Clustered Index (on DeatHDate, SSN), since this will ensure that new Inserts
will generally be added to new Pages on disk, not randomly distributed
throughout the physical storage... Putting SSN as first column in PK index,
means that records would be physically ordered on SSN, and new inserts will
be distributed among all the physical pages on disk, causing many page split
s
and rapid table and index fragmentation.
"CD" wrote:

> We are getting ready to setup the gov's death file on a sql server. I wou
ld
> like thoughts on the table design to optimize space. This is the data spec
's
> https://dmf.ntis.gov/recordlayout.pdf
> The master file doesn't have the first column. So here is where I was head
ed
> for the main table. The column's with asterisk are possibly empty. The
> file updates will be done based off SSN column.
> CREATE TABLE [dbo].[tblDMFile] (
> [SSN] [char] (9) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
> [LastName] [varchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
> *[NameSuffix] [varchar] (4) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
> [FirstName] [varchar] (15) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
> *[MiddleName] [varchar] (15) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
> *[StatusCode] [char] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
> [DeathDate] [smalldatetime] NULL ,
> [BirthDate] [smalldatetime] NULL ,
> *[ResidentCode] [char] (2) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
> *[ZipLastResident] [varchar] (5) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
> ,
> *[ZipLumpSumPaymt] [varchar] (5) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
> ) ON [PRIMARY]
> GO
> ALTER TABLE [dbo].[tblDMFile] WITH NOCHECK ADD
> CONSTRAINT [PK_tblDMFile] PRIMARY KEY CLUSTERED
> (
> [SSN]
> ) ON [PRIMARY]
> GO
> CREATE INDEX [IX_tblDMFile] ON [dbo].[tblDMFile]([LastName], [FirstName])
> ON [PRIMARY]
> GO
> TIA
> CD
>
>|||Thanks for the reply. That is a good point about SSN resuage(possibly)
1) To clarify the table schema is good for the best Least space usage
2) ALTER TABLE [dbo].[tblDMFile] WITH NOCHECK ADD
CONSTRAINT [PK_tblDMFile] PRIMARY KEY CLUSTERED
([DeathDate], [SSN] ) ON [PRIMARY]
3) CREATE INDEX [IX_tblDMFile] ON [dbo].[tblDMFile]([DeathDate],
[LastName], [FirstName])
ON [PRIMARY]
I am guessing most of the searches will be off the SSN then probably least
likely LastName...
Thanks again.
"CBretana" <cbretana@.areteIndNOSPAM.com> wrote in message
news:A19A88F8-A183-4116-98F2-24BF3666352E@.microsoft.com...
> My understanding (could be wrong) is that SSNs of deceased persons are
> reused, (or can be resused) so, if that is in fact true, then your use of
> SSN
> as single column Primary Key might be an issue. If true, you could add
> DeathDate as well, (make it non null) I would assume since this is Death
> File, every record will have to have a Death Date?
> CONSTRAINT [PK_tblDMFile] PRIMARY KEY CLUSTERED
> ([DeathDate],[SSN]) ON [PRIMARY]
> That will handle the issue...
> Also, suggest you put DeathDate first in the Index, and make this the
> Clustered Index (on DeatHDate, SSN), since this will ensure that new
> Inserts
> will generally be added to new Pages on disk, not randomly distributed
> throughout the physical storage... Putting SSN as first column in PK
> index,
> means that records would be physically ordered on SSN, and new inserts
> will
> be distributed among all the physical pages on disk, causing many page
> splits
> and rapid table and index fragmentation.
>
> "CD" wrote:
>|||CD,
The only other suggestion I can make, related to minimizing disk storage,
which will only save you 8bytes per record, is based on my assumption that
you are not storing time data in either Birthdate or death date... Therefore
,
by using SmallDateTime, which uses 2bytes for date, and 2 bytes for time, yo
u
are wasting the 2 time bytes. One way avoid this is to use your own
propietary "Date" data type, based on SmallInt, where the value of the
smallInt
(which is from -2^15 (-32,768) through 2^15 - 1 (32,767) represents the
Date as number of days since some arbitrary Date. If you Cast a
smalldateTime to a SmallInt, you will get the same value based on 1 Jan 1900
,
If you want to use the same values as the 2 bytes in a SmallDateTime Value,
you must remember that the 2 date bytes in a smalldatetime represent integer
s
from 0 to 65535, (UNSIGNED 2-byte Integer), not from -32,768 to 32,767.
So, if you want to take this approach, first you need to decide what range
of dates you want to be able to represent... And to do this in 2 bytes, you
need to limit it to 65536 dates.. If you want to use the same range of dates
as SmallDateTime
(1 Jan 1900 - 6 Jun 2079)
Then the conversion from a SmalldateTime value (say it's in Variable @.SDT)
to the smallint you need to store in your table will be
Cast (Cast (@.SDT as Integer) - 32768 As SmallInt)
1) Cast SmallDateTime as Integer (it's in range 0 - 65535)
2) Subtract 32,768 (now it's in range - 32,768 to 32,7687)
3) Cast it as SmallInt (This not absoutely necessay as Insert into SmallInt
Column will auto convert an integer)
And the conversion from the smallint in the table (say Colname is
"DeathDt"), to the SmalldateTime value will be
Cast(DeathDt + 32768 As SmallDateTime)
Add 32,768 (to make it positive (in range from 0 - 65535) and then cast it
to smalldateTime
By the way, you can add Calculated columns to the table definition, based
exactly on that latter formula [ Cast(DeathDt + 32768 As SmallDateTime) ]
that will not increase on disk data storage, yet output the exact
SmallDateTime value exactly as you would if you stored it in the the table a
s
a SmallDateTime...
"CD" wrote:

> Thanks for the reply. That is a good point about SSN resuage(possibly)
> 1) To clarify the table schema is good for the best Least space usage
> 2) ALTER TABLE [dbo].[tblDMFile] WITH NOCHECK ADD
> CONSTRAINT [PK_tblDMFile] PRIMARY KEY CLUSTERED
> ([DeathDate], [SSN] ) ON [PRIMARY]
> 3) CREATE INDEX [IX_tblDMFile] ON [dbo].[tblDMFile]([DeathDate],
> [LastName], [FirstName])
> ON [PRIMARY]
> I am guessing most of the searches will be off the SSN then probably least
> likely LastName...
> Thanks again.
>
> "CBretana" <cbretana@.areteIndNOSPAM.com> wrote in message
> news:A19A88F8-A183-4116-98F2-24BF3666352E@.microsoft.com...
>
>|||Never actually researched this one, Thanx Michael... Another urban legend
bites the dust...
"Michael C#" wrote:

> According to the Social Security Administration (www.ssa.gov), SSN's are N
OT
> re-assigned after someone dies. However, some people are not assigned SSN
's
> (Pennsylvania Amish spring immediately to mind), so SSN might be NULL for
> some folks, which could cause issues. I'm facing a similar issue with
> trying to identify people uniquely in a database right now myself.
> --Quote From SSA.GOV Website:
> Question:
> Are Social Security Numbers re-assigned after a person dies?
> Answer:
> No. We do not reassign a Social Security number (SSN) after the
> number holder's death. Even though we have issued over 415 million SSNs so
> far, and we assign about 5 and one-half million new numbers a year, the
> current numbering system will provide us with enough new numbers for sever
al
> generations into the future with no changes in the numbering system.
>
> --End Quote
> "CBretana" <cbretana@.areteIndNOSPAM.com> wrote in message
> news:A19A88F8-A183-4116-98F2-24BF3666352E@.microsoft.com...
>
>|||Sorry, not 8bytes per record, only 2 byes/record, total only 4 bytes saved..
.
"CBretana" wrote:
> CD,
> The only other suggestion I can make, related to minimizing disk storage,
> which will only save you 8bytes per record, is based on my assumption that
> you are not storing time data in either Birthdate or death date... Therefo
re,
> by using SmallDateTime, which uses 2bytes for date, and 2 bytes for time,
you
> are wasting the 2 time bytes. One way avoid this is to use your own
> propietary "Date" data type, based on SmallInt, where the value of the
> smallInt
> (which is from -2^15 (-32,768) through 2^15 - 1 (32,767) represents the
> Date as number of days since some arbitrary Date. If you Cast a
> smalldateTime to a SmallInt, you will get the same value based on 1 Jan 19
00,
> If you want to use the same values as the 2 bytes in a SmallDateTime Value
,
> you must remember that the 2 date bytes in a smalldatetime represent integ
ers
> from 0 to 65535, (UNSIGNED 2-byte Integer), not from -32,768 to 32,767.
> So, if you want to take this approach, first you need to decide what range
> of dates you want to be able to represent... And to do this in 2 bytes, yo
u
> need to limit it to 65536 dates.. If you want to use the same range of dat
es
> as SmallDateTime
> (1 Jan 1900 - 6 Jun 2079)
> Then the conversion from a SmalldateTime value (say it's in Variable @.SDT)
> to the smallint you need to store in your table will be
> Cast (Cast (@.SDT as Integer) - 32768 As SmallInt)
> 1) Cast SmallDateTime as Integer (it's in range 0 - 65535)
> 2) Subtract 32,768 (now it's in range - 32,768 to 32,7687)
> 3) Cast it as SmallInt (This not absoutely necessay as Insert into SmallIn
t
> Column will auto convert an integer)
>
> And the conversion from the smallint in the table (say Colname is
> "DeathDt"), to the SmalldateTime value will be
> Cast(DeathDt + 32768 As SmallDateTime)
> Add 32,768 (to make it positive (in range from 0 - 65535) and then cast i
t
> to smalldateTime
> By the way, you can add Calculated columns to the table definition, based
> exactly on that latter formula [ Cast(DeathDt + 32768 As SmallDateTime) ]
> that will not increase on disk data storage, yet output the exact
> SmallDateTime value exactly as you would if you stored it in the the table
as
> a SmallDateTime...
>
> "CD" wrote:
>|||Thanks for the advice,
The date is currently a problem in its current format (MM,DD,CC,YY)
01301980. I have the data loaded (dates are in varchar) and plan to run a
update to move the year to front the change the column type.
I have not test but hope this will work.
set Deathdate = Right(Deathdate, 4) + Left(Deathdate, 4)
"CBretana" <cbretana@.areteIndNOSPAM.com> wrote in message
news:17A3FFDD-9F3F-4266-9B28-9F57F729BC07@.microsoft.com...
> Sorry, not 8bytes per record, only 2 byes/record, total only 4 bytes
> saved...
> "CBretana" wrote:
>|||Yes that should work...
but cast or convert the result to smalldateTime as well...
Cast(Right(Deathdate, 4) + Left(Deathdate, 4) As SmallDateTime)
"CD" wrote:

> Thanks for the advice,
> The date is currently a problem in its current format (MM,DD,CC,YY)
> 01301980. I have the data loaded (dates are in varchar) and plan to run a
> update to move the year to front the change the column type.
> I have not test but hope this will work.
> set Deathdate = Right(Deathdate, 4) + Left(Deathdate, 4)
> "CBretana" <cbretana@.areteIndNOSPAM.com> wrote in message
> news:17A3FFDD-9F3F-4266-9B28-9F57F729BC07@.microsoft.com...
>
>|||On Wed, 9 Mar 2005 12:14:46 -0600, CD wrote:
(snip)
> The column's with asterisk are possibly empty.
(snip)
Hi CD,
Then why are the columns without asterisk not declared as NOT NULL?
* Prevents data corruption
* Since you want the best space allocation: would save you one byte per
row (up to 8 nullable columns take a one-byte bitmap to hold the
NULL/NOT NULL control bits; 9-16 nullable columns add a second byte to
the NULL/NOT NULL bitmap, etc.)
Best, Hugo
--
(Remove _NO_ and _SPAM_ to get my e-mail address)

Design View

I have a database created by another developer that I purchased and was
recently instructed to change some values in some tables form one kind to
another like "NOT NULL" to "NULL" or change something to a "FLOAT" I am not
that good at SQL but have always done this stuff with the Query Anylizer.. I
kept getting errors due to the relations in the tables and was instructed to
do the following?
"You should just make these changes in the design view of Enterprise
Manager, not through SQL commands. It should automatically update any
relationships for you."
I created a new view but still do not see where I can change these values,
all 3 of my SQL books seem to not cover this or the Enterprise Manager very
much.. And the hlp file is not clear on this either.
Thanks for any help.
Don
Hi
If you have purchased this database then I would expect it is the
responsibility of the developer that sold it you to create the appropriate
upgrade scripts!
There is nothing wrong with doing this in Query Analyser and most
experienced DBAs will do it that way. Enterprise manager will do some of the
harder work required to change columns when they are part of a PK or FK. You
can use profiler to see what EM does when you save changes made.
Using EM to get into design mode for a table, open up the tables branch in
EM and right click the table, you will then have a design table option on
the menu.
John
"Don Stull" <dstull1@.msn.com> wrote in message
news:eW7AeQuUEHA.1764@.TK2MSFTNGP10.phx.gbl...
> I have a database created by another developer that I purchased and was
> recently instructed to change some values in some tables form one kind to
> another like "NOT NULL" to "NULL" or change something to a "FLOAT" I am
not
> that good at SQL but have always done this stuff with the Query Anylizer..
I
> kept getting errors due to the relations in the tables and was instructed
to
> do the following?
> "You should just make these changes in the design view of Enterprise
> Manager, not through SQL commands. It should automatically update any
> relationships for you."
> I created a new view but still do not see where I can change these values,
> all 3 of my SQL books seem to not cover this or the Enterprise Manager
very
> much.. And the hlp file is not clear on this either.
> Thanks for any help.
> Don
>
>