• Tidak ada hasil yang ditemukan

INVOICE

4.5 DATA TABLE STRUCTURES

Once a set of relations has been derived, the final stage of data design involves specifying the physical table structures. This includes defining the columns and their data types and sizes. At this point the analyst may choose to use codes to identify some data values, e.g.

student_id – S123456, course_code – CMP etc. Using codes – which usually consist of letters and/or numbers – appropriately can minimise data entry time, reduce data entry mistakes and save storage space. Where numeric-only codes are used to uniquely identify data records these are usually automatically generated by the system to avoid duplicates being entered in error.

Typical available data types include the following:-

Number – used to hold values which are used in calculations, e.g. hourly pay rate, are normally defined as integers if only whole numbers need to be stored, e.g. 121, or real numbers if decimal places are needed e.g. 5.25.

Download free eBooks at bookboon.com Click on the ad to read moreClick on the ad to read moreClick on the ad to read moreClick on the ad to read moreClick on the ad to read moreClick on the ad to read moreClick on the ad to read moreClick on the ad to read moreClick on the ad to read moreClick on the ad to read moreClick on the ad to read moreClick on the ad to read moreClick on the ad to read moreClick on the ad to read moreClick on the ad to read moreClick on the ad to read moreClick on the ad to read moreClick on the ad to read moreClick on the ad to read moreClick on the ad to read moreClick on the ad to read moreClick on the ad to read moreClick on the ad to read moreClick on the ad to read moreClick on the ad to read moreClick on the ad to read moreClick on the ad to read moreClick on the ad to read moreClick on the ad to read moreClick on the ad to read more

Maersk.com/Mitas

�e Graduate Programme for Engineers and Geoscientists

Month 16 I was a construction supervisor in the North Sea

advising and helping foremen solve problems I was a

he s

Real work International opportunities

�ree work placements al

Internationa or

�ree wo

I wanted real responsibili�

I joined MITAS because

Maersk.com/Mitas

�e Graduate Programme for Engineers and Geoscientists

Month 16 I was a construction supervisor in the North Sea

advising and helping foremen solve problems I was a

he s

Real work International opportunities

�ree work placements al

Internationa or

�ree wo

I wanted real responsibili�

I joined MITAS because

Maersk.com/Mitas

�e Graduate Programme for Engineers and Geoscientists

Month 16 I was a construction supervisor in the North Sea

advising and helping foremen solve problems I was a

he s

Real work International opportunities

�ree work placements al

Internationa or

�ree wo

I wanted real responsibili�

I joined MITAS because

Maersk.com/Mitas

�e Graduate Programme for Engineers and Geoscientists

Month 16 I was a construction supervisor in the North Sea

advising and helping foremen solve problems I was a

he s

Real work International opportunities

�ree work placements al

Internationa or

�ree wo

I wanted real responsibili�

I joined MITAS because

www.discovermitas.com

Character – used to store character strings of a fixed length which can be made up of letters, digits or other symbols commonly found on a computer keyboard. Note. Columns that do not contain the maximum number of characters specified will normally be padded out with spaces. Fixed size codes such as student id or items such as telephone numbers are usually defined as character data types.

Variable length character – used to store variable length character strings, these allow for larger strings to be stored but if a string that is less than the maximum specified length is entered, the data value is not padded with spaces and the system shrinks the column in order to save storage space.

Date – the date datatype is used when actual dates need to be stored. They are encoded so that they can be used in date checking arithmetic, whereas dates stored within a character field may look like dates when displayed, but are not stored as true dates therefore they cannot be recognised as such in date checking validation or calculations.

Note. The specific data types available and their storage formats will depend on the database management system specified for implementation.

Care should be taken when specifying data types and sizes to ensure that they will hold the maximum required numerical values, character string lengths or date formats.

Similar data type principles also apply to conventional data files that may be used in some systems.

The following shows the ORACLE Structured Query Language (SQL) table structure definitions for the student ERD example shown in Fig 4.15 above:-

CREATE TABLE course (

Course_Id char(3) Primary key, Course_name varchar(30));

CREATE TABLE student (

Student_Id char(3) Primary Key, Student_name varchar2(30),

Course_Id char(3) references Course (Course_Id));

Download free eBooks at bookboon.com

CREATE TABLE module (

Module_Id char(2) Primary Key, Module_name varchar2(30));

CREATE TABLE module_grade ( Student_Id char(3),

Module_Id char(2) references module (Module_Id), Module_Grade Integer,

Primary key (Student_Id, Module_Id));

The ‘char ‘datatype defines a fixed length character string and the value in ( ) represents the maximum number of characters that can be stored.

Varchar2 data type defines a variable length character string and the value in ( ) represents the maximum number of characters that can be stored.

Integer data type defines a column that can hold a value in the range -2147483648 to 2147483647.

SQL can be used to extract and manipulate data from within the database tables. The following is an example for the query “which students are studying the Databases module”:- SELECT Student_name

FROM student, module_grade, module

WHERE student.Student_Id = module_grade.Student_Id AND module_grade.Module_Id = module.Module_Id

AND module.module_name = ‘Databases’;

Note that the data types and sizes are not specified within the SQL SELECT statement to extract the data, as the database maintains the stored table definitions.

Finally, data access and security need to be considered to ensure that users of the system are only granted access to data they are permitted to use. This is usually enabled by means of a system user access ID and password. Often, stored data is encrypted to prevent unauthorised access and audit logs may be kept to record information about a user’s data access. The database administrator will be responsible for setting access rights and ensuring that the database is backed up regularly to ensure that in the event of a serious problem, previously backed up data can be retrieved and reinstated.

Download free eBooks at bookboon.com