Please Test My Script To Analyze Table Keys (was Submitted For Your Review...:)

Feb 25, 2005

Here is a script I wrote that analyzes datasets and returns all the minimal composite and unary keys that uniquely identify records. I wrote it because I frequently have to analyze client spreadsheets and non-normalized data tables.

On my desktop server it took about two minutes to analyze 2000 permutations of a table with 50 columns and 5000 records.

Please try it out for me and let me know if it chokes on anything, or if you see any ways it could be improved!

View 8 Replies


ADVERTISEMENT

Is There A Way Using Sqlexpress To Review The Most Recent Set Of Sql Commands Submitted To A Database?

May 18, 2007

is there a way using sqlexpress to review the most recent set of sql commandssubmitted to a database?I remember something about setting up logging in sql server 2000, but don'tsee much about this on google or the news group for 2005.thanksJeff Kish

View 2 Replies View Related

Review Of DB Design - Normalized, Contraints, Foreign Keys, Etc.

Jul 2, 2004

First of all, this is my initial thread here on dbforums. I come from the land of Broadband Reports and would like to say, Hello fellow DB enthusiasts. :)

I'm not a novice to relational databases (Access MDBs), but new to implementing a db via SQL SERVER (2000 in this case) and using Access Data Projects.

My partial db schema is as follows:

participants
---DID (pk) char(1)
---LID (fk - schools) char(4)
---studentLast varchar(50)
---studentFirst varchar(25)

Sample Data would be
010191M001 | 5671 | SPARKS | JONATHAN
030495F283 | 5671 | DYLAN | CYNTHIA
=====================================

enrollhist (insert/update trigger for enrollactive)
---EID (pk - autonumber) bigint(8)
---EMID (fk - enrollmode) int(4)
---DID (fk - participants) char(10)
---LID (fk - schools) char(4)
---enrollactive bit(1)

Sample Data would be
38173 | 4 | 030495F283 | 9003 | 0
38266 | 3 | 010191M001 | 5671 | 0
39022 | 6 | 030495F283 | 9003 | 0
39036 | 5 | 030495F283 | 9003 | 0
39044 | 4 | 030495F283 | 5671 | 1
39117 | 4 | 010191M001 | 5671 | 1
=====================================

enrollmode
---EMID (pk) int(4)
---mode varchar(25)

Sample Data would be
1 | RECEIVED
2 | WAITING
3 | PENDING
4 | ENROLLED
5 | DROPPED
6 | TRANSFERRED
10 | ORPHANED
11 | DENIED
=====================================

schools
---LID (pk) varchar(4)
---CTID (fk - caltracks) char(1)
---AID (fk - agencies) char(1)
---SDID (fk - schooldist) char(1)
---COID (fk - countydist) char(1)
---sitename varchar(25)
---sitetitle varchar(75)

Sample Data would be
5671 | 3 | 2 | 1 | 4 | ASCOT | ASCOT AVENUE
9003 | 2 | 1 | 4 | 1 | ROWAN | ROWAN AVENUE
2865 | 1 | 3 | 2 | 3 | BRIGHT | BIRDELEE BRIGHT
=====================================

caltracks
---CTID (pk) char(1)
---legend char(4)
---trktitle varchar(15)
---trkcnt int(4)

Sample Data would be
1 | 9030 | 90/30 | 4
2 | CON6 | CONCEPT-6 | 3
3 | SNGL | SINGLE TRACK | 1
=====================================

agencies
---AID (pk) char(1)
---legend varchar(4)
---agencytitle varvhar(50)

Sample Data would be
1 | CRYS | CRYSTAL STAIRS
2 | MAOF | MEXICAN AMERICAN FOUNDATION
3 | PATH | PATHWAYS
4 | CCRC | CHILD CARE RESOURCE CENTER
5 | CHSC | CHILDREN'S HOME SOCIETY OF CALIFORNIA
==========================================

