Chapter 2 part 1(Database System)
-
Upload
dolce-miera -
Category
Education
-
view
148 -
download
1
Transcript of Chapter 2 part 1(Database System)
![Page 1: Chapter 2 part 1(Database System)](https://reader034.fdocuments.in/reader034/viewer/2022051112/55a851581a28abb74f8b460e/html5/thumbnails/1.jpg)
![Page 2: Chapter 2 part 1(Database System)](https://reader034.fdocuments.in/reader034/viewer/2022051112/55a851581a28abb74f8b460e/html5/thumbnails/2.jpg)
By the end of this lesson, student will be able to:
2.1 Define database
2.2 Describe components of a database table
2.3 Describe the characteristics of relation scheme
2.4 Identify relation keys
2.5 Explain integrity rules
2.6 Explain relational model relationships
![Page 3: Chapter 2 part 1(Database System)](https://reader034.fdocuments.in/reader034/viewer/2022051112/55a851581a28abb74f8b460e/html5/thumbnails/3.jpg)
Database• A collection of related data• Shared collection of logically related data (and a description
of this data), designed to meet the information needs of an organization.
Data Known facts that can be recorded and have an implicit
meaning/ Raw facts; that is, facts that have not been yet processed to reveal their meaning to the end user.
Information Facts (data) that are arranged in meaningful patterns
![Page 4: Chapter 2 part 1(Database System)](https://reader034.fdocuments.in/reader034/viewer/2022051112/55a851581a28abb74f8b460e/html5/thumbnails/4.jpg)
![Page 5: Chapter 2 part 1(Database System)](https://reader034.fdocuments.in/reader034/viewer/2022051112/55a851581a28abb74f8b460e/html5/thumbnails/5.jpg)
Relational database is a collection of tables
Heading: table name and column names
Body: rows, occurrences of data
StdSSN StdLastName StdMajor StdClass StdGPA 123-45-6789 WELLS IS FR 3.00 124-56-7890 NORBERT FIN JR 2.70 234-56-7890 KENDALL ACCT JR 3.50
Student
![Page 6: Chapter 2 part 1(Database System)](https://reader034.fdocuments.in/reader034/viewer/2022051112/55a851581a28abb74f8b460e/html5/thumbnails/6.jpg)
![Page 7: Chapter 2 part 1(Database System)](https://reader034.fdocuments.in/reader034/viewer/2022051112/55a851581a28abb74f8b460e/html5/thumbnails/7.jpg)
• Typically include: 1) Numeric data types for integers and real numbers2) Characters3) Booleans4) Fixed-length strings5) Variable-length strings6) Date, time, timestamp7) Money / Currency8) Other special data types
![Page 8: Chapter 2 part 1(Database System)](https://reader034.fdocuments.in/reader034/viewer/2022051112/55a851581a28abb74f8b460e/html5/thumbnails/8.jpg)
Marina G. Erechtchoukova 8
Schema:Book (Bid: char(2), Title: char(50),
Author:char(20), Price: decimal(5,2)) Instance: Bid Title Author Price
11 Franklin forgets Bourgeois 7.00
22 Arthur and the Seventh-Inning Stretcher Krensky 14.00
33 Midnight Wrestlers Morgan 11.00
44 Midnight Pilot Morgan 9.00
55 Book of Science Activities 18.00
![Page 9: Chapter 2 part 1(Database System)](https://reader034.fdocuments.in/reader034/viewer/2022051112/55a851581a28abb74f8b460e/html5/thumbnails/9.jpg)
Yards
Yard Number
Owner
Address
Phone Number
1 2
3
4
![Page 10: Chapter 2 part 1(Database System)](https://reader034.fdocuments.in/reader034/viewer/2022051112/55a851581a28abb74f8b460e/html5/thumbnails/10.jpg)
![Page 11: Chapter 2 part 1(Database System)](https://reader034.fdocuments.in/reader034/viewer/2022051112/55a851581a28abb74f8b460e/html5/thumbnails/11.jpg)
1) What is the name of the relation?2) What is the cardinality of the relation?3) What is the degree of the relation?4) What is the domain of StdGPA? What is the
domain of StdSSN?
StdSSN StdLastName StdMajor StdClass StdGPA 123-45-6789 WELLS IS FR 3.00 124-56-7890 NORBERT FIN JR 2.70 234-56-7890 KENDALL ACCT JR 3.50
Student
![Page 12: Chapter 2 part 1(Database System)](https://reader034.fdocuments.in/reader034/viewer/2022051112/55a851581a28abb74f8b460e/html5/thumbnails/12.jpg)
Answer the question below based on the following tables:
LECTURER
Identify attribute, domain, tuple, and cardinality
StaffNum ICNum Name Posit ion Department PhoneNumIT001 781103-03-5333 Abdullah Pensyarah Kejuruteraan perisian 09-8840023
IT002 680923-11-4908 Maimunah Prof Madya Sains komputer 09-8840024IT003 801204-06-2323 Kamal Pensyarah Sistem maklumat 09-8840025IT004 600720-06-5380 Jamilah Prof Madya Multimedia 09-8840026IT005 590101-01-2425 Hakim Professor Kejuruteraan perisian 09-8840027IT006 810303-19-9923 Anis Pensyarah Multimedia 09-8840028
LECTURER
![Page 13: Chapter 2 part 1(Database System)](https://reader034.fdocuments.in/reader034/viewer/2022051112/55a851581a28abb74f8b460e/html5/thumbnails/13.jpg)
GRADE STUDENT
1) Identify attribute, domain, tuple, degree and cardinality for table GRADE & STUDENT.
2) Transform each table to relation schema.
StudentNum CourseCod
e
Grade
P1050 SK001 2.50
L2115 SM100 3.00
L4213 KP222 3.00
P2020 SM100 3.50
StudentNum Name CourseCode
P1050 Azura SK001
L2115 Chong SM100
L4213 Karim KP222
P2020 Ahmad SM100
![Page 14: Chapter 2 part 1(Database System)](https://reader034.fdocuments.in/reader034/viewer/2022051112/55a851581a28abb74f8b460e/html5/thumbnails/14.jpg)
1) Candidate key- Any set of one or more columns whose combined values are
unique among all occurrences (i.e., tuples or rows). - Since a null value is not guaranteed to be unique, no
component of a candidate key is allowed to be null. - There can be any number of candidate keys in a table .
2) Primary key- Any candidate key of that table which the database designer
arbitrarily designates as "primary".- The primary key may be selected for convenience,
comprehension, performance, or any other reasons.
![Page 15: Chapter 2 part 1(Database System)](https://reader034.fdocuments.in/reader034/viewer/2022051112/55a851581a28abb74f8b460e/html5/thumbnails/15.jpg)
3) Foreign key- A set of one or more columns in any table which may hold
the value(s) found in the primary key column(s) of some other table.
![Page 16: Chapter 2 part 1(Database System)](https://reader034.fdocuments.in/reader034/viewer/2022051112/55a851581a28abb74f8b460e/html5/thumbnails/16.jpg)
1) What is the candidate key ?2) What is the primary key?3) Transform the table to relation schema.
![Page 17: Chapter 2 part 1(Database System)](https://reader034.fdocuments.in/reader034/viewer/2022051112/55a851581a28abb74f8b460e/html5/thumbnails/17.jpg)
Identify the relational key available in each relation.
![Page 18: Chapter 2 part 1(Database System)](https://reader034.fdocuments.in/reader034/viewer/2022051112/55a851581a28abb74f8b460e/html5/thumbnails/18.jpg)
Data integrity means that the data values in the database are correct and consistent.
Integrity constraints provide a way of ensuring that changes made to the database by authorized users do not result in a loss of data consistency
Data integrity is enforced in the relational model by:
1) Entity integrity
2) Referential integrity
![Page 19: Chapter 2 part 1(Database System)](https://reader034.fdocuments.in/reader034/viewer/2022051112/55a851581a28abb74f8b460e/html5/thumbnails/19.jpg)
Entity Integrity- The entity integrity rule states that for every instance of an
entity, the value of the primary key must exist, be unique, and cannot be null.
- Without entity integrity, the primary key could not fulfill its role of uniquely identifying each instance of an entity.
Referential Integrity- The referential integrity rule states that every foreign key
value must match a primary key value in an associated table.
- Referential integrity ensures that we can correctly navigate between related entities.
![Page 20: Chapter 2 part 1(Database System)](https://reader034.fdocuments.in/reader034/viewer/2022051112/55a851581a28abb74f8b460e/html5/thumbnails/20.jpg)
1) One to many2) Many to many3) Self referencing
![Page 21: Chapter 2 part 1(Database System)](https://reader034.fdocuments.in/reader034/viewer/2022051112/55a851581a28abb74f8b460e/html5/thumbnails/21.jpg)
• One Birdfeeder is visited by Many Birds• One Yard contains Many Birdfeeders• One Patient has Many Prescriptions• One Insurance has Many Patients• One Student attends Many Classes
• One to Many relationships are the most common relationships.
• A record MUST be in the One table in order to appear in the Many table.
• One to Many includes One to None.
![Page 22: Chapter 2 part 1(Database System)](https://reader034.fdocuments.in/reader034/viewer/2022051112/55a851581a28abb74f8b460e/html5/thumbnails/22.jpg)
1 ∞Medical Record #
Patients Prescription Number
Medical Record #
Medications
Primary Key linked to Non Primary Key
Example 1:
![Page 23: Chapter 2 part 1(Database System)](https://reader034.fdocuments.in/reader034/viewer/2022051112/55a851581a28abb74f8b460e/html5/thumbnails/23.jpg)
Bird Feeders
Bird Feeder Number
Material
Location in Yard
Yard Number
Yards
Yard Number
Owner
Address
Phone Number
Each Birdfeeder can only be in one Yard, but each Yard can have many Birdfeeders. This is called a one to many (1 - ∞) Relationship.
![Page 24: Chapter 2 part 1(Database System)](https://reader034.fdocuments.in/reader034/viewer/2022051112/55a851581a28abb74f8b460e/html5/thumbnails/24.jpg)
• Many Students are taught by Many Teachers• Many Patients see Many Doctors• Many Medications are taken by Many Patients• Many Customers buy Many Products
Many to Many relationships are also very common.
![Page 25: Chapter 2 part 1(Database System)](https://reader034.fdocuments.in/reader034/viewer/2022051112/55a851581a28abb74f8b460e/html5/thumbnails/25.jpg)
∞ ∞Shands Medical Record #
Medicare Patients Prescription Number
Shands Medical Record #
Medications
Non Primary Key linked to Non Primary Key
Example:
Access sees this as an Indeterminate relationship
You cannot Enforce Referential Integrity
![Page 26: Chapter 2 part 1(Database System)](https://reader034.fdocuments.in/reader034/viewer/2022051112/55a851581a28abb74f8b460e/html5/thumbnails/26.jpg)
Indeterminate relationships are often found when we are linking tables, because Linked Tables cannot have a primary key.
If you have imported or created a table, it’s very rare to have a need for an indeterminate Relationship.
These relationships show Access that the data saved in the field from the first table is the same kind of data saved in the second table, but there can be no data integrity rules applied on indeterminate relationships.
![Page 27: Chapter 2 part 1(Database System)](https://reader034.fdocuments.in/reader034/viewer/2022051112/55a851581a28abb74f8b460e/html5/thumbnails/27.jpg)
ExamplesPatients
Patient ID
First
Last
Address
City
State
Zip
Medications
Med ID
Medication
Description
Patient Meds
PM ID
Patient ID
Med ID
Dosage
Directions
1
One Patient can take many
Medications∞
1
One Kind of Medication can be
taken by Many Patients
∞
![Page 28: Chapter 2 part 1(Database System)](https://reader034.fdocuments.in/reader034/viewer/2022051112/55a851581a28abb74f8b460e/html5/thumbnails/28.jpg)
ExamplesPatients
Patient ID
First
Last
Address
City
State
Zip
Primary Drs
Doc ID
Name
Phone
Pager
![Page 29: Chapter 2 part 1(Database System)](https://reader034.fdocuments.in/reader034/viewer/2022051112/55a851581a28abb74f8b460e/html5/thumbnails/29.jpg)
ExamplesPatients
Patient ID
First
Last
Address
City
State
Zip
Primary Drs
Doc ID
Name
Phone
Pager
One Patient will have only ONE primary Doctor.One Primary Doctor can have MANY patients.
Primary Doc
1
∞
![Page 30: Chapter 2 part 1(Database System)](https://reader034.fdocuments.in/reader034/viewer/2022051112/55a851581a28abb74f8b460e/html5/thumbnails/30.jpg)
ExamplesPatients
Patient ID
First
Last
Address
City
State
Zip
Med History
Patient ID
Health Q1
Health Q2
Health Q3
Health Q4
![Page 31: Chapter 2 part 1(Database System)](https://reader034.fdocuments.in/reader034/viewer/2022051112/55a851581a28abb74f8b460e/html5/thumbnails/31.jpg)
ExamplesPatients
Patient ID
First
Last
Address
City
State
Zip
Med History
Patient ID
Health Q1
Health Q2
Health Q3
Health Q4
One Patient will have only ONE Medical History.Each Medical History will belong to only ONE patient.
11