Access over 20 million homework & study documents

search

Database keys and datatypes

Content type
User Generated
Rating
Showing Page:
1/2
Explain about Data Types INT1, INT2, INT3,
INT4 & NUMC
INT1: 1-byte integer between 0 and 255. The length is set to 3 places for this data type.
INT2: 2-byte integer between -32767 and 32767. Fields of this type should only be used for length fields. These long
fields are positioned immediately in front of a long field (type LCHR, LRAW). With INSERT or UPDATE on the long
field, the database interface enters the length which was actually used in the length field. The length is set to 5 places
for this data type.
INT4: 4-byte integer between -2147483647 bis 2147483647. The length is set to 10 places for this data type.
NUMC: Long character field in which only numbers can be entered. The length of this field is limited to a maximum of
255 places.
Candidate key
The best way to define candidate keys is with an example. For example, a bank’s database is being designed. To
uniquely define each customer’s account, a combination of the customer’s ID or social security number (SSN) and a
sequential number for each of his or her accounts can be used. So, Mr. Andrew Smith’s checking account can be
numbered 223344-1, and his savings account 223344-2. A candidate key has just been created.
This can raise problems. What if the government makes a mistake and issues the same SSN to more than one
person, and both now want to open an account with the bank?
Because of such potential pitfalls, a frequently used option is to create your own candidate key. In this case, the
bank’s database can issue unique account numbers that are guaranteed to prevent the problem just highlighted. For
good measure, these account numbers can have some built-in logic. For example checking accounts can begin with
a ‘C,’ followed by the year and month of creation, and within that month, a sequential number. So Andrew Smith’s
checking account can now be C-200805-22. Even without referring elsewhere, a teller can identify that this was the
22nd checking account created in May 2008. Savings accounts follow the same logic, but with an ‘S’ instead of ’C.’
Note that it was possible to uniquely identify each account using the aforementioned SSNs and a sequential number
(assuming no government mess-up, in which the same number is issued to two people). So, this is a candidate key
that can potentially be used to identify records. However, a much better way of doing the same thing has just been
demonstrated - creating a candidate key. In fact, if the chosen candidate key is so good that it can certainly uniquely
identify each and every record, then it should be used as the primary key. All databases allow the definition of one,
and only one, primary key per table.

Sign up to view the full document!

lock_open Sign Up
Showing Page:
2/2

Sign up to view the full document!

lock_open Sign Up
Unformatted Attachment Preview
Explain about Data Types INT1, INT2, INT3, INT4 & NUMC INT1: 1-byte integer between 0 and 255. The length is set to 3 places for this data type. INT2: 2-byte integer between -32767 and 32767. Fields of this type should only be used for length fields. These long fields are positioned immediately in front of a long field (type LCHR, LRAW). With INSERT or UPDATE on the long field, the database interface enters the length which was actually used in the length field. The length is set to 5 places for this data type. INT4: 4-byte integer between -2147483647 bis 2147483647. The length is set to 10 pl ...
Purchase document to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Anonymous
I was struggling with this subject, and this helped me a ton!

Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4