♥_ mE and oNLy mEh_♥

♥_ mE and oNLy mEh_♥
♥ wAz laNg ♥

Sunday, July 5, 2009

MY_ASSIGNMENT

DATA TYPES

a.)
A data type (or datatype) in programming languages is a set of values and the operations on those values.

Almost all programming languages explicitly include the notion of data type, though different languages may use different terminology. Most programming languages also allow the programmer to define additional data types, usually by combining multiple elements of other types and defining the valid operations of the new data type. For example, a programmer might create a new data type named "Person" that specifies that data interpreted as Person would include a name and a date of birth. Common data types may include:

* integers,
* floating-point numbers (decimals), and
* alphanumeric strings.

For example, in the Java programming language, the "int" type represents the set of 32-bit integers ranging in value from -2,147,483,648 to 2,147,483,647, as well as the operations that can be performed on integers, such as addition, subtraction, and multiplication. Colors, on the other hand, are represented by three bytes denoting the amounts each of red, green, and blue, and one string representing that color's name; allowable operations include addition and subtraction, but not multiplication.

A data type also represents a constraint placed upon the interpretation of data in a type system, describing representation, interpretation and structure of values or objects stored in computer memory. The type system uses data type information to check correctness of computer programs that access or manipulate the data.

b.) What role do they play in database?

The database itself can help to keep bad data out (for example you can't put 'text' into a number only field) and can speed things up especially searching and sorting?
Data type selection plays an important role in how efficiently your RDBMS functions, and so it's important to be fully aware of the options available to you, and to select the most appropriate data type for your storage needs. That's where this document comes in. It outlines the most important data types supported by PostgreSQL, describing when and how each should be used, and provides you with a ready supply of choices the next time you sit down to optimize your existing databases or create new ones.

c.) Example of data types in DBMS.

STRING
Character string, has a fixed size up to 64 kbytes.

DATE
This field is used to store the date. It takes 3 bytes and actually contains the munber of days from January 1, Year 0000.

POINTER
This field is a pointer to a record in another class. physically it contains the sub- class record number. Size can be from 1-4 bytes. Having pointer makes context somewhat different than traditional DBMS systems.Connection between tables in relational databases is done through the common indexing of two tables with common keys. In this case, the keys must be present in both tables, which means size overhead. To perform search for related records in two tables indexes are needed. In context there is no need to search. The number of a record in a sub class is contained in the field of the main class. (Terms "main class" and "sub class" in the future will only be used for clarity, but in reality all class in context are equal.) Since there are no keys, the performance is much better. In this case it is important to understand that fields are not linked together, only records. The field simple points to a record.

INTEGER, UNSIGNED
These types of fields are designed to store integer. Size may vary from 1 to 8 bytes. 8 bytes holds a very large number. It is often necessary to enter a number with decimal points (dollars and cents). A choice in selecting how precise you wish the number to be is available to you. Example: You many have an integer field that contains 7 bytes long with 2 numbers after the decimal point.

FLOAT, DOUBLE
Four and eight bit numbers with floating point. Size is fixed, but you can pick how precise you want them to be. Output will be limited to the number of digits you pick.

STRUCTURE
It is a static composite field. Actually this isn't a field. It is a package of fields or structure. This field consist of subfields that holds others ConteXt fields or objects. A subfields maybe STRUCTURE too etc. In other words this type of field can create a hierarchy of data inside a record. This opens up a lot of new opportunities in database design and makes some applications much easier to develop.

TEXT, BINARY
(BLOB - Binary Large Object) These are regular fields with a varying size. You can store unlimited size (limited by disk space) text or binary information .

IMAGE
This is a BINARY field clone. Contains GIF or JPEG image.

FILE
This field is similar to TEXT, but contains the name of the file in a file system. Essentially this is a pointer to a file. It is often a better idea to have a pointer to the file instead of copying the file contents into the file.

EXPRESSION
This is another TEXT field clone but contains a program on a certain language. When the output of a true field value is calculated.

COMPLEX
This is a dynamic composite field. The idea is similar to VARIANT but in relation to structures. Field STRUCTURE can contain sub fields, but their number and type is specified during the databse creation, and are therefore constant. What if it is necessary to change the structure of a field depending on the information? That's where COMPLEX type of fields comes in. Basically, it is a combination of a pointer to a sub Class containing the stuctures and a binary field containing the information.