THE REMAINING "FKs" FROM SCHOOL ARE SIMILAR, as is other tables and their relationships. The design of the foreign keys were made using sql and the keyword "REFERENCES" and "FOREIGN KEY."

My questions are: :confused:
(1) Is the use of FK as a Constraint any different than using an INDEX and how?
(2) Should I Alter the Tables to include CASCADING Up/Down?
(3) Are the use of CHARs Ok for the Keys?
(4) Have I over/under-normalized any of the relationships?

View 4 Replies View Related

Oracle's Analyze Table Statement ?

Oct 9, 2004

Hi,

Below is an Oracle query used for cost optimization purpose :

analyze table test estimate statistics sample 2500 Rows;

Is there any equivalent for the above in SQL Server ?

Please advice,

Thanks,
Sam

View 5 Replies View Related

Creating Inter-table Relationships Using Primary Keys/Foreign Keys Problem

Apr 11, 2006

Hello again,

I'm going through my tables and rewriting them so that I can create relationship-based constraints and create foreign keys among my tables. I didn't have a problem with a few of the tables but I seem to have come across a slightly confusing hiccup.

Here's the query for my Classes table:

Code:

CREATE TABLE Classes
(
class_id
INT
IDENTITY
PRIMARY KEY
NOT NULL,

teacher_id
INT
NOT NULL,

class_title
VARCHAR(50)
NOT NULL,

class_grade
SMALLINT
NOT NULL
DEFAULT 6,

class_tardies
SMALLINT
NOT NULL
DEFAULT 0,

class_absences
SMALLINT
NOT NULL
DEFAULT 0,

CONSTRAINT Teacher_instructs_ClassFKIndex1 FOREIGN KEY (teacher_id)
REFERENCES Users (user_id)
)

This statement runs without problems and I Create the relationship with my Users table just fine, having renamed it to teacher_id. I have a 1:n relationship between users and tables AND an n:m relationship because a user can be a student or a teacher, the difference is one field, user_type, which denotes what type of user a person is. In any case, the relationship that's 1:n from users to classes is that of the teacher instructing the class. The problem exists when I run my query for the intermediary table between the class and the gradebook:

Code:

CREATE TABLE Classes_have_Grades
(
class_id
INT
PRIMARY KEY
NOT NULL,

teacher_id
INT
NOT NULL,

grade_id
INT
NOT NULL,

CONSTRAINT Grades_for_ClassesFKIndex1 FOREIGN KEY (grade_id)
REFERENCES Grades (grade_id),

CONSTRAINT Classes_have_gradesFKIndex2 FOREIGN KEY (class_id, teacher_id)
REFERENCES Classes (class_id, teacher_id)
)

Query Analyzer spits out: Quote: Originally Posted by Query Analyzer There are no primary or candidate keys in the referenced table 'Classes' that match the referencing column list in the foreign key 'Classes_have_gradesFKIndex2'. Now, I know in SQL Server 2000 you can only have one primary key. Does that mean I can have a multi-columned Primary key (which is in fact what I would like) or does that mean that just one field can be a primary key and that a table can have only the one primary key?

In addition, what is a "candidate" key? Will making the other fields "Candidate" keys solve my problem?

Thank you for your assistance.

View 1 Replies View Related

Script To Analyze Table Space Usage

Feb 14, 2006

Edit 2007-8-9:
Added code to show database file sizes. Not really closely related to tables sizes, but a lot of the people who need this want to know why their database it so large, so it may help to know which files, especially the logs, are so large, and if the files have empty space in them.


-- Script to analyze table space usage using the
-- output from the sp_spaceused stored procedure
-- Works with SQL 7.0, 2000, and 2005

set nocount on


print 'Show Size, Space Used, Unused Space, Type, and Name of all database files'

