Before Starting Data Integrity Data Types Record (line, tupel) Field (attribute, column) Table...
-
Upload
amie-shields -
Category
Documents
-
view
215 -
download
2
Transcript of Before Starting Data Integrity Data Types Record (line, tupel) Field (attribute, column) Table...
![Page 1: Before Starting Data Integrity Data Types Record (line, tupel) Field (attribute, column) Table (file, relation) Data Dictionary (repository, metadata)](https://reader036.fdocuments.in/reader036/viewer/2022071807/56649e495503460f94b3bf76/html5/thumbnails/1.jpg)
Before Starting• Data Integrity• Data Types• Record (line, tupel)• Field (attribute, column)• Table (file, relation)• Data Dictionary (repository, metadata)• Backup & Recovery• DataWarehouse, DataMart, DataMining
![Page 2: Before Starting Data Integrity Data Types Record (line, tupel) Field (attribute, column) Table (file, relation) Data Dictionary (repository, metadata)](https://reader036.fdocuments.in/reader036/viewer/2022071807/56649e495503460f94b3bf76/html5/thumbnails/2.jpg)
Database Design Guidelines
• What is the purpose of the database?
• Design the tables (ERD on paper)
• Decide which fields to include for each table (datadictionary)
• Create the relationships between tables
• And then start the implementation
![Page 3: Before Starting Data Integrity Data Types Record (line, tupel) Field (attribute, column) Table (file, relation) Data Dictionary (repository, metadata)](https://reader036.fdocuments.in/reader036/viewer/2022071807/56649e495503460f94b3bf76/html5/thumbnails/3.jpg)
CASE 1
Bogus University hired you to design a database for them. They would like to keep track of each student, classes, and rooms so that they would like to be able to find which student is taking which classes or which room is available on a given day, etc. Assume each class can only be thought by a single instructor.
![Page 4: Before Starting Data Integrity Data Types Record (line, tupel) Field (attribute, column) Table (file, relation) Data Dictionary (repository, metadata)](https://reader036.fdocuments.in/reader036/viewer/2022071807/56649e495503460f94b3bf76/html5/thumbnails/4.jpg)
Design the Tables
Students Classes
Rooms ???
![Page 5: Before Starting Data Integrity Data Types Record (line, tupel) Field (attribute, column) Table (file, relation) Data Dictionary (repository, metadata)](https://reader036.fdocuments.in/reader036/viewer/2022071807/56649e495503460f94b3bf76/html5/thumbnails/5.jpg)
Decide which fields to include for each table
StudentsStudent_ID, Student_Name, Student_Phone, Student_Address
ClassesClass_ID, Class_Name, Credits, Instructor, Prerequisite, Days, Time, Room_ID
RoomsRoom_ID, Building, Number
???
![Page 6: Before Starting Data Integrity Data Types Record (line, tupel) Field (attribute, column) Table (file, relation) Data Dictionary (repository, metadata)](https://reader036.fdocuments.in/reader036/viewer/2022071807/56649e495503460f94b3bf76/html5/thumbnails/6.jpg)
Create the relationships between tables
• Determine the relationship types first.• One-To-One
• One-To-Many
• Many-To-Many
• Resolve Many-To-Many relationship in 2 One-To-Many relationships
• Keep on asking yourself “One … can (have, teach, purchase, etc.) many …, but one …cannot (have, teach, purchase, etc.) many …
![Page 7: Before Starting Data Integrity Data Types Record (line, tupel) Field (attribute, column) Table (file, relation) Data Dictionary (repository, metadata)](https://reader036.fdocuments.in/reader036/viewer/2022071807/56649e495503460f94b3bf76/html5/thumbnails/7.jpg)
Create the relationships between tables (Cont’d)
• Select Primary Keys for each table among the Candidates and place the Foreign Keys into tables if necessary.
![Page 8: Before Starting Data Integrity Data Types Record (line, tupel) Field (attribute, column) Table (file, relation) Data Dictionary (repository, metadata)](https://reader036.fdocuments.in/reader036/viewer/2022071807/56649e495503460f94b3bf76/html5/thumbnails/8.jpg)
Tables
![Page 9: Before Starting Data Integrity Data Types Record (line, tupel) Field (attribute, column) Table (file, relation) Data Dictionary (repository, metadata)](https://reader036.fdocuments.in/reader036/viewer/2022071807/56649e495503460f94b3bf76/html5/thumbnails/9.jpg)
Relationships
![Page 10: Before Starting Data Integrity Data Types Record (line, tupel) Field (attribute, column) Table (file, relation) Data Dictionary (repository, metadata)](https://reader036.fdocuments.in/reader036/viewer/2022071807/56649e495503460f94b3bf76/html5/thumbnails/10.jpg)
CASE 2
Sham Bookstore wants you to design a database to keep records of the books they have, their authors, and their publishers. Assume that each book can be published by a single publisher and the order of authors does not matter.
![Page 11: Before Starting Data Integrity Data Types Record (line, tupel) Field (attribute, column) Table (file, relation) Data Dictionary (repository, metadata)](https://reader036.fdocuments.in/reader036/viewer/2022071807/56649e495503460f94b3bf76/html5/thumbnails/11.jpg)
Design the Tables
Books Authors
Publishers ???
![Page 12: Before Starting Data Integrity Data Types Record (line, tupel) Field (attribute, column) Table (file, relation) Data Dictionary (repository, metadata)](https://reader036.fdocuments.in/reader036/viewer/2022071807/56649e495503460f94b3bf76/html5/thumbnails/12.jpg)
Decide which fields to include for each table
BooksISBN, Book_Name, Pages
AuthorsAuthor_ID, Author_Name
PublishersPublisher_ID, Pub_Name, Pub_Phone, Pub_Address
???
![Page 13: Before Starting Data Integrity Data Types Record (line, tupel) Field (attribute, column) Table (file, relation) Data Dictionary (repository, metadata)](https://reader036.fdocuments.in/reader036/viewer/2022071807/56649e495503460f94b3bf76/html5/thumbnails/13.jpg)
Create the relationships between tables
• Can one book be published by many publishers?
• Can one publisher publish many books?
• Can one book have many authors?
• Can one author have many books?Aha!.
![Page 14: Before Starting Data Integrity Data Types Record (line, tupel) Field (attribute, column) Table (file, relation) Data Dictionary (repository, metadata)](https://reader036.fdocuments.in/reader036/viewer/2022071807/56649e495503460f94b3bf76/html5/thumbnails/14.jpg)
Tables
![Page 15: Before Starting Data Integrity Data Types Record (line, tupel) Field (attribute, column) Table (file, relation) Data Dictionary (repository, metadata)](https://reader036.fdocuments.in/reader036/viewer/2022071807/56649e495503460f94b3bf76/html5/thumbnails/15.jpg)
Relationships
![Page 16: Before Starting Data Integrity Data Types Record (line, tupel) Field (attribute, column) Table (file, relation) Data Dictionary (repository, metadata)](https://reader036.fdocuments.in/reader036/viewer/2022071807/56649e495503460f94b3bf76/html5/thumbnails/16.jpg)
SQLStructured Query Language
SELECT fieldname1, fieldname2…fieldnameN
FROM table1, table2…tableM
WHERE (Table Joins)
AND (any specifications, eg. students living in Balto City.)
GROUP BY (used if an aggregate function exist in select clause)
HAVING (any specifications about aggregate functions)
ORDER BY fieldname2, fieldname1;
![Page 17: Before Starting Data Integrity Data Types Record (line, tupel) Field (attribute, column) Table (file, relation) Data Dictionary (repository, metadata)](https://reader036.fdocuments.in/reader036/viewer/2022071807/56649e495503460f94b3bf76/html5/thumbnails/17.jpg)
SQL Examples
List all student names and phone #s in alphabetical order
SELECT Student_Name, Student_Phone
FROM Students
ORDER BY Student_Name;
![Page 18: Before Starting Data Integrity Data Types Record (line, tupel) Field (attribute, column) Table (file, relation) Data Dictionary (repository, metadata)](https://reader036.fdocuments.in/reader036/viewer/2022071807/56649e495503460f94b3bf76/html5/thumbnails/18.jpg)
SQL ExamplesList all student names and phone #s of students whose ID is larger than 233000 in descending alphabetical order
SELECT Student _ID, Student_Name, Student_PhoneFROM StudentsWHERE Student_ID > 233000ORDER BY Student_Name;
![Page 19: Before Starting Data Integrity Data Types Record (line, tupel) Field (attribute, column) Table (file, relation) Data Dictionary (repository, metadata)](https://reader036.fdocuments.in/reader036/viewer/2022071807/56649e495503460f94b3bf76/html5/thumbnails/19.jpg)
SQL Examples
List all book names and publisher names
SELECT Book_Name, Pub_Name
FROM Books, Publishers
WHERE Books.Publisher_ID = Publishers.Publisher_ID;
![Page 20: Before Starting Data Integrity Data Types Record (line, tupel) Field (attribute, column) Table (file, relation) Data Dictionary (repository, metadata)](https://reader036.fdocuments.in/reader036/viewer/2022071807/56649e495503460f94b3bf76/html5/thumbnails/20.jpg)
SQL Examples
List all book names and publisher names of books smaller than 300 pages.
SELECT Book_Name, Pub_Name
FROM Books, Publishers
WHERE Books.Publisher_ID = Publishers.Publisher_ID
AND Pages < 300;