Upload
anshu-kumar
View
214
Download
0
Embed Size (px)
DESCRIPTION
rdms
Citation preview
Relational Databases
Relational database
• data stored in tables• must put data into the correct tables• define relationship between tables• primary key• Standard Database Notation
EMPLOYEES(EmployeeID, Surname, Forename)
Creating a database file
• Design the record format for a table, considering:– the order of the fields;– the name of each field;– the data type for each field.
• Text (also referred to as Character or Alphanumeric);• Number (integer, or real with a specified number of decimal
points);• Date (in a number of different formats);• Yes/No (or True/False);• Memo (for writing notes about a client, for example);
– For some types of field, such as a text field, the field length is important.
Importance of Data types• Certain field types are automatically validated when the user
enters data.– If you have specified the field as a text field, no automatic validation
is possible.
• If a field is defined as currency or numeric, no non-numeric characters allowed
• A telephone number should not be numeric because it may require a space or hyphen
• Number fields are held differently inside the computer from text fields, and if the field will be involved in any type of calculation, it MUST be defined as numeric (or date, or currency)
• The length specified for a text field should also be chosen carefully and documented for future reference
Primary key• Each record in a database file needs to be given a
unique identifier - the primary key.• It needs to be carefully chosen;
– Surname, for example, is no use as an identifier.– MS Access has an Autonumber data type which generates
unique identifiers automatically• The primary key sometimes consists of more than one
field: for example several stores in a national chain may each have a store number, and each store may have Departments 1,2,3 etc.– To identify a particular department in a particular store, the
primary key would be composed of both Store number and Department number. Solving the flat file problems
Hierarchy of data• BIT
– All data is stored in a computer’s memory or storage devices in the form of binary digits or bits. A bit can be either ‘ON’ of ‘OFF’ representing 1 or 0.
• BYTE– is a group of 8 bits. One byte can represent one character or, in different
contexts, other data such as a sound, part of a picture etc.• FIELD
– is a group of characters. e.g. data held about a person may be split into many fields including ID Number, Surname, Initials, Title, Street, Town, etc
• RECORD– is a group of fields holding all the information about one person or item
• FILE– a collection of records. A stock file will contain a record for each item of
stock, and so on.• DATABASE
– may consist of many different files, linked in such a way that information can be retrieved from several files at once.