select
[FileSizeMB]=
convert(numeric(10,2),sum(round(a.size/128.,2))),
[UsedSpaceMB]=
convert(numeric(10,2),sum(round(fileproperty( a.name,'SpaceUsed')/128.,2))) ,
[UnusedSpaceMB]=
convert(numeric(10,2),sum(round((a.size-fileproperty( a.name,'SpaceUsed'))/128.,2))) ,
[Type] =
case when a.groupid is null then '' when a.groupid = 0 then 'Log' else 'Data' end,
[DBFileName]= isnull(a.name,'*** Total for all files ***')
from
sysfiles a
group by
groupid,
a.name
with rollup
having
a.groupid is null or
a.name is not null
order by
case when a.groupid is null then 99 when a.groupid = 0 then 0 else 1 end,
a.groupid,
case when a.name is null then 99 else 0 end,
a.name




create table #TABLE_SPACE_WORK
(
TABLE_NAME sysnamenot null ,
TABLE_ROWS numeric(18,0)not null ,
RESERVED varchar(50) not null ,
DATA varchar(50) not null ,
INDEX_SIZE varchar(50) not null ,
UNUSED varchar(50) not null ,
)

create table #TABLE_SPACE_USED
(
Seqintnot null
identity(1,1)primary key clustered,
TABLE_NAME sysnamenot null ,
TABLE_ROWS numeric(18,0)not null ,
RESERVED varchar(50) not null ,
DATA varchar(50) not null ,
INDEX_SIZE varchar(50) not null ,
UNUSED varchar(50) not null ,
)

create table #TABLE_SPACE
(
Seqintnot null
identity(1,1)primary key clustered,
TABLE_NAME SYSNAME not null ,
TABLE_ROWS int not null ,
RESERVED int not null ,
DATA int not null ,
INDEX_SIZE int not null ,
UNUSED int not null ,
USED_MBnumeric(18,4)not null,
USED_GBnumeric(18,4)not null,
AVERAGE_BYTES_PER_ROWnumeric(18,5)null,
AVERAGE_DATA_BYTES_PER_ROWnumeric(18,5)null,
AVERAGE_INDEX_BYTES_PER_ROWnumeric(18,5)null,
AVERAGE_UNUSED_BYTES_PER_ROWnumeric(18,5)null,
)

declare @fetch_status int

declare @proc varchar(200)
select@proc= rtrim(db_name())+'.dbo.sp_spaceused'

declare Cur_Cursor cursor local
for
select
TABLE_NAME=
rtrim(TABLE_SCHEMA)+'.'+rtrim(TABLE_NAME)
from
INFORMATION_SCHEMA.TABLES
where
TABLE_TYPE= 'BASE TABLE'
order by
1

open Cur_Cursor

declare @TABLE_NAME varchar(200)

select @fetch_status = 0

while @fetch_status = 0
begin

fetch next from Cur_Cursor
into
@TABLE_NAME

select @fetch_status = @@fetch_status

if @fetch_status <> 0
begin
continue
end

truncate table #TABLE_SPACE_WORK

insert into #TABLE_SPACE_WORK
(
TABLE_NAME,
TABLE_ROWS,
RESERVED,
DATA,
INDEX_SIZE,
UNUSED
)
exec @proc @objname =
@TABLE_NAME ,@updateusage = 'true'


-- Needed to work with SQL 7
update #TABLE_SPACE_WORK
set
TABLE_NAME = @TABLE_NAME

insert into #TABLE_SPACE_USED
(
TABLE_NAME,
TABLE_ROWS,
RESERVED,
DATA,
INDEX_SIZE,
UNUSED
)
select
TABLE_NAME,
TABLE_ROWS,
RESERVED,
DATA,
INDEX_SIZE,
UNUSED
from
#TABLE_SPACE_WORK

end --While end

close Cur_Cursor

deallocate Cur_Cursor

