SlideShare a Scribd company logo
Copyright © 2009 Bahn, D., Tang, H. & Yardley, A. All Rights Reserved. ISBN: 978-1-936203-01-7



                             Systems Analysis and Design
                              Learning Module Series #1
                                  Document version

Creating a Relational Database
Overview
In this tutorial we will create a relational database file comprised of two tables linked together in a one-to-many
relationship. These tables may be components of a database that manages student registrations for one or more
sections pertaining to a given course. The two tables, then, will be a Course Table and a Sections Table, such
that a Section-to-Course relationship exists between them. Since one course can contain many sections, the
relationship is one of one-to-many, which in database language is expressed as a relationship having a
maximum cardinality of 1:N.

We will therefore, initialize a new database file in MS Access 2007, create two tables, link or join the tables
together, and perform some create, update and delete tasks to observe what happens as a result of each.


Section I: Database Design
Initializing a New Database file in MS Access 2007

   1. At the Getting Stared with Microsoft Access screen click on New Blank Database.




   2.     In the File Name text box, name your database Course Database and click on the Folder (right) to set
         the destination folder. Note: The *.accdb extension is added automatically by the wizard. Click Create.




                                                         1
Copyright © 2009 Bahn, D., Tang, H. & Yardley, A. All Rights Reserved. ISBN: 978-1-936203-01-7




