3. Relational Databases
3.01 Introduction
A relational database implements the Relational Model. By model we mean by model is that it serves as an abstraction to the complex real-world. Usually we will abstract data.
A relation, as defined by E. F. Codd., is a set of tuples (d1; : : : ; dn) where each element dj is a member of Dj.
A relation is approximately a table – so a relational database uses tables to represent data.
Relational Databases are an implementation of Relational Algebra, a theory for modelling data and defining queries on such data.
The following summarises a set of rules for Relational Databases.
- Everything is a relation
- All operations use the relational model
- All data is represented and accessed as relations
- Table and database structure is accessed and altered as relations
- The system is unaffected by its implementation
- If the hardware changes
- If the operating system changes
- If the discs are replaced
- If data is distributed
The Relational Model is not the same as the Entity Relationship Model. An ER Model helps us model concepts, usually as part of the design of a Relational Database. SQL is a standard that attempts to implement the Relational Model.
3.02 Drawing a database: Basic Entity-Relationship diagrams
Some terms we need to know.
- An entity is the thing we want to model. It must be uniquely identifiable and it may have attributes.
- Attributes are information that describe an aspect of an entity.
- A relationship is a connection or dependency between two entities.
How do we draw an entity? An entity is basically a box, with a word in it. eg:
An attribute is similar but we use an ellipse instead.
So to show an entity with an attribute we simply show them both with a line between the two.
In a database design you would see a box with lots of ellipses coming off it, because an entity would have many different attributes.
To show a relationship we draw a diamond, like this:
As we mentioned above, a relationship is a connection or dependency between two entities. So we can draw lines connecting entities to the relationship, like this:
We use words like “has student” to describe the relationship. In a simple example like this we could use “teaches”, etc – whatever it is that describes the relationship. You can give it a name that’s useful to you.
Tuesday 26 October 2021, 506 views
Next post: 4. Introduction to SQL Previous post: 2. What shape is your data?
Databases and Advanced Data Techniques index
- 26. A very good guide to linked data
- 25. Information Retrieval
- 24. Triplestores and SPARQL
- 23. Ontologies – RDF Schema and OWL
- 22. RDF – Remote Description Framework
- 21. Linked Data – an introduction
- 20. Transforming XML databases
- 19. Semantic databases
- 18. Document databases and MongoDB
- 17. Key/Value databases and MapReduce
- 16. Distributed databases and alternative database models
- 15. Query efficiency and denormalisation
- 14. Connecting to SQL in other JS and PHP
- 13. Grouping data in SQL
- 12. SQL refresher
- 11. Malice and accidental damage
- 10. ACID: Guaranteeing a DBMS against errors
- 9. Normalization example
- 8. Database normalization
- 7. Data integrity and security
- 6. Database integrity
- 5. Joins in SQL
- 4. Introduction to SQL
- 3. Relational Databases
- 2. What shape is your data?
- 1. Sources of data
Leave a Reply