insert into #TABLE_SPACE
(
TABLE_NAME,
TABLE_ROWS,
RESERVED,
DATA,
INDEX_SIZE,
UNUSED,
USED_MB,
USED_GB,
AVERAGE_BYTES_PER_ROW,
AVERAGE_DATA_BYTES_PER_ROW,
AVERAGE_INDEX_BYTES_PER_ROW,
AVERAGE_UNUSED_BYTES_PER_ROW

)
select
TABLE_NAME,
TABLE_ROWS,
RESERVED,
DATA,
INDEX_SIZE,
UNUSED,
USED_MB=
round(convert(numeric(25,10),RESERVED)/
convert(numeric(25,10),1024),4),
USED_GB=
round(convert(numeric(25,10),RESERVED)/
convert(numeric(25,10),1024*1024),4),
AVERAGE_BYTES_PER_ROW=
case
when TABLE_ROWS <> 0
then round(
(1024.000000*convert(numeric(25,10),RESERVED))/
convert(numeric(25,10),TABLE_ROWS),5)
else null
end,
AVERAGE_DATA_BYTES_PER_ROW=
case
when TABLE_ROWS <> 0
then round(
(1024.000000*convert(numeric(25,10),DATA))/
convert(numeric(25,10),TABLE_ROWS),5)
else null
end,
AVERAGE_INDEX_BYTES_PER_ROW=
case
when TABLE_ROWS <> 0
then round(
(1024.000000*convert(numeric(25,10),INDEX_SIZE))/
convert(numeric(25,10),TABLE_ROWS),5)
else null
end,
AVERAGE_UNUSED_BYTES_PER_ROW=
case
when TABLE_ROWS <> 0
then round(
(1024.000000*convert(numeric(25,10),UNUSED))/
convert(numeric(25,10),TABLE_ROWS),5)
else null
end
from
(
select
TABLE_NAME,
TABLE_ROWS,
RESERVED=
convert(int,rtrim(replace(RESERVED,'KB',''))),
DATA=
convert(int,rtrim(replace(DATA,'KB',''))),
INDEX_SIZE=
convert(int,rtrim(replace(INDEX_SIZE,'KB',''))),
UNUSED=
convert(int,rtrim(replace(UNUSED,'KB','')))
from
#TABLE_SPACE_USED aa
) a
order by
TABLE_NAME

print 'Show results in descending order by size in MB'

select * from #TABLE_SPACE order by USED_MB desc
go

drop table #TABLE_SPACE_WORK
drop table #TABLE_SPACE_USED
drop table #TABLE_SPACE




CODO ERGO SUM

View 12 Replies View Related

Prompt When New Message Is Submitted

Jul 31, 2006

Hey everyone I dont know if this is the right area to post this but here it goesAn easy expamle of this that everyone is really fimaler with is myspace. When a new database entry is submitted then on the admin page it will say like new message(s).. how can I do this. It doesnt have to be per member. It is only going to be on the admin page.

View 1 Replies View Related

Parametervalue Is Not Submitted To ReportServer

Feb 7, 2008



Good day!

I've following problem: There are a few reports, all with parameters, and they work fine. For most user. But there is one user, stupidly he is the CEO, whose parameter selections doesn't take effect, so that the whole data are shown in the report. One of the admins have tried it on the CEO's PC, so faulty operation is barred.

I've had a look into the execution log, and it seems that the parameter values are not submitted to the IIS, so for the parameters in the log have the default values, what is in my case NULL.

Maybe that the problem depends on the not really actual system of the CEO's PC. Don't know the version of the Internet Explorer or the XP's service pack.


Has anyone seen that and can me give any suggestion?

Thanks,
Torsten

View 6 Replies View Related

Count All Table Rows Then Insert Into Test Table Using SSIS Packages

Jul 15, 2013

I have database test007DB and I need count all table rows then insert into test99 table using ssis packages .

test99: tableName countRows
t1 20
t2 30
t3 25

View 2 Replies View Related

DB Engine :: Replicate A Master Test Database To 100 Test Environments?

Oct 12, 2015

We are setting up a test lab environment with 100 machines.  We want one master testing db that gets replicated to each to run scripted application tests nightly.  

My goal is to minimize the amount of work to move this thing to each of the 100 test machines.  I am wondering if we need to even have the sql local and invest in a monster db server with 100 copies of the db we restore and each test machine point to their own db on that server, or if I should use db mirroring or something to get the master test db to each of those machines instead.

