Presentation is loading. Please wait.

Presentation is loading. Please wait.

©www.teach-ict.com Relational Databases. ©www.teach-ict.com Entities Data is stored in tables. Each table is concerned with one entity An entity is a.

Similar presentations


Presentation on theme: "©www.teach-ict.com Relational Databases. ©www.teach-ict.com Entities Data is stored in tables. Each table is concerned with one entity An entity is a."— Presentation transcript:

1 ©www.teach-ict.com Relational Databases

2 ©www.teach-ict.com Entities Data is stored in tables. Each table is concerned with one entity An entity is a person/object/event on which data can be held. In a hospital database the following would all be entities: Patient, nurse, treatment, ward, appointment, medical test, doctor.

3 ©www.teach-ict.com Attributes Each entity has a series of attributes. These describe different properties of the entity. The attributes of a patient would include: Name, address, age, weight, dietary needs etc

4 ©www.teach-ict.com Relationships Relationships exist between the different entities. For example the Doctor will treat many patients but a patient will only see one doctor.

5 ©www.teach-ict.com Entities, Attributes and Relationships A Video company wants to set up a database to keep accurate records on which videos have been rented by their customers. From the list on the next slide, decide which items are: Entities Attributes Any relationship between the entities.

6 ©www.teach-ict.com Task Length of film First Name Year released Video title E-mailDate rented RatingAddress Rental price AgeLast Name Date returned Phone number Film Genre Gender

7 ©www.teach-ict.com Entity: Customer Attributes First Name Surname Address Telephone Number Age Gender E-mail

8 ©www.teach-ict.com Entity: Video Attributes Video Title Rating Film Genre Date Released Length of film Rental price

9 ©www.teach-ict.com Entity: Video Rentals Attributes Date Rented Date Returned

10 ©www.teach-ict.com Tables Customer Table First Name Surname Address Telephone number E-mail Age Gender Video Table Video title Rating Film Genre Date Released Length of film Rental price Video Rentals Table Date Rented Date Returned

11 ©www.teach-ict.com Relationships Customer Table Customer ID First Name Surname Address Telephone number E-mail Age Gender Video Table Video ID Video title Rating Film Genre Date Released Length of film Rental price Video Rentals Table Video_Rental ID Customer ID Video ID Date Rented Date Returned

12 ©www.teach-ict.com Primary and Foreign Key Customer Table Customer ID First Name Surname Address Telephone number E-mail Age Gender Video Table Video ID Video title Rating Film Genre Date Released Length of film Rental price Video Rentals Table Video_Rental ID Customer ID Video ID Date Rented Date Returned

13 ©www.teach-ict.com Primary Keys This is a field that is used to uniquely define a particular record or line in a table. Since text fields e.g. surname can be repeated, primary keys are nearly always numeric fields. They can include: Membership number, product number, employee number, catalogue number, account number. If there is no logical number that can be used, then most databases will create one automatically (called auto number)

14 ©www.teach-ict.com Foreign Keys This is a field in one table which is also the primary key of another table. Foreign keys are used to establish a relationship between the main table and other subsidiary tables. Customer Table Customer ID First Name Surname Address Telephone number E-mail Age Gender Video Table Video ID Video title Rating Film Genre Date Released Length of film Rental price Video Rentals Table Video_Rent al ID Customer ID Video ID Date Rented Date Returned

15 ©www.teach-ict.com Standard database notation The tables we have looked at can be described as follows: CUSTOMER (CustomerID, Firstname, Surname, Address, TelephoneNumber, Email, Age, Gender) VIDEO (VideoID, VideoTitle, Rating, FilmGenre, DateReleased, LengthOfFilm, RentalPrice) VIDEORENTALS (VideoRentalID, CustomerID, VideoID, DateRented, DateReturned)

16 ©www.teach-ict.com Field Types Alphanumeric (text) Numeric. Currency Date Picture (bitmap) Logical/Boolean Autonumber Memo (for writing notes)

17 ©www.teach-ict.com Field Types It is important that when you create tables in Access, that you choose the correct field types right at the beginning. Similarly, if a field is defined as currency or numeric, text cannot be entered by mistake. Certain fields are automatically validated when data is entered e.g. dates. If you chose text for a date field, there will be no validation.

18 ©www.teach-ict.com Field Types Numeric fields are held differently from text fields. Calculations can only be performed on numeric, date or currency fields. Field length should be carefully chosen whilst creating the table to ensure that the size of the database is reasonable.


Download ppt "©www.teach-ict.com Relational Databases. ©www.teach-ict.com Entities Data is stored in tables. Each table is concerned with one entity An entity is a."

Similar presentations


Ads by Google