Relasjonsdatamodell i DBMS | Database Concepts & Eksempel
What is Relational Model?
Relasjonsmodell (RM) representerer databasen som en samling av relasjoner. En relasjon er ikke annet enn en verditabell. Hver rad i tabellen representerer en samling av relaterte dataverdier. Disse radene i tabellen angir en reell enhet eller relasjon.
The table name and column names are helpful to interpret the meaning of values in each row. The data are represented as a set of relations. In the relational model, data are stored as tables. However, the physical storage of the data is independent of the way the data are logically organized.
Some popular Relational Database management systems are:
- DB2 og Informix Dynamic Server โ IBM
- Oracle og RDB โ Oracle
- SQL Server og tilgang โ Microsoft
Relasjonsmodell Concepts i DBMS
- Egenskap: Each column in a Table. Attributes are the properties which define a relation. e.g., Student_Rollno, NAME,etc.
- tabeller โ I relasjonsmodellen lagres relasjoner i tabellformatet. Den lagres sammen med dens enheter. En tabell har to egenskaper rader og kolonner. Rader representerer poster og kolonner representerer attributter.
- tuppel โ It is nothing but a single row of a table, which contains a single record.
- Relasjonsskjema: A relation schema represents the name of the relation with its attributes.
- Grad: The total number of attributes which in the relation is called the degree of the relation.
- Cardinality: Totalt antall rader i tabellen.
- Column: The column represents the set of values for a specific attribute.
- Relation instance โ Relation instance is a finite set of tuples in the RDBMS system. Relation instances never have duplicate tuples.
- Relasjonsnรธkkel โ Every row has one, two or multiple attributes, which is called relation key.
- Attribute domain โ Every attribute has some pre-defined value and scope which is known as attribute domain
Relasjonelt Integrity begrensninger
Relasjonelt Integrity begrensninger i DBMS henvises til betingelser som mรฅ vรฆre tilstede for en gyldig relasjon. Disse relasjonelle begrensningene i DBMS er avledet fra reglene i miniverdenen som databasen representerer.
There are many types of Integrity Begrensninger i DBMS. Begrensninger pรฅ det relasjonelle databasestyringssystemet er for det meste delt inn i tre hovedkategorier:
- Domain Constraints
- Nรธkkelbegrensninger
- Referensielt Integrity begrensninger
Domain Constraints
Domenebegrensninger kan brytes hvis en attributtverdi ikke vises i det tilsvarende domenet, eller den ikke er av riktig datatype.
Domain constraints specify that within each tuple, and the value of each attribute must be unique. This is specified as data types which include standard data types integers, real numbers, characters, Booleans, variable length strings, etc.
Eksempel:
Create DOMAIN CustomerName CHECK (value not NULL)
The example shown demonstrates creating a domain constraint such that CustomerName is not NULL
Nรธkkelbegrensninger
Et attributt som unikt kan identifisere en tuppel i en relasjon kalles nรธkkelen til tabellen. Verdien av attributtet for forskjellige tupler i relasjonen mรฅ vรฆre unik.
Eksempel:
I den gitte tabellen er CustomerID et nรธkkelattributt i CustomerTable. Det er mest sannsynlig at det bare er รฉn nรธkkel for รฉn kunde, CustomerID =1 er bare for CustomerName = Google".
| Kunde ID | Kundenavn | status |
|---|---|---|
| 1 | Aktiv | |
| 2 | Amazon | Aktiv |
| 3 | Apple | inaktiv |
Referensielt Integrity begrensninger
Referensielt Integrity constraints in DBMS are based on the concept of Foreign Keys. A foreign key is an important attribute of a relation which should be referred to in other relationships. Referential integrity constraint state happens where relation refers to a key attribute of a different or same relation. However, that key element must exist in the table.
Eksempel:
I eksemplet ovenfor har vi 2 relasjoner, Kunde og Billing.
Tuple for CustomerID =1 is referenced twice in the relation Billing. Sรฅ vi vet Kundenavn=Google har faktureringsbelรธpet $300
Operasjoner i relasjonsmodellen
Fire grunnleggende oppdateringsoperasjoner utfรธrt pรฅ relasjonsdatabasemodellen er
Insert, update, delete and select.
- Insert is used to insert data into the relation
- Delete is used to delete tuples from the table.
- Modify allows you to change the values of some attributes in existing tuples.
- Select allows you to choose a specific range of data.
Nรฅr en av disse operasjonene brukes, mรฅ integritetsbegrensninger spesifisert pรฅ relasjonsdatabaseskjemaet aldri brytes.
innfelt Operasjon
The insert operation gives values of the attribute for a new tuple which should be inserted into a relation.
Oppdater Operasjon
You can see that in the below-given relation table CustomerName= โAppleโ is updated from Inactive to Active.
Delete Operasjon
For รฅ spesifisere sletting velger en betingelse pรฅ attributtene til relasjonen tuppelen som skal slettes.
In the above-given example, CustomerName= โAppleโ is deleted from the table.
The Delete operation could violate referential integrity if the tuple which is deleted is referenced by foreign keys from other tuples in the same database.
Velg Operasjon
I eksemplet ovenfor, CustomerName=โAmazonโ is selected
Beste praksis for รฅ lage en relasjonsmodell
- Data mรฅ representeres som en samling av relasjoner
- Each relation should be depicted clearly in the table
- Rows should contain data about instances of an entity
- Columns must contain data about attributes of the entity
- Cells of the table should hold a single value
- Each column should be given a unique name
- Ingen to rader kan vรฆre identiske
- The values of an attribute should be from the same domain
Fordeler med relasjonell databasemodell
- Enkelhet: A Relational data model in DBMS is simpler than the hierarchical and network model.
- Strukturell uavhengighet: The relational database is only concerned with data and not with a structure. This can improve the performance of the model.
- Lett รฅ bruke: Relasjonsmodellen i DBMS er enkel da tabeller som bestรฅr av rader og kolonner er ganske naturlige og enkle รฅ forstรฅ
- Query capability: It makes possible for a high-level query language like SQL for รฅ unngรฅ kompleks databasenavigasjon.
- Data independence: The Structure of Relational database can be changed without having to change any application.
- Skalerbar: Regarding a number of records, or rows, and the number of fields, a database should be enlarged to enhance its usability.
Ulemper med relasjonsmodell
- Few relational databases have limits on field lengths which canโt be exceeded.
- Relational databases can sometimes become complex as the amount of data grows, and the relations between pieces of data become more complicated.
- Komplekse relasjonsdatabasesystemer kan fรธre til isolerte databaser der informasjonen ikke kan deles fra ett system til et annet.
Sammendrag
- The Relational database modelling represents the database as a collection of relations (tables)
- Attribute, Tables, Tuple, Relation Schema, Degree, Cardinality, Column, Relation instance, are some important components of Relational Model
- Relasjonelt Integrity constraints are referred to conditions which must be present for a valid Relation approach in DBMS
- Domenebegrensninger kan brytes hvis en attributtverdi ikke vises i det tilsvarende domenet eller den ikke er av riktig datatype
- Insert, Select, Modify and Delete are the operations performed in Relational Model constraints
- The relational database is only concerned with data and not with a structure which can improve the performance of the model
- fordeler med Relational model in DBMS are simplicity, structural independence, ease of use, query capability, data independence, scalability, etc.
- Few relational databases have limits on field lengths which canโt be exceeded.