View 6 Replies View Related

MDX Training : Need Review

Apr 13, 2004

Hi Gurus ....

Planning for a MDX Training for me and my development team ...
The following has been proposed for a training course spread over three days ...

I need to know whether this will be enough or should some more things be added on to the same (anything that has been missed)...

I have the option of removing and adding from the list.


Module 1: OLAP Review

OLAP Databases
OLAP Definitions
Warehouse Data Flow

Module 2: MDX Foundations

The Role of MDX
MDX Member Names
Using the Calculated Member Builder
Working with Calculated Members

Module 3: Using MDX Expressions

Displaying Member Information
Displaying Family Tree Relatives
Working with Member Properties
Using Conditional Expressions

Module 4: Retrieving Values from a Cube

Understanding Multidimensional Coordinates
Retrieving a Value from a Cube
Percent of Total Calculations
Growth Calculations

Module 5: Creating Simple MDX Queries

Understanding MDX Query Statements
Creating Simple MDX Query Statements

Module 6: Creating and Manipulating Sets

Using Set Creation Functions
Using Set Manipulation Functions
Using Subquery Set Functions
Working with Dimension Interactions

Module 7: Using Aggregation Functions

Understanding Aggregation Functions
Using Time Set Functions
Calculating a Trend

Module 8: Case Study - Implementing Budget Allocations

Allocating Values from a Grand Total
Allocating Values from a Subtotal
Allocating Values Across Multiple Dimensions

Module 9: Using Calculated Cells



Respose needed urgently since I have to get back to the training team by tomorrow morning

View 8 Replies View Related

Unit Testing For SSIS - To Test Or Not To Test?

Oct 17, 2006

Now that we have a good programming model in SSIS - the question is whether to write automated unit tests for your packages, and would it generally be a good idea for packages?

Also - if yes to write tests - then where to find more informations regarding How to accomplish that?

View 1 Replies View Related

How To Test SSis Package And What Are The Things I Need To Test It ?

Nov 27, 2007



hi every one,
i need to test SSIS pacakge which will import data from different database where record count is around 5 millions.
iam planning to test it through c# code as well as manually also.
SSIS source : consist of 7 tables
SSIS destination :consist of 7 tables
Using c# code iam trying to run ssis package through batch file.
i am putting expected rowcount, column count in an excel file and comparing same with destination tables by writing query implementing ADO.Net concept.
am i going right way ,can any one suggest best and productive way to test the ssis package .
what are the other things i need to test it.
do any one can add test cases to it.






S.No

Test Case


1

Verify all the tables have been imported.



2

Verify all the rows in each table have been imported.



3

Verify all the columns specified in source query for each table have been imported


4

Verify all the data has been received without any truncation for each column.



5

Verify the schema at source and destination



6

Verify the time taken /speed for data transfer


7

Fields truncated due to difference in length of the field at destination.
Regards
Arif shareef

View 9 Replies View Related

Creating Indexes On Columns That Are Foreign Keys To Primary Keys Of Other Tables

Jul 16, 2014

what the best practice is for creating indexes on columns that are foreign keys to the primary keys of other tables. For example:

[Schools] [Students]
---------------- -----------------
| SchoolId PK|<-. | StudentId PK|
| SchoolName | '--| SchoolId |
---------------- | StudentName |
-----------------

The foreign key above is as:

ALTER TABLE [Students] WITH CHECK ADD CONSTRAINT [FK_Students_Schools]
FOREIGN KEY([SchoolId]) REFERENCES [Schools] ([SchoolId])

What kind of index would ensure best performance for INSERTs/UPDATEs, so that SQL Server can most efficiently check the FK constraints? Would it be simply:

CREATE INDEX IX_Students_SchlId ON Students (SchoolId)
Or
CREATE INDEX IX_Students_SchlId ON Students (SchoolId, StudentId)

