relational databases
DESCRIPTION
Relational DatabasesTRANSCRIPT
![Page 1: Relational Databases](https://reader036.vdocument.in/reader036/viewer/2022082522/577cc75f1a28aba711a0bddd/html5/thumbnails/1.jpg)
1
Introduction to Relational Databases 1
![Page 2: Relational Databases](https://reader036.vdocument.in/reader036/viewer/2022082522/577cc75f1a28aba711a0bddd/html5/thumbnails/2.jpg)
2
Relational Databases As information needs grow and become
more complex, so to do methods of storing, managing and retrieving the data.
Database systems evolved to manage this information and data.
![Page 3: Relational Databases](https://reader036.vdocument.in/reader036/viewer/2022082522/577cc75f1a28aba711a0bddd/html5/thumbnails/3.jpg)
3
Relational Databases The relational model was developed in
1970 by E.F. Codd The basic data components in a
relational database are "entities" and their "attributes" and the basic logical structure is a "table".
![Page 4: Relational Databases](https://reader036.vdocument.in/reader036/viewer/2022082522/577cc75f1a28aba711a0bddd/html5/thumbnails/4.jpg)
4
Components Entities
A "thing" in a real world with an independent existence. Something about which you want to store data typically: a person, place, object, concept, or event.
![Page 5: Relational Databases](https://reader036.vdocument.in/reader036/viewer/2022082522/577cc75f1a28aba711a0bddd/html5/thumbnails/5.jpg)
5
Components Attributes
A characteristic of an entity or object. A detailed piece of information that describes an entity.
Tables Each table is a separate and independent
unit - although tables may be related
![Page 6: Relational Databases](https://reader036.vdocument.in/reader036/viewer/2022082522/577cc75f1a28aba711a0bddd/html5/thumbnails/6.jpg)
6
The Relational Database Model The simplest model for a database is a
flat file. You have only a single table which
includes fields for each element you need to store.
The problem with flat files is that they waste storage space and are problematic to maintain.
![Page 7: Relational Databases](https://reader036.vdocument.in/reader036/viewer/2022082522/577cc75f1a28aba711a0bddd/html5/thumbnails/7.jpg)
7
Flat Files Data redundancy
storing the same information in more than one file. E.g. a customers address stored in more than
one file. Data integrity
maintaining accurate data. If a customer’s address is changed will it be changed in all files? If not the data loses it’s integrity - it is inaccurate.
![Page 8: Relational Databases](https://reader036.vdocument.in/reader036/viewer/2022082522/577cc75f1a28aba711a0bddd/html5/thumbnails/8.jpg)
8
Example
Customers Customer Number Company Name Address City, State, Phone Number
Orders Order Number Order Date
Order Line Items Item Number Description Quantity Price
Each time an order is placed, you'll need to repeat the customer information, including the Customer Number, Company Name, etc.
A company which takes orders from many
customers
![Page 9: Relational Databases](https://reader036.vdocument.in/reader036/viewer/2022082522/577cc75f1a28aba711a0bddd/html5/thumbnails/9.jpg)
9
Solution The solution to this problem is to use a
relational model for the data. This means that in this example each
order entered is related to a customer record, and each line item is related to an order record.
![Page 10: Relational Databases](https://reader036.vdocument.in/reader036/viewer/2022082522/577cc75f1a28aba711a0bddd/html5/thumbnails/10.jpg)
10
Solution A relational database management
system (RDBMS) is a piece of software that manages groups of records which are related to one another.
![Page 11: Relational Databases](https://reader036.vdocument.in/reader036/viewer/2022082522/577cc75f1a28aba711a0bddd/html5/thumbnails/11.jpg)
11
Solution
Customers CustID CustName CustAddress CustCity CustState CustPhone
Orders OrdID OrdCustID OrdDate
OrderDetails ODID ODOrdID ODDescription ODQty ODPrice
![Page 12: Relational Databases](https://reader036.vdocument.in/reader036/viewer/2022082522/577cc75f1a28aba711a0bddd/html5/thumbnails/12.jpg)
12
Advantages of a RDMS All data is stored in the database Data redundancy is reduced Easier to maintain data integrity Eliminates the dependence between
programs and data. The database can operate as a stand
alone application.
![Page 13: Relational Databases](https://reader036.vdocument.in/reader036/viewer/2022082522/577cc75f1a28aba711a0bddd/html5/thumbnails/13.jpg)
13
Keys A key is simply a field which can be
used to identify a record. Primary key
A primary key is a field that uniquely identifies a record in a table.
No two records can have the same value for a primary key.
![Page 14: Relational Databases](https://reader036.vdocument.in/reader036/viewer/2022082522/577cc75f1a28aba711a0bddd/html5/thumbnails/14.jpg)
14
Keys Foreign Key
A foreign key represents the value of primary key for a related table.
Foreign keys are the cornerstone of relational databases.
![Page 15: Relational Databases](https://reader036.vdocument.in/reader036/viewer/2022082522/577cc75f1a28aba711a0bddd/html5/thumbnails/15.jpg)
15
Example
In the Customers Table, the CustID field will contain the data to uniquely identify a customer. This is the primary key.
In the Orders table, the OrdCustID field would hold the value of the CustID field for the customer who placed the order. This makes OrdCustID a foreign key
![Page 16: Relational Databases](https://reader036.vdocument.in/reader036/viewer/2022082522/577cc75f1a28aba711a0bddd/html5/thumbnails/16.jpg)
16
Solution
Customers CustID CustName CustAddress CustCity CustState CustPhone
Orders OrdID OrdCustID OrdDate
OrderDetails ODID ODOrdID ODDescription ODQty ODPrice
Primary Keys
Foreign KeysIn the Orders table, the OrdCustID field would hold the value of the CustID field for the customer who placed the order.
![Page 17: Relational Databases](https://reader036.vdocument.in/reader036/viewer/2022082522/577cc75f1a28aba711a0bddd/html5/thumbnails/17.jpg)
17
Referential Integrity This is a validity check
a set of rules that avoids data inconsistency. This means that a foreign key cannot be
entered into one table unless it matches a primary key in another
Referential integrity can also prevent the deletion of a record if the record has a primary key that matches foreign keys in another table.