Database - mysql. Contents Database –DBMS –Relational model SQL –MySQL.
Relational database model -report
-
Upload
kj-limbo -
Category
Technology
-
view
414 -
download
3
Transcript of Relational database model -report
![Page 1: Relational database model -report](https://reader035.fdocuments.net/reader035/viewer/2022062418/5561a019d8b42ae9708b46f1/html5/thumbnails/1.jpg)
RELATIONAL DATABASE MODEL:LOGICAL VIEW OF DATAANDKEYS
Karina Joyce E. LimboJedan TipuraBLIS-III
![Page 2: Relational database model -report](https://reader035.fdocuments.net/reader035/viewer/2022062418/5561a019d8b42ae9708b46f1/html5/thumbnails/2.jpg)
Logical View of Data
Logical simplicity yields simpler and more effective database design methodologies.
![Page 3: Relational database model -report](https://reader035.fdocuments.net/reader035/viewer/2022062418/5561a019d8b42ae9708b46f1/html5/thumbnails/3.jpg)
• The model was first proposed by E.F.Codd in 1970.
![Page 4: Relational database model -report](https://reader035.fdocuments.net/reader035/viewer/2022062418/5561a019d8b42ae9708b46f1/html5/thumbnails/4.jpg)
Entity
An entity is simply a person, place, event, or thing for which we intend to collect data.
Examples:❖ University -- Students, Faculty
Members, Courses❖ Airlines -- Pilots, Aircraft, Routes,
Supplier
![Page 5: Relational database model -report](https://reader035.fdocuments.net/reader035/viewer/2022062418/5561a019d8b42ae9708b46f1/html5/thumbnails/5.jpg)
Attributes
Each entity has certain characteristics known as attributes.
Examples:❖ Student -- Student Number, Name,
GPA, Date of Enrollment, Data of Birth, Home Address, Phone Number, Major
❖ Aircraft -- Aircraft Number, Data of Last Maintenance, Total Hours Flown, Hours Flown since Last Maintenance
![Page 6: Relational database model -report](https://reader035.fdocuments.net/reader035/viewer/2022062418/5561a019d8b42ae9708b46f1/html5/thumbnails/6.jpg)
Entities and Attributes
A grouping of related entities becomes an entity set.
Examples:❖ The STUDENT entity set contains all
student entities.❖ The FACULTY entity set contains all
faculty entities.❖ The AIRCRAFT entity set contains all
aircraft entities
![Page 7: Relational database model -report](https://reader035.fdocuments.net/reader035/viewer/2022062418/5561a019d8b42ae9708b46f1/html5/thumbnails/7.jpg)
Tables and Their Characteristics A table is perceived as a two-
dimensional structure composed of rows and columns.
Each table row (tuple) represents a single entity within the entity set.
Each column represents an attribute and each column has a distinct name.
Each row/column intersection represents a single data value
![Page 8: Relational database model -report](https://reader035.fdocuments.net/reader035/viewer/2022062418/5561a019d8b42ae9708b46f1/html5/thumbnails/8.jpg)
All values in a column must conform to the same data format.
Each column has a specific range of values known as the attribute domain.
The order of the rows and columns is immaterial to the DBMS
Each table must have an attribute or a combination of attributes that uniquely identifies each row.
![Page 9: Relational database model -report](https://reader035.fdocuments.net/reader035/viewer/2022062418/5561a019d8b42ae9708b46f1/html5/thumbnails/9.jpg)
Table Name: STUDENT
STU_NUM
STU_LNAME
STU_FNAME
STU_INIT
STU_DOB
STU_HRS STU_CLASS
STU_GPA
STU_TRANSFER
DEPT_CODE
STU_PHONE
PROF_NUM
321452 Bowser William C 12-Feb-1975
42 So 2.84 No BIOL 2134 205
324257 Smithson
Anne K 15-Nov-1981
81 Jr 3.27 Yes CIS 2256 222
324258 Brewer Juliette F 23-Aug-1969
36 So 2.26 Yes ACCT 2256 228
![Page 10: Relational database model -report](https://reader035.fdocuments.net/reader035/viewer/2022062418/5561a019d8b42ae9708b46f1/html5/thumbnails/10.jpg)
Relational Schema
![Page 11: Relational database model -report](https://reader035.fdocuments.net/reader035/viewer/2022062418/5561a019d8b42ae9708b46f1/html5/thumbnails/11.jpg)
Keys
It is an attribute that determines the values of other attributes within the entity.
![Page 12: Relational database model -report](https://reader035.fdocuments.net/reader035/viewer/2022062418/5561a019d8b42ae9708b46f1/html5/thumbnails/12.jpg)
The key’s role is based on a concept known as determination.
The shorthand notation for “A determines B” is A B. If A determines B, C and D, you write A B, C, D.
![Page 13: Relational database model -report](https://reader035.fdocuments.net/reader035/viewer/2022062418/5561a019d8b42ae9708b46f1/html5/thumbnails/13.jpg)
Example:
STU_NUM STU_LNAME, STU_FNAME, STU_INIT
![Page 14: Relational database model -report](https://reader035.fdocuments.net/reader035/viewer/2022062418/5561a019d8b42ae9708b46f1/html5/thumbnails/14.jpg)
Functional Dependence
Can be generalized to cover the case in which the determining attribute values occur more than once in a table.
![Page 15: Relational database model -report](https://reader035.fdocuments.net/reader035/viewer/2022062418/5561a019d8b42ae9708b46f1/html5/thumbnails/15.jpg)
Attribute A determines Attribute B (that is, B is functionally dependent on A) if all of the rows in the table that agree in value for attribute A also agree in value for attribute B.
![Page 16: Relational database model -report](https://reader035.fdocuments.net/reader035/viewer/2022062418/5561a019d8b42ae9708b46f1/html5/thumbnails/16.jpg)
STUDENT CLASSIFICATION
HOURS COMPLETED CLASSIFICATION
Less than 30 Fr
30-59 So
60-89 Jr
90 or more Sr
![Page 17: Relational database model -report](https://reader035.fdocuments.net/reader035/viewer/2022062418/5561a019d8b42ae9708b46f1/html5/thumbnails/17.jpg)
STU_HRS STU_CLASS
But specific number of hours is not dependent on the classification. In other words, the classification (STU_CLASS) does not determine one and only one value for completed hours (STU_HRS).
![Page 18: Relational database model -report](https://reader035.fdocuments.net/reader035/viewer/2022062418/5561a019d8b42ae9708b46f1/html5/thumbnails/18.jpg)
Key Attribute
Any attribute that is part of a key.
Examples:STU_LNAME,STU_FNAME,STU_INIT,STU_PHONE
STU_HRS,STU_CLASS
![Page 19: Relational database model -report](https://reader035.fdocuments.net/reader035/viewer/2022062418/5561a019d8b42ae9708b46f1/html5/thumbnails/19.jpg)
Relational Database Keys
Superkey An attribute (or combination of
attributes) that uniquely identifies each entity in a table.
![Page 20: Relational database model -report](https://reader035.fdocuments.net/reader035/viewer/2022062418/5561a019d8b42ae9708b46f1/html5/thumbnails/20.jpg)
Example:In the STUDENT table..
STU_NUMSTU_NUM, STU_LNAMESTU_NUM, STU_LNAME, STU_INIT
![Page 21: Relational database model -report](https://reader035.fdocuments.net/reader035/viewer/2022062418/5561a019d8b42ae9708b46f1/html5/thumbnails/21.jpg)
Candidate Key A minimal superkey. A superkey that
does not contain a subset of attributes that is itself a superkey.
![Page 22: Relational database model -report](https://reader035.fdocuments.net/reader035/viewer/2022062418/5561a019d8b42ae9708b46f1/html5/thumbnails/22.jpg)
STU_NUM,STU_LNAMEis a superkey, but it is not a candidate
key because STU_NUM by itself is a candidate key.
![Page 23: Relational database model -report](https://reader035.fdocuments.net/reader035/viewer/2022062418/5561a019d8b42ae9708b46f1/html5/thumbnails/23.jpg)
Controlled Redundancy
-makes the relational database work.-tables within the database share common attributes that enable the tables to be linked together.
![Page 24: Relational database model -report](https://reader035.fdocuments.net/reader035/viewer/2022062418/5561a019d8b42ae9708b46f1/html5/thumbnails/24.jpg)
Table Name: PRODUCT
Primary Key: PROD_CODE
Foreign key: VEND_CODE
Table Name: VENDOR link
Primary Key: VEND_CODE
Foreign key: none
PROD_CODE PROD_DESCRIPT PROD_PRICE PROD_ON_HAND
VEND_CODE
ZZXG245Q Steel tape, 12 ft. length 6.79 8 235
QER-34256 Sledge hammer, 16-lb. head
18.63 6 231
SRE-657UG Rat-tile file 2.99 15 232
VEND_CODE VEND_CONTACT VEND_AREACODE VEND_PHONE
232 Annalise Crystal
608 224-2134
231 James Johnson
615 123-4536
235 Henry Ortozo 615 899-3425
![Page 25: Relational database model -report](https://reader035.fdocuments.net/reader035/viewer/2022062418/5561a019d8b42ae9708b46f1/html5/thumbnails/25.jpg)
Primary Key
-is usually underlined.- A candidate key selected to uniquely identify all other attribute values in any given row.
![Page 26: Relational database model -report](https://reader035.fdocuments.net/reader035/viewer/2022062418/5561a019d8b42ae9708b46f1/html5/thumbnails/26.jpg)
Example:
VENDOR (VEND_CODE, VEND_CONTACT, VEND_AREACODE, VEND_PHONE)
PRODUCT (PROD_CODE, PROD_DESCRIPT, PROD_PRICE, PROD_ON_HAND, VEND_CODE)
![Page 27: Relational database model -report](https://reader035.fdocuments.net/reader035/viewer/2022062418/5561a019d8b42ae9708b46f1/html5/thumbnails/27.jpg)
Secondary Key
- An attribute used strictly for data retrieval purposes.
![Page 28: Relational database model -report](https://reader035.fdocuments.net/reader035/viewer/2022062418/5561a019d8b42ae9708b46f1/html5/thumbnails/28.jpg)
Example:
A customer date are stored in a CUSTOMER table. The customer number is the primary key; the secondary key is the combination of the customer’s last name and phone number.
![Page 29: Relational database model -report](https://reader035.fdocuments.net/reader035/viewer/2022062418/5561a019d8b42ae9708b46f1/html5/thumbnails/29.jpg)
Foreign Key
- An attribute in one table whose values must either match the primary key in another table or be null.
![Page 30: Relational database model -report](https://reader035.fdocuments.net/reader035/viewer/2022062418/5561a019d8b42ae9708b46f1/html5/thumbnails/30.jpg)
VENDOR
VEND_CODE VEND_CONTACT VEND_AREACODE VEND_PHONE
PRODUCT
PROD_CODE PROD_DESCRIPT PROD_PRICE PROD_ON_HAND VEND_CODE