In other words, what's best practice for adding an index which best supports a Foreign Key constraint?

View 4 Replies View Related

DB Analyze

Mar 16, 2008

I have been asked to analyze a DB which was under a different team. I have done the following,

1.Identified tables without PK, and clustered index
2.identified FK’s without index
3.orphan users and weak passwords
4.analyzed SPS for bad code

Is there anything else I can do? Are there any ready-made scripts which I can use.


------------------------
I think, therefore I am - Rene Descartes

View 5 Replies View Related

Please Review This UPDATE Sql Statement For Me

Mar 27, 2008

Thanks for looking at this for me. Here is the SQL Script as it stands so far. 
UPDATE    TableImportHistorySET ImportStopTime = CONVERT(numeric, GETDATE(), 108), Elapsetime = CONVERT(numeric,GETDATE(), 108) - CAST((SELECT TOP 1 ImportStartTime FROM TableImportHistory  WHERE     TableName = 'ARCHRG'ORDER BY DataImportID DESC) AS numeric), Successful = 1WHERE (DataImportID = (SELECT TOP 1 DataImportID AS LastID FROM TableImportHistory WHERE TableName = 'ARCHRG') ORDER BY DataImportID DESC))
The Elapetime update portion of this statement is where I'm getting stuck (if I take it out the statement works) 
I get the error "ERROR converting Data type NVARCHAR to Numeric" I've changed the data type in the Table from numric to varchar, nvarchar, decemial nothing works and not sure what I should set the Starttime and StopTime datatypes in the table to (any suggestions please)
Elapsetime = CONVERT(numeric,GETDATE(), 108) - CAST((SELECT TOP 1 ImportStartTime FROM TableImportHistory  WHERE     TableName = 'ARCHRG'ORDER BY DataImportID DESC) AS numeric) 
Are there better ways to do this statement?
 
Thank you in advance
Rex

View 4 Replies View Related

Getting A SQL Expert To Review SQL Server And DB?

Apr 3, 2007

Hi,

I posted last year when we were having problems with a new SQL box we had moved to here...

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=74650

...we coded round most of the issues and deadlocks and things seemed to improve for quite a while but we have recently run into performance problems again of late.

The CPUs on our SQL box often thrash away at 100% and our ColdFusion website has begun running painfully slow.

Our developers/hosts have suggested we might need to look for a 3rd party SQL guru who could look at the SQL box, do some tracing etc. and perhaps make some recomendations around optimising the DB architecture or changing the way we run certain queries. At the moment we have only gut instinct on which bits of the DB are likely to be being hit most hard.

Our website has grown from being very small to being really quite busy and it's possible we are running into shortcomings with the design of the DB that need to be tackled before we can expand further.

I'm not sure what the protocol is (I see there is a Jobs part of the site) but I wondered about the possibility of getting one of you guys in for a short while to review our server and database, for a fee of course. I'm not sure how long it would take to review that kind of data and get a feel for the usage?

We are based in the UK and whilst I guess it could be done remotely it might be easiest if the person was UK based too.

I'm as much interested in feedback about the idea (it might be not workable/a good idea for example) as I am to people offering their services.

If this post breaks any rules please let me know.

Cheers,

Tem

View 18 Replies View Related

Need Consultant Help For Architecture Review

Dec 18, 2007

Don't know if this is the appropriate forum. I am looking for an experienced SS consultant to review our setup, hardware architecture, recovery plan, and to provide high-level advice moving forward. My company is a CRM hosted software provider with a dynamic, metadata-based product built in Visual Studio 2005. Currently we run on SS 2000, but plan to migrate to SS 2005 or 2008. We anticipate quite a bit of growth and want to make sure that we are on the right path. Let me know if you are interested or know someone who is.

If I should post this elsewhere, let me know.

View 2 Replies View Related

Analyze Index In Ms SQL

Jul 21, 2003

Hello, friends!
sorry for the stupid question:
I created a new index on table and I'm looking to a command equal to "Analyze table ", "Compute statistics "in Oracle
to check if that index is usefull.

