dbTalk Databases Forums  

Almost Newbie: My first SQL Server Database

microsoft.public.sqlserver.setup microsoft.public.sqlserver.setup


Discuss Almost Newbie: My first SQL Server Database in the microsoft.public.sqlserver.setup forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Templar
 
Posts: n/a

Default Almost Newbie: My first SQL Server Database - 01-08-2010 , 01:47 PM






My Form Solicits The Following:
Type of Pet: (radio button selection)
First Name (text)
Last Name (text)
Street Address (text/numeric)
City (text)
State (text)
Zip Code: (numeric)
Email: (text)
Phone: (numeric)
Name of Pet (Text)
Age (numeric)
Weight (numeric)
Breed (text)
Color (text)
Gender (radio button selection)
Spayed (radio button selection)
Rabies Vacine (radio button selection)
Pet Information (text box)
Photo (upload)
OptIn (Checkbox Yes/No)

The SQL table CREATION TOOL at my host has the following columns
KEY - Column - Type - Length - Prec. - Scale - Nullable - Default - ID. -
Id.Incr. -
Id. seed - Row GUID

I'm presuming the field name goes into the "Column" column. However, I am
seeking guidance in understanding how to respone/what to enter in the other
columns beginning with KEY and ending with Row GUID with the TYPE column
appearing to be the most significant. I would presume that VarChar would be
appropriate for the text fields and Int. appropriate for the numbers (zip
code etc) fields..............but who knows. The TYPLE Column provides a
drop down menu which provides the following list from which to choose:

BigInt, Binary, Bit, Char, DataTime, Decimal, Float, Image, Int, Money,
NChar, None,
NText. Numeric. NVarChar, NVarCharMax, Real, SmallDateTime, SmallInt,
SmallMoney, SysName, Text, TimeStamp, TinyInt, UniqueIdentifer, VarBinary
VarBinaryMax, VarChar, VarCharMax, Variant, XML

Can you direct me to a handy "jump start" learning aid/resource/cheat
sheet...................whatever..........that will get me "up and running".

PS: I wish there was a way of including an attachment with this question.

Thanks.


--
Templar

Reply With Quote
  #2  
Old   
Rick Byham, MSFT
 
Posts: n/a

Default Re: Almost Newbie: My first SQL Server Database - 01-11-2010 , 10:59 AM






The Key is the column name or names that uniquely identify each row. That
could be the First Name and Last Name of the columns combined. However you
might have two customers named John Smith or a single customer might have
two pets, so usually some sort of PetID column is added.
Zip Code isn't a number. After all , if you store 02948 as a number it would
be 2948. You would lose the leading 0. Same with Phone. It's not a really a
number. Ask yourself, "Does it make sense two add two phone numbers
together, or get the average of the phone numbers?" If not, it's probably
not really a number. It's just that the characters allowed are only 0-9.
Weight and age, are numbers. You could calculate the average weight of the
dogs.
Char is a character column. You specify how many characters are always
allocated. Zip is a good Char column. Always 5 characters, (or always 9).
Use VarChar for text values that vary in size, like First Name. Then Robert
uses space for 7 characters, but Bob only uses 3.
Precision and scale have to do with decimal numbers. Do you want to store
25.21563 for the weight, or just 25.2. If you only want 25, use integer
(int).
E-mail should be nullable. If people don't have an e-mail address, or don't
wish to share it, then you can complete the form without including it.
Database people like to require all the columns (like Age) to be completed.
But users prefer the columns to be nullable (because you got the cat from
the pound and you don't know the age).

A more complicated concept is called normalization. In your example, if one
owner had 5 pets, you would have to enter the name and address fields for
each pet (duplicating the information 5 times). And if they move, you might
end up with some pets with the new address and other pets with the old
address. Consider putting the information about the people (address, phone
number) in one table, and the information about the pet (type, Name of pet,
weight) in a different table. Then the pet table gets a column called Owner
ID, so you can relate the owner info to the pet info. Queries (searches of
the database) must join the two tables together. A sample query:
SELECT Pet.[Name of Pet], Owner.[Last Name]
FROM Pet JOIN Owner ON Pet.OwnerID = Owner.OwnerID
WHERE [Name of Pet] = 'Fluffy'
This is a basic database concept and the tools will expect this.

Try a used bookstore for a book on basic database principles.
I hope this gets you started.
--
Rick Byham, MSFT
(Implies no warranty or rights)


"Templar" <Templar (AT) discussions (DOT) microsoft.com> wrote

Quote:
My Form Solicits The Following:
Type of Pet: (radio button selection)
First Name (text)
Last Name (text)
Street Address (text/numeric)
City (text)
State (text)
Zip Code: (numeric)
Email: (text)
Phone: (numeric)
Name of Pet (Text)
Age (numeric)
Weight (numeric)
Breed (text)
Color (text)
Gender (radio button selection)
Spayed (radio button selection)
Rabies Vacine (radio button selection)
Pet Information (text box)
Photo (upload)
OptIn (Checkbox Yes/No)

The SQL table CREATION TOOL at my host has the following columns
KEY - Column - Type - Length - Prec. - Scale - Nullable - Default - ID. -
Id.Incr. -
Id. seed - Row GUID

I'm presuming the field name goes into the "Column" column. However, I am
seeking guidance in understanding how to respone/what to enter in the
other
columns beginning with KEY and ending with Row GUID with the TYPE column
appearing to be the most significant. I would presume that VarChar would
be
appropriate for the text fields and Int. appropriate for the numbers (zip
code etc) fields..............but who knows. The TYPLE Column provides a
drop down menu which provides the following list from which to choose:

BigInt, Binary, Bit, Char, DataTime, Decimal, Float, Image, Int, Money,
NChar, None,
NText. Numeric. NVarChar, NVarCharMax, Real, SmallDateTime, SmallInt,
SmallMoney, SysName, Text, TimeStamp, TinyInt, UniqueIdentifer, VarBinary
VarBinaryMax, VarChar, VarCharMax, Variant, XML

Can you direct me to a handy "jump start" learning aid/resource/cheat
sheet...................whatever..........that will get me "up and
running".

PS: I wish there was a way of including an attachment with this question.

Thanks.


--
Templar

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.