3. Under the All Tables pane, right click on Table1 : Table and select Design View from the drop down
   menu . (In the Save As dialog box, under Table Name, type Course and click OK .

                                                                           




4. (a) Under the Field Name pane, enter column (or field) names as follows: course_ID (primary key),
       subject, course_title, credits, and grading_method.

      (b) Under Section tab, under Data Type, click the down-arrow for the course_ID to select Text

         Notice the yellow key indicating that “course_ID” is the Primary Key. This key is set by default
         to the first row in the table




5.    From the Table Tools palette, select the Create tab, and click on Table.

                                                     2
Copyright © 2009 Bahn, D., Tang, H. & Yardley, A. All Rights Reserved. ISBN: 978-1-936203-01-7




6. Under the All Tables pane, right click on Table1 : Table and select Design View from the drop down
   menu . (In the Save As dialog box, under Table Name, type Section and click OK .

                                                                             




7. (a) Under the Section tab, under Field Name, enter Field (or column) names as follows: section_ID
   (primary key), course_ID (foreign key), location, employee_ID, and day_of_week.

      (b) Under Section tab, under Data Type, click the down-arrow for the section_ID to select Text.




8. On the main File Menu, click the Save button (Highlighted above in red box).


                                                    3
Copyright © 2009 Bahn, D., Tang, H. & Yardley, A. All Rights Reserved. ISBN: 978-1-936203-01-7


9. Right click on the Section tab and select Close All to close all tabs. Click Yes at the confirmation “Do you
   want to save changes…” dialog box.




                                                      4
Copyright © 2009 Bahn, D., Tang, H. & Yardley, A. All Rights Reserved. ISBN: 978-1-936203-01-7




Section II: Adding Data to the Tables

 1. Under All Tables, double-click on Course : Table. Enter the data as shown below.




 1. When you are done, right-click on the Course tab and click Save on the drop down menu.




 2. Under All Tables, double-click on Section : Table. Enter the data as shown below.




 3. When you are done, right-click on the Section tab and click Save on the drop down menu.




                                                  5
Copyright © 2009 Bahn, D., Tang, H. & Yardley, A. All Rights Reserved. ISBN: 978-1-936203-01-7




4.    From the Table Tools palette, select the Database Tools tab, and click on Relationships




5.    If the Show Table window doesn’t automatically appear, click the Show Table button.




6.     Click on course to highlight it, and click the Add button (below left); then click on section to highlight
      it, and click the Add button (below right).




                                                       6
Copyright © 2009 Bahn, D., Tang, H. & Yardley, A. All Rights Reserved. ISBN: 978-1-936203-01-7




Referential Integrity
Referential Integrity in a relational database describes consistency between related tables.

In this section, we explore the following:

     What happens and what it means to relate two tables together without enforcing Referential Integrity

     What happens and what it means to relate two tables together in a One-to-Many relationship Enforcing
      Referential Integrity, but without enforcing Cascade Update Related Fields or Cascade Delete Related
      Records
     What happens and what it means to relate two tables together in a One-to-Many relationship enforcing
      Referential Integrity and enforcing Cascade Update Related Fields

     What happens and what it means to relate two tables together in a One-to-Many relationship enforcing
      Referential Integrity and enforcing Cascade Delete Related Records




Section III:
Update, modify and delete observations …

(a) Without Referential Integrity

Let us examine what happens and what it means to relate two tables together without Enforcing Referential
Integrity, i.e. leaving this checkbox unchecked.




             Important: If you are going to try this “hands-on”…

                 Save a copy of your working database now!!!


                                                        7
Copyright © 2009 Bahn, D., Tang, H. & Yardley, A. All Rights Reserved. ISBN: 978-1-936203-01-7




1. Now, we notice that the “course_ID”, which is the primary key in the Course table can be matched to
   “course_ID” in the Section table, which can be considered a foreign key in the Section table. Click
   course_ID in the Course Table and drag it over course_ID in the Section Table.




2. The Edit Relationships window displays. In the Edit Relationships window, confirm that course_ID
   appears on both sides of the join.

           Notice the Unchecked “Enforce Referential Integrity” checkbox.




                                                     8
Copyright © 2009 Bahn, D., Tang, H. & Yardley, A. All Rights Reserved. ISBN: 978-1-936203-01-7




3. Click Create. Notice that the join is represented by a simple black line and does not indicate the One-to-
   Many relationship.




4.    In the course table, locate the entry for << course_ID BIO123 >> and click on the blue square of the row to
     highlight it (see red arrow below).




5.    Right-click anywhere on the row and select Delete Record from the drop down menu.




                                                        9
Copyright © 2009 Bahn, D., Tang, H. & Yardley, A. All Rights Reserved. ISBN: 978-1-936203-01-7


6.   Notice that top record is now BIO124 and the database warns that You are about to delete 1
     record(s).

        Confirm that you are working on a copy of your database, and click Yes to delete the record.




7.   Now open the Section Table in the database.

     Notice that sections 123-01 and 123-02 still exist in the section table even though the course BIO123
     they relate to, no longer exists! Since we did not enforce referential integrity between the coupled
     tables, there is now an inconsistency between them due to the deletion that took place on the Course Table.




(b) With Referential Integrity
       Let us now examine what happens and what it means to relate two tables together in a One-to-Many
       relationship with referential integrity, but without enforcing Cascade Update Related Fields or
       Cascade Delete Related Records.




                                                      10
Copyright © 2009 Bahn, D., Tang, H. & Yardley, A. All Rights Reserved. ISBN: 978-1-936203-01-7




8. Double click on the black line (above) joining the two tables. The Edit Relationships window displays.
9. In the Edit Relationships window, click the drop down arrow under Table/Query and select Course from
   the drop down menu.




10. Confirm that the relationships appear as shown below and check Enforce Referential Integrity (leaving
    the other two check boxes unchecked) and click OK.
11.




                                                   11
Copyright © 2009 Bahn, D., Tang, H. & Yardley, A. All Rights Reserved. ISBN: 978-1-936203-01-7




   Notice that the black line (below) representing the join between the tables now reflects the One-to-Many
   relationship between the coupled tables. Theoretically, this relationship is a function of a business rule or
   another such constraint; one course can have many associated sections, but any given section can only have
   one associated course. As far as database is concerned, however, this relationship is implemented by the
   Enforcing of Referential Integrity.

   The end of the line that connects to the Course Table is now designated with a “1” – indicating that this
   table is the parent table, which can have many children. The end of the line that connects to the Section
   Table is designated with “∞” – indicating that this table is the child table, which can only have one parent.
   Thus, one course can have one or more associated sections, but any given section can only have one
   associated course.




12. Right-click on the Relationship tab and select Close from the drop down menu. If the “Do you want to
    save changes to the layout of „Relationships‟?” dialog box appears, click Yes.




13. Try to add (Update) a new row in the Section Table. Click on the next available row in the table, enter
    the complete row for << Section 600-01 >> as shown below and click Enter.




                                                      12
Copyright © 2009 Bahn, D., Tang, H. & Yardley, A. All Rights Reserved. ISBN: 978-1-936203-01-7




      Since << course_ID MKT600 >> does not exist in the Course Table, the DBMS returns the following
      error:




  This is because of the Enforce Referential Integrity setting that we applied in step 10. Since there is no
  record of << course_ID MKT600 >> in the Course table, referential integrity prevents us from adding
  (Updating) this row in the Section Table until we first add it to the Course table.

  To put this in plain English: We cannot create a section for a course which does not exist.
14. Click once on the blue square of the row for course_ID BIO123 to highlight it. Then right-click
    anywhere on the row and select Delete Record from the drop down menu.




      The DBMS returns the following error:



                                                     13
Copyright © 2009 Bahn, D., Tang, H. & Yardley, A. All Rights Reserved. ISBN: 978-1-936203-01-7




Since the course here (course_ID BIO123) has existing and related sections in the Section Table, (namely,
Section 123-01 and Section 123-02) the DBMS must prevent the course from being deleted until all related
sections have first been deleted. This is because the “sections” are existence-dependent entities with respect to
“courses”. A course may exist without a section, but a section cannot exist without a course.

       To put this in plain English: We cannot delete a course for which a section exists.




15. In the Course Table, if we try to Modify the record for BIO123, changing it to BIO999 …



        The DBMS returns the following error:




       Again since << course_ID BIO123 >> has existing and related sections in the Section Table, the DBMS
       must prevent the course_ID from being modified until all related sections have first been deleted.


(c ) With Cascade Updated Related Fields



                                                        14
Copyright © 2009 Bahn, D., Tang, H. & Yardley, A. All Rights Reserved. ISBN: 978-1-936203-01-7




16. Double click on the black line (above) joining the two tables. The Edit Relationships window displays.

17. In the Edit Relationships window, click the drop down arrow under Table/Query and select Course from
    the drop down menu.




18. In the Edit Relationships window, confirm that Enforce Referential Integrity is checked, check the
    Cascade Updated Related Fields check box and click OK.




19. Double-click on the course table to modify the Course Table. Click on the row for <<course_ID BIO123>>
    and modify it to read BIO999. Right click on the Course Table tab, and select Save from the drop down
    menu.
                                                     15
Copyright © 2009 Bahn, D., Tang, H. & Yardley, A. All Rights Reserved. ISBN: 978-1-936203-01-7




20. Now click on the Section Table tab. Notice that the records for Section 123-01 and Section 123-02 have
    been updated under the course_ID column, to reflect their modified associated course BIO999.




(d) With Cascade Deleted Related Fields




21. Double click on the black line (above) joining the two tables. The Edit Relationships window displays.

22. In the Edit Relationships window, click the drop down arrow under Table/Query and select Course from
    the drop down menu.


                                                     16
Copyright © 2009 Bahn, D., Tang, H. & Yardley, A. All Rights Reserved. ISBN: 978-1-936203-01-7




23. In the Edit Relationships window, confirm that Enforce Referential Integrity is checked, check the
    Cascade Deleted Related Records check box and click OK. (All three may be checked here).




24. Double-click on the course table to modify the Course Table. Click on the blue square to select and
    highlight the row for << course_ID BIO999 >> right click anywhere on the row and select Delete Record
    from the drop down menu.

  Note: This row originally was named BIO123 but was modified to BIO999 in the previous section.




                                                    17
Copyright © 2009 Bahn, D., Tang, H. & Yardley, A. All Rights Reserved. ISBN: 978-1-936203-01-7




25. Click Yes to confirm that want to delete these records…




26. Click on the Section Table tab to notice that Section 123-01 and Sections 123-02 have been deleted.




                                                     18
Copyright © 2009 Bahn, D., Tang, H. & Yardley, A. All Rights Reserved. ISBN: 978-1-936203-01-7




          This completes the documentation for


                     Systems Analysis and Design
                      Learning Module Series #1
                          Document version

Creating a Relational Database




                                              19

More Related Content

Similar to S1 relational database pdf

S2 intersection table pdf
S2  intersection table pdfS2  intersection table pdf
S2 intersection table pdfaviy1966
 
S5 elementary erd pdf
S5 elementary erd pdfS5 elementary erd pdf
S5 elementary erd pdfaviy1966
 
S6 advanced issues in erd pdf
S6 advanced issues in erd pdfS6 advanced issues in erd pdf
S6 advanced issues in erd pdfaviy1966
 
Operate Spreadsheet applications ppt.pptx
Operate Spreadsheet applications ppt.pptxOperate Spreadsheet applications ppt.pptx
Operate Spreadsheet applications ppt.pptx
Esubalew21
 
Module 08 Access & Use Database Application.pptx
Module 08 Access & Use Database Application.pptxModule 08 Access & Use Database Application.pptx
Module 08 Access & Use Database Application.pptx
Esubalew21
 
PreviewAAPPENDIXOnce you have .docx
PreviewAAPPENDIXOnce you have .docxPreviewAAPPENDIXOnce you have .docx
PreviewAAPPENDIXOnce you have .docx
ChantellPantoja184
 
PreviewAAPPENDIXOnce you have .docx
PreviewAAPPENDIXOnce you have .docxPreviewAAPPENDIXOnce you have .docx
PreviewAAPPENDIXOnce you have .docx
harrisonhoward80223
 
lecture 5
 lecture 5 lecture 5
lecture 5
umardanjumamaiwada
 
Creating a repository using the oracle business intelligence administration tool
Creating a repository using the oracle business intelligence administration toolCreating a repository using the oracle business intelligence administration tool
Creating a repository using the oracle business intelligence administration tool
Ravi Kumar Lanke
 
Database Course Project-Usage Documentation
Database Course Project-Usage DocumentationDatabase Course Project-Usage Documentation
Database Course Project-Usage DocumentationJustin Tate
 
Acccesss notes
Acccesss notesAcccesss notes
Acccesss notes
art02
 
Access2003
Access2003Access2003
Access2003tanik363
 
Access2003
Access2003Access2003
Access2003mrh1222
 
Creating relationships with tables
Creating relationships with tablesCreating relationships with tables
Creating relationships with tablesJhen Articona
 
Basic interview questions for skills tests
Basic interview questions for skills testsBasic interview questions for skills tests
Basic interview questions for skills tests
Durga Balaji M
 
B.sc i agri u 4 introduction to ms access
B.sc i agri u 4 introduction to ms accessB.sc i agri u 4 introduction to ms access
B.sc i agri u 4 introduction to ms access
Rai University
 
B.sc i micro bio u 4 introduction to ms access
B.sc i micro bio u 4 introduction to ms accessB.sc i micro bio u 4 introduction to ms access
B.sc i micro bio u 4 introduction to ms access
Rai University
 
B.sc i bio tech u 4 introduction to ms access
B.sc i bio tech u 4 introduction to ms accessB.sc i bio tech u 4 introduction to ms access
B.sc i bio tech u 4 introduction to ms access
Rai University
 
B.sc i bio chem u 4 introduction to ms access
B.sc i bio chem u 4 introduction to ms accessB.sc i bio chem u 4 introduction to ms access
B.sc i bio chem u 4 introduction to ms access
Rai University
 
B.sc i cs u 4 introduction to ms access
B.sc i cs u 4 introduction to ms accessB.sc i cs u 4 introduction to ms access
B.sc i cs u 4 introduction to ms access
Rai University
 

Similar to S1 relational database pdf (20)

S2 intersection table pdf
S2  intersection table pdfS2  intersection table pdf
S2 intersection table pdf
 
S5 elementary erd pdf
S5 elementary erd pdfS5 elementary erd pdf
S5 elementary erd pdf
 
S6 advanced issues in erd pdf
S6 advanced issues in erd pdfS6 advanced issues in erd pdf
S6 advanced issues in erd pdf
 
Operate Spreadsheet applications ppt.pptx
Operate Spreadsheet applications ppt.pptxOperate Spreadsheet applications ppt.pptx
Operate Spreadsheet applications ppt.pptx
 
Module 08 Access & Use Database Application.pptx
Module 08 Access & Use Database Application.pptxModule 08 Access & Use Database Application.pptx
Module 08 Access & Use Database Application.pptx
 
PreviewAAPPENDIXOnce you have .docx
PreviewAAPPENDIXOnce you have .docxPreviewAAPPENDIXOnce you have .docx
PreviewAAPPENDIXOnce you have .docx
 
PreviewAAPPENDIXOnce you have .docx
PreviewAAPPENDIXOnce you have .docxPreviewAAPPENDIXOnce you have .docx
PreviewAAPPENDIXOnce you have .docx
 
lecture 5
 lecture 5 lecture 5
lecture 5
 
Creating a repository using the oracle business intelligence administration tool
Creating a repository using the oracle business intelligence administration toolCreating a repository using the oracle business intelligence administration tool
Creating a repository using the oracle business intelligence administration tool
 
Database Course Project-Usage Documentation
Database Course Project-Usage DocumentationDatabase Course Project-Usage Documentation
Database Course Project-Usage Documentation
 
Acccesss notes
Acccesss notesAcccesss notes
Acccesss notes
 
Access2003
Access2003Access2003
Access2003
 
Access2003
Access2003Access2003
Access2003
 
Creating relationships with tables
Creating relationships with tablesCreating relationships with tables
Creating relationships with tables
 
Basic interview questions for skills tests
Basic interview questions for skills testsBasic interview questions for skills tests
Basic interview questions for skills tests
 
B.sc i agri u 4 introduction to ms access
B.sc i agri u 4 introduction to ms accessB.sc i agri u 4 introduction to ms access
B.sc i agri u 4 introduction to ms access
 
B.sc i micro bio u 4 introduction to ms access
B.sc i micro bio u 4 introduction to ms accessB.sc i micro bio u 4 introduction to ms access
B.sc i micro bio u 4 introduction to ms access
 
B.sc i bio tech u 4 introduction to ms access
B.sc i bio tech u 4 introduction to ms accessB.sc i bio tech u 4 introduction to ms access
B.sc i bio tech u 4 introduction to ms access
 
B.sc i bio chem u 4 introduction to ms access
B.sc i bio chem u 4 introduction to ms accessB.sc i bio chem u 4 introduction to ms access
B.sc i bio chem u 4 introduction to ms access
 
B.sc i cs u 4 introduction to ms access
B.sc i cs u 4 introduction to ms accessB.sc i cs u 4 introduction to ms access
B.sc i cs u 4 introduction to ms access
 

Recently uploaded

Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
Neo4j
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
Neo4j
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
RinaMondal9
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
Peter Spielvogel
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
James Anderson
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems S.M.S.A.
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
Pierluigi Pugliese
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Nexer Digital
 

Recently uploaded (20)

Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
 

S1 relational database pdf

  • 1. Copyright © 2009 Bahn, D., Tang, H. & Yardley, A. All Rights Reserved. ISBN: 978-1-936203-01-7 Systems Analysis and Design Learning Module Series #1 Document version Creating a Relational Database Overview In this tutorial we will create a relational database file comprised of two tables linked together in a one-to-many relationship. These tables may be components of a database that manages student registrations for one or more sections pertaining to a given course. The two tables, then, will be a Course Table and a Sections Table, such that a Section-to-Course relationship exists between them. Since one course can contain many sections, the relationship is one of one-to-many, which in database language is expressed as a relationship having a maximum cardinality of 1:N. We will therefore, initialize a new database file in MS Access 2007, create two tables, link or join the tables together, and perform some create, update and delete tasks to observe what happens as a result of each. Section I: Database Design Initializing a New Database file in MS Access 2007 1. At the Getting Stared with Microsoft Access screen click on New Blank Database. 2. In the File Name text box, name your database Course Database and click on the Folder (right) to set the destination folder. Note: The *.accdb extension is added automatically by the wizard. Click Create. 1
  • 2. Copyright © 2009 Bahn, D., Tang, H. & Yardley, A. All Rights Reserved. ISBN: 978-1-936203-01-7 3. Under the All Tables pane, right click on Table1 : Table and select Design View from the drop down menu . (In the Save As dialog box, under Table Name, type Course and click OK .   4. (a) Under the Field Name pane, enter column (or field) names as follows: course_ID (primary key), subject, course_title, credits, and grading_method. (b) Under Section tab, under Data Type, click the down-arrow for the course_ID to select Text Notice the yellow key indicating that “course_ID” is the Primary Key. This key is set by default to the first row in the table 5. From the Table Tools palette, select the Create tab, and click on Table. 2
  • 3. Copyright © 2009 Bahn, D., Tang, H. & Yardley, A. All Rights Reserved. ISBN: 978-1-936203-01-7 6. Under the All Tables pane, right click on Table1 : Table and select Design View from the drop down menu . (In the Save As dialog box, under Table Name, type Section and click OK .   7. (a) Under the Section tab, under Field Name, enter Field (or column) names as follows: section_ID (primary key), course_ID (foreign key), location, employee_ID, and day_of_week. (b) Under Section tab, under Data Type, click the down-arrow for the section_ID to select Text. 8. On the main File Menu, click the Save button (Highlighted above in red box). 3
  • 4. Copyright © 2009 Bahn, D., Tang, H. & Yardley, A. All Rights Reserved. ISBN: 978-1-936203-01-7 9. Right click on the Section tab and select Close All to close all tabs. Click Yes at the confirmation “Do you want to save changes…” dialog box. 4
  • 5. Copyright © 2009 Bahn, D., Tang, H. & Yardley, A. All Rights Reserved. ISBN: 978-1-936203-01-7 Section II: Adding Data to the Tables 1. Under All Tables, double-click on Course : Table. Enter the data as shown below. 1. When you are done, right-click on the Course tab and click Save on the drop down menu. 2. Under All Tables, double-click on Section : Table. Enter the data as shown below. 3. When you are done, right-click on the Section tab and click Save on the drop down menu. 5
  • 6. Copyright © 2009 Bahn, D., Tang, H. & Yardley, A. All Rights Reserved. ISBN: 978-1-936203-01-7 4. From the Table Tools palette, select the Database Tools tab, and click on Relationships 5. If the Show Table window doesn’t automatically appear, click the Show Table button. 6. Click on course to highlight it, and click the Add button (below left); then click on section to highlight it, and click the Add button (below right). 6
  • 7. Copyright © 2009 Bahn, D., Tang, H. & Yardley, A. All Rights Reserved. ISBN: 978-1-936203-01-7 Referential Integrity Referential Integrity in a relational database describes consistency between related tables. In this section, we explore the following:  What happens and what it means to relate two tables together without enforcing Referential Integrity  What happens and what it means to relate two tables together in a One-to-Many relationship Enforcing Referential Integrity, but without enforcing Cascade Update Related Fields or Cascade Delete Related Records  What happens and what it means to relate two tables together in a One-to-Many relationship enforcing Referential Integrity and enforcing Cascade Update Related Fields  What happens and what it means to relate two tables together in a One-to-Many relationship enforcing Referential Integrity and enforcing Cascade Delete Related Records Section III: Update, modify and delete observations … (a) Without Referential Integrity Let us examine what happens and what it means to relate two tables together without Enforcing Referential Integrity, i.e. leaving this checkbox unchecked. Important: If you are going to try this “hands-on”… Save a copy of your working database now!!! 7
  • 8. Copyright © 2009 Bahn, D., Tang, H. & Yardley, A. All Rights Reserved. ISBN: 978-1-936203-01-7 1. Now, we notice that the “course_ID”, which is the primary key in the Course table can be matched to “course_ID” in the Section table, which can be considered a foreign key in the Section table. Click course_ID in the Course Table and drag it over course_ID in the Section Table. 2. The Edit Relationships window displays. In the Edit Relationships window, confirm that course_ID appears on both sides of the join. Notice the Unchecked “Enforce Referential Integrity” checkbox. 8
  • 9. Copyright © 2009 Bahn, D., Tang, H. & Yardley, A. All Rights Reserved. ISBN: 978-1-936203-01-7 3. Click Create. Notice that the join is represented by a simple black line and does not indicate the One-to- Many relationship. 4. In the course table, locate the entry for << course_ID BIO123 >> and click on the blue square of the row to highlight it (see red arrow below). 5. Right-click anywhere on the row and select Delete Record from the drop down menu. 9
  • 10. Copyright © 2009 Bahn, D., Tang, H. & Yardley, A. All Rights Reserved. ISBN: 978-1-936203-01-7 6. Notice that top record is now BIO124 and the database warns that You are about to delete 1 record(s). Confirm that you are working on a copy of your database, and click Yes to delete the record. 7. Now open the Section Table in the database. Notice that sections 123-01 and 123-02 still exist in the section table even though the course BIO123 they relate to, no longer exists! Since we did not enforce referential integrity between the coupled tables, there is now an inconsistency between them due to the deletion that took place on the Course Table. (b) With Referential Integrity Let us now examine what happens and what it means to relate two tables together in a One-to-Many relationship with referential integrity, but without enforcing Cascade Update Related Fields or Cascade Delete Related Records. 10
  • 11. Copyright © 2009 Bahn, D., Tang, H. & Yardley, A. All Rights Reserved. ISBN: 978-1-936203-01-7 8. Double click on the black line (above) joining the two tables. The Edit Relationships window displays. 9. In the Edit Relationships window, click the drop down arrow under Table/Query and select Course from the drop down menu. 10. Confirm that the relationships appear as shown below and check Enforce Referential Integrity (leaving the other two check boxes unchecked) and click OK. 11. 11
  • 12. Copyright © 2009 Bahn, D., Tang, H. & Yardley, A. All Rights Reserved. ISBN: 978-1-936203-01-7 Notice that the black line (below) representing the join between the tables now reflects the One-to-Many relationship between the coupled tables. Theoretically, this relationship is a function of a business rule or another such constraint; one course can have many associated sections, but any given section can only have one associated course. As far as database is concerned, however, this relationship is implemented by the Enforcing of Referential Integrity. The end of the line that connects to the Course Table is now designated with a “1” – indicating that this table is the parent table, which can have many children. The end of the line that connects to the Section Table is designated with “∞” – indicating that this table is the child table, which can only have one parent. Thus, one course can have one or more associated sections, but any given section can only have one associated course. 12. Right-click on the Relationship tab and select Close from the drop down menu. If the “Do you want to save changes to the layout of „Relationships‟?” dialog box appears, click Yes. 13. Try to add (Update) a new row in the Section Table. Click on the next available row in the table, enter the complete row for << Section 600-01 >> as shown below and click Enter. 12
  • 13. Copyright © 2009 Bahn, D., Tang, H. & Yardley, A. All Rights Reserved. ISBN: 978-1-936203-01-7 Since << course_ID MKT600 >> does not exist in the Course Table, the DBMS returns the following error: This is because of the Enforce Referential Integrity setting that we applied in step 10. Since there is no record of << course_ID MKT600 >> in the Course table, referential integrity prevents us from adding (Updating) this row in the Section Table until we first add it to the Course table. To put this in plain English: We cannot create a section for a course which does not exist. 14. Click once on the blue square of the row for course_ID BIO123 to highlight it. Then right-click anywhere on the row and select Delete Record from the drop down menu. The DBMS returns the following error: 13
  • 14. Copyright © 2009 Bahn, D., Tang, H. & Yardley, A. All Rights Reserved. ISBN: 978-1-936203-01-7 Since the course here (course_ID BIO123) has existing and related sections in the Section Table, (namely, Section 123-01 and Section 123-02) the DBMS must prevent the course from being deleted until all related sections have first been deleted. This is because the “sections” are existence-dependent entities with respect to “courses”. A course may exist without a section, but a section cannot exist without a course. To put this in plain English: We cannot delete a course for which a section exists. 15. In the Course Table, if we try to Modify the record for BIO123, changing it to BIO999 … The DBMS returns the following error: Again since << course_ID BIO123 >> has existing and related sections in the Section Table, the DBMS must prevent the course_ID from being modified until all related sections have first been deleted. (c ) With Cascade Updated Related Fields 14
  • 15. Copyright © 2009 Bahn, D., Tang, H. & Yardley, A. All Rights Reserved. ISBN: 978-1-936203-01-7 16. Double click on the black line (above) joining the two tables. The Edit Relationships window displays. 17. In the Edit Relationships window, click the drop down arrow under Table/Query and select Course from the drop down menu. 18. In the Edit Relationships window, confirm that Enforce Referential Integrity is checked, check the Cascade Updated Related Fields check box and click OK. 19. Double-click on the course table to modify the Course Table. Click on the row for <<course_ID BIO123>> and modify it to read BIO999. Right click on the Course Table tab, and select Save from the drop down menu. 15
  • 16. Copyright © 2009 Bahn, D., Tang, H. & Yardley, A. All Rights Reserved. ISBN: 978-1-936203-01-7 20. Now click on the Section Table tab. Notice that the records for Section 123-01 and Section 123-02 have been updated under the course_ID column, to reflect their modified associated course BIO999. (d) With Cascade Deleted Related Fields 21. Double click on the black line (above) joining the two tables. The Edit Relationships window displays. 22. In the Edit Relationships window, click the drop down arrow under Table/Query and select Course from the drop down menu. 16
  • 17. Copyright © 2009 Bahn, D., Tang, H. & Yardley, A. All Rights Reserved. ISBN: 978-1-936203-01-7 23. In the Edit Relationships window, confirm that Enforce Referential Integrity is checked, check the Cascade Deleted Related Records check box and click OK. (All three may be checked here). 24. Double-click on the course table to modify the Course Table. Click on the blue square to select and highlight the row for << course_ID BIO999 >> right click anywhere on the row and select Delete Record from the drop down menu. Note: This row originally was named BIO123 but was modified to BIO999 in the previous section. 17
  • 18. Copyright © 2009 Bahn, D., Tang, H. & Yardley, A. All Rights Reserved. ISBN: 978-1-936203-01-7 25. Click Yes to confirm that want to delete these records… 26. Click on the Section Table tab to notice that Section 123-01 and Sections 123-02 have been deleted. 18
  • 19. Copyright © 2009 Bahn, D., Tang, H. & Yardley, A. All Rights Reserved. ISBN: 978-1-936203-01-7 This completes the documentation for Systems Analysis and Design Learning Module Series #1 Document version Creating a Relational Database 19