Thank you very much in advance.

View 3 Replies View Related

1st Attempt, Designing, Would Like Somebody To Review And Critique It

Jan 23, 2001

Hello

This is my 1st attempt at designing a database, and I have not finished
it completely, but I would like somebody to review and critique for me.
I really don't want to make any mistakes with this and I would appreciate any expertise out there to direct, recommend, suggest improvements and/or changes, PLEASE.

Thank you for considering this,,,if you provide me with your e-mail, I can send you a script.

take care,
~Iris~
:)

View 1 Replies View Related

User Review Database Design

Apr 14, 2008

I involved in redesign a database for hotel review listing. My current hotel datatable below

Hotel
ID
HotelName
Description
Address
TotalRating

If I would like to extend the review feature in details based on each user comments for example
Overall 7
Rooms 6
Services 7
Food 8


Could anyone guide me how could I modify the table or add new table that allow me to do so.
Thank you

View 10 Replies View Related

Generate Script For Primary Keys And Foreing Keys

May 16, 2008



Pls let me know How I generate script for All primary keys and foreign keys in a table. Thereafter that can be used to add primary keys and foreign keys in another databse with same structure.

Also how I script default and other constraints of a table?

View 2 Replies View Related

PIVOT Multiple Columns In Test Table

Apr 24, 2014

-- Here's a test table where I'm trying to workout how to Pivot more than one column.

-- Drop the Temp Table
IF (SELECT Object_id('tempdb..#Test_Pivot_Example')) <> 0
BEGIN
DROP TABLE #Test_Pivot_Example
END

[Code] ....

Once I have worked this out then I need to dynamic populate the IN ([1] etc with the val;ue sin field [SIZE])

but one step at a time trying to workout pivot on more than one column.

View 4 Replies View Related

2 Different Foreign Keys In One Table

Jun 13, 2006

There is itemlookup table, which stores item number and itemdescription. Also there is a child table, pricehistory, of theitemlookup table, which stores different prices and different dateranges. So it is one-to-many relationship. (Price can be stored morethan one with a different date range)And there is another table RequestItem that stores the foreign key ofthe itemlookup table to show the information of the itemlookup table.Then how do I know later which date range of the price was stored inthe RequestItem table? Since I only keep the foreign key of theitemlookup table, it will be impossible to keep track of the row of thepricehistory table if there are more than one data existed in thepricehistory table.Will it be a valid table structure to create a column for the foreignkey of the pricehistory in RequestItem table or any other ways tohandle this issue?

View 1 Replies View Related

Table Names As Keys?

Jul 20, 2005

Hello all,I got a chance to peak into a database system. Part of its design israther unfamiliar to me. When I look at the diagram generated by SQLServer, there are many floating tables. Eventually it turns out thatthese many floating tables are actually not floating. Their tablenames relate to fields (as TableID) in other tables. In this case,you can get a handle to one of such tables by search TableID columnsin other tables.To be more specific, the database is a microarray database implementedin SQL Server 2000. They have a table called MICROARRAYS. In thistable, there is a column called table_id. These table_ids are in facttable names of a bunch of other tables.My questions are1) Is this good relational design?2) How well is this kind of design supported in SQL Server?3) Are there better alternatives?Any other comment or link to helpful resources will also beappreciated.Thanks,Eric Wu

View 2 Replies View Related

How Many Foreing Keys Does A Table Has?

Dec 12, 2007



hi

I could not build a query using the system tables; where I can know how many foreing keys does a specific table has? I´m lost.

can somebody help me... thanks

View 4 Replies View Related

Analyze Key Influencers Questions

Jun 24, 2007

I will be grateful if you could answer a few more questions around Analyzing Key Influencers



1. When specifying the training data for Decision Tree, there is a SUGGEST button (Recommend inputs for currently set predictable) which recommends which input are related to the predictable attribute. It also gives a €˜Score€™ for each recommended inputs. What algorithm does the SUGGEST button use? Does it use simple entropy/correlation based algorithm OR sophisticated feature selection algorithms?

