Presentation is loading. Please wait.

Presentation is loading. Please wait.

Database elements. RHS – 2009 2 Database elements A database can be compared to an old- fashioned file cabinet –The entire canibet is the database –A.

Similar presentations


Presentation on theme: "Database elements. RHS – 2009 2 Database elements A database can be compared to an old- fashioned file cabinet –The entire canibet is the database –A."— Presentation transcript:

1 Database elements

2 RHS – Database elements A database can be compared to an old- fashioned file cabinet –The entire canibet is the database –A drawer is a table –A folder is a record –One piece of information is a field

3 RHS – Table A table contains data about one specific type of entity, and always on the same form Person NameAddressPhoneBornMarried Per JensenSkolevej No Jane HøstAllégade Yes Allan RavnSvinget Yes Ole OlsenJunivej Yes Ditte DorfmannDalstrøget No

4 RHS – Table A table should have a proper name, reflecting the type of entity stored in the table Some tables are directly related to entities, others are related to relations between entities A table definition consists of definitions of data fields, each with a name and type

5 RHS – Record A record is a single row in a specific table, containing information about a single entity Person NameAddressPhoneBornMarried Per JensenSkolevej No Jane HøstAllégade Yes Allan RavnSvinget Yes Ole OlsenJunivej Yes Ditte DorfmannDalstrøget No

6 RHS – Record All records in a specific table always has the same form All records in a specific table must be unique (have a key field) A key field consists of one or more fields in the table definition, the combination of which is always unique

7 RHS – Record What makes a Person unique…? Person NameAddressPhoneBornMarried Per JensenSkolevej No Jane HøstAllégade Yes Allan RavnSvinget Yes Ole OlsenJunivej Yes Ditte DorfmannDalstrøget No

8 RHS – Field A field is a single piece of information, about one specific entity in the table Person NameAddressPhoneBornMarried Per JensenSkolevej No Jane HøstAllégade Yes Allan RavnSvinget Yes Ole OlsenJunivej Yes Ditte DorfmannDalstrøget No

9 RHS – Field A field has a name and a type The type of the field should reflect the possible content of the field –String (text data) –Number (numeric data) –Date (dates, time) –Yes/No (binary choices) –Binary (picture, attached file,…)

10 RHS – Designing a database Designing a database looks fairly easy… Designing it correctly can be more challenging! Correctly: Avoid the two arch enemies of databases –Redundancy –Inconsistency

11 RHS – Designing a database Redundancy: the phenomenon that the same data occurs multiple times in the database –Makes the database unnecessarily large –Data processing becomes slower –Increases the risk of inconsistency

12 RHS – Designing a database NameAddressPhoneBornCourse Per JensenSkolevej English Per JensenSkolevej IT Ditte DorfmannDalstrøget English Ditte DorfmannDalstrøget Economics Ditte DorfmannDalstrøget Math Student

13 RHS – Designing a database IdNameAddressPhoneBorn 1Per JensenSkolevej Ditte DorfmannDalstrøget Student Enrollment IdCourse 1 English 1 IT 2 English 2 Economics 2 Math

14 RHS – Designing a database Inconsistency: the phenomenon, that some data is in conflict with each other. Not all data can be correct Which data should we trust then? If the database is free of redundancy, simple inconsistency cannot occur

15 RHS – Designing a database NameAddressPhoneBornCourse Per JensenSkolevej English Per JensenSkolevej IT Ditte DorfmannDalstrøget English Ditte DorfmannDalstrøget Economics Ditte DorfmannBakkehøj Math Student

16 RHS – Designing a database Exercise 1.We wish to construct a database for data about our friends. More specifically, we would like to store: Name, Address, Zipcode, Phone, , Marital status, date of last contact, and a picture (feel free to include more data if you wish) 2.A single table called Friend might be enough. Design such a table, including definitions of each data field needed in the table. Remember that the table should contain a key field 3.Look at your final table definition. Is there any danger of redundancy and/or inconsistency? 4.(If yes in 3.) Try to think of a better design, to eliminate the risk of redundancy and/or inconsistency? (Tip: you may need to include more tables in the database)


Download ppt "Database elements. RHS – 2009 2 Database elements A database can be compared to an old- fashioned file cabinet –The entire canibet is the database –A."

Similar presentations


Ads by Google