2. Can I access this €˜Score€™ and recommended inputs above programmatically?

3. What feature selection algorithms are used in SQL Server 2005? Can they be invoked programmatically?

5. In Logistic Regression mining model viewer, we get a chart which clearly shows what attributes favor which state of the predictable attribute. For example, income level < 23000 favors BikeBuyer = 0 (does not buy) with a score of 89.00. What algorithm is used to calculate the €˜Score€™? Can LR be used as a feature selector in case where the predicted attribute is binary (select the attributes that favor one state or the other with a score of, say, greater than some threshold)?

6. You suggested using Naive Bayes to find AKIs. What if the input attributes are all continuous (predicted attribute binary)? Shouldnt I be going for LR?

Thanks bunches

MA

View 4 Replies View Related

Analyze Key Influencers Issue........

Oct 23, 2007

Excuse the elementary question; I am new to this feature.


No matter what dataset I use, I get the following error:
"The task was not able to detect any key influencers for the 'xxx' column. The values of 'xxx' seem unrelated to values of other columns."


Any ideas on what is happening here?

Here is the sample dataset:







Loan Amount
CLTV
transmitted

1,000
51.0%
1

5,000
52.0%
1

9,000
53.0%
1

13,000
54.0%
1

17,000
55.0%
1

21,000
56.0%
1

25,000
57.0%
1

29,000
58.0%
1

33,000
59.0%
1

37,000
60.0%
0

41,000
61.0%
0

45,000
62.0%
0

49,000
63.0%
0

53,000
64.0%
0

57,000
65.0%
0

61,000
66.0%
0

65,000
67.0%
0

69,000
68.0%
0

73,000
69.0%
0

77,000
70.0%
0

Thanks in advance.......

View 13 Replies View Related

Query To Compare Table Data Between Test And Production?

Jul 23, 2005

I am debugging one of our programs and ran the fix in Test. I would liketo compare table 1 between Production and Test. I want the query to outputcolumn 1 if Production <> Test output.What is the best way to achieve this?jeff--Message posted via http://www.sqlmonster.com

View 2 Replies View Related

When Updating Keys How Do Cascade The Changes To Other Table?

Dec 13, 2007

I'm using SqlDatasource when the update process is on a primary key, how do you cascade the changes to other tables?
Also when deleting does the cascade deletes the row from another table or only sets the primary key to NULL?

View 1 Replies View Related

Update Table, Foreign Keys Etc

Aug 16, 2004

I have two tables as below. I want to update a quote and change the item for which it is for. So I want to do an update statement to change the cat_ref that the quote is for. However, when I do this I get a foreign key conflict with cat_ref in the item table. How do I get around this? Thanks


Code:

CREATE TABLE Item (
cat_ref VARCHAR(5)PRIMARY KEY,
descrip VARCHAR(50),
date_added SMALLDATETIME,
cat_type VARCHAR(20))


CREATE TABLE has_quote (
quote_id INT IDENTITY (1,1) PRIMARY KEY,
date_last_pricecheck SMALLDATETIME,
cat_ref VARCHAR(5)FOREIGN KEY
REFERENCES Item(cat_ref)
ON DELETE CASCADE,
first_name VARCHAR(10),
surname VARCHAR(10),
FOREIGN KEY (first_name, surname)
REFERENCES Customer(first_name, surname)
ON DELETE CASCADE
ON UPDATE CASCADE)

View 5 Replies View Related

Create Table With Foreign Keys

May 30, 2007

How do I create a table with a foreign key

View 6 Replies View Related

Two Primary Keys In A Single Table

Jul 15, 2012

I have a table fields Register_date, Std_ID, course, version, CourseLearningDays, Batch_Time and Trainer_IDHOw to make Register_date and Batch_Time as primary key in the table.. What are the necessary datatype for these two fields.And one more do we have datatype called date and time in MS SQL Server...

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved