Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

2023. 4. 13.

Data vs. Information vs. Knowledge


MGT3002 Management Information Systems } Data

Information vs. knowledge


Data Management & }

Access DB Tutorial

Sogang University Business School


2

1 2

Database Database

eet
adsh
e
Spr
3 4

3 4

Database Databases

Relationships: Values in one table may relate rows to those in other tables

5 6

5 6

1
2023. 4. 13.

Database Database
Table Primary Key § Relational databases store data in tables that represent
relationships using primary key and foreign key
§ Primary Key
Attributes
§ Column (or group of columns) that makes each row unique in a
table
§ E.g. “student number” can be the primary of the “student” table
§ Composite primary keys if a group of columns are primary key
§ Foreign Key
§ Non-key column or field in one table that links to a primary key
in another table
§ E.g., “student number” in “email” and “office visit” tables

7 8

7 8

Database Entity-Relationship (ER) Model


§ Database: } Types of relationships:
§ Preserves data integrity } One-to-one: a student has
one schedule; a schedule
} Assures that data is consistent, correct, and accessible belongs to one student
} One-to-many: a course has
§ Eliminates data redundancy
one professor; a professor
} Unnecessary repetition of data that slows data processing has one or more courses
} Many-to-many: a student
§ Limits data views (query and report) has one or more courses; a
} Users only see what they need to see, as cleanly and course has one or more
students
clearly as possible

9 10

實體聯繫圖
Entity Relationship Diagram (ERD) or E-R Diagram Database Management Systems (DBMS)
} Cardinality
} Software for creating, storing, organizing, and accessing data
from a database
} Separates the logical and physical views of the data
} Logical view: how end users view data
} Physical view: how data are actually structured and
§ Relationship between two entities organized
§ 1 to 1 (1:1) } Examples: Microsoft Access, DB2, Oracle Database, Microsoft
§ 1 to Many (1:N) SQLServer, MySQL
§ Many to Many (N:M)
§ Many to Many is not allowed
§ Use join table – converts “Many to Many” to “1 to Many” and “Many to 1”
11 12
12

11 12

2
2023. 4. 13.

關聯資料庫管理系統

Human Resources Database with Multiple Views Operations of a Relational DBMS


} Select:
} Creates a subset of all records meeting stated criteria
} Join:
} Combines relational tables to present the server with
more information than is available from individual
tables
} Project:
} Creates a subset consisting of columns in a table
} Permits user to create new tables containing only
desired information

13 14

13 14

Three Basic Operations of a Relational DBMS Capabilities of DBMS


} Data definition capabilities:
} Specify structure of content of database
} Data dictionary:
} Automated or manual file storing definitions of data
elements and their characteristics
} Querying and reporting:
} Data manipulation language
} Structured query language (S Q L) 建立詢問語言
} Microsoft Access query-building tools
} Report generation, e.g., Crystal Reports

15 16

15 16

An Access Query Why Use Access?


} Access is a “relational” database application
} Relational means we can link together sets of data without
repetition that may occur anywhere else

} We can keep track of the patients, the doctors and when the patients
last saw their doctors, what happened at each visit and so on

17 18

17 18

3
2023. 4. 13.

Basic Access Objects Basic Access Objects


} Tables } Queries – show the data in a Table format

19 20

19 20

Basic Access Objects Basic Access Objects


} Forms – provide a “user-friendly” side of your database } Forms

21 22

21 22

Basic Access Objects Creating a New Database


} Reports – print out your data in a formatted structure 1. Open Microsoft Access
2. Choose Blank Desktop Database
3. Click on the yellow folder at the end of the File Name box and browse for
the desktop
4. Use the file name: Patient Appointments
5. Click Create

23 24

23 24

4
2023. 4. 13.

Explore the Window Creating the Patient Table


1. Close Table 1 with the X under the ribbon, or by right-clicking on the name 1. Click on the Create tab and choose Table Design
of the table
2. Explore the Ribbon
1. Home Tab – Sort & Filter, Refresh Data, Format text, etc.

2. Create – Create a database objects: Tables, Queries, Forms, Reports


3. External Data – Import and Export Data
2. Type the first Field Name: Pt Med Rec #
4. Database Tools – Advanced Features of Relationships and Data
- Data Type: Short Text, Description: Patients’ Medical Record Number
Analyzers
3. Enter the rest of the fields (descriptions not necessary):

25 26

25 26

Creating the Patient Table Entering First Record


4. Set the Pt Med Rec # to be the primary key 1. Turn to the Datasheet View
- Clicking on the big yellow key on the toolbar 2. Enter our first Med Rec #: 123-456
5. Save the Table as Patients 3. Press tab to move to the next field

27 28

27 28

Exit the Database Adding Fields


1. In Design View, create Pt Gender, Short Text, above Pt Birth Date
1. Exit the database, Access will probably not ask you to save
1. Insert Rows from Design Tab, or from the right-click menu
- But it did save the record, it does so automatically
2. In Data View, enter “Male” (the whole word) for Sam and Jacob
2. Open your database from the desktop
- If necessary, Enable Content
3. Open the table (double-click) from the navigation pane
- Sam is still there!

29 30

29 30

5
2023. 4. 13.

Creating Female Patient’s Query Creating Female Patient’s Query


1. Go to the Create Tab and choose Query Design 4. View Datasheet View

2. In the Show Table Window, push the Add button and the close the
window
3. Double-clicking on the field names to the add Pt First Name, Pt
Last Name, and Pt Gender

31 32

31 32

Customizing a Query Creating Patients Form


1. In the Datasheet view, notice the sort order is by Med Rec # 1. Select Patients Table from left Navigation Pane so it becomes the default
2. In the Design view, set Query to Sort by Pt Last Name Ascending data source
3. Go to the Data view, patients should read, Franks through Williams 2. On the Create Tab click on the Form button
4. In the Design View, set the Criteria line for the Pt Gender field to be
Female
- In Datasheet view, you should only have two people: Jane and Doris
5. Close and save the Query as Female Patients 3. We are in the Form’s Layout view
- Place your mouse along the right border of the highlighted box and
resize
4. Change to the “Form” view (first button on the Home Tab)
5. Create a new FEMALE patient, any you want
- Tan until you reach a new blank record, or use the NEW button on the
Home Tab
- Make sure to leave the record, “pencils down!,” move to another record
or save
33 34

33 34

Creating Patients Form Create a Report


6. Open the Patients TABLE, view new person 1. Select Table from left Navigation Pane so it becomes the default
- From the left Navigation Pane, double-click to open data source
7. Open the Female Patients QUERY, view new person 2. On the Create Tab click on the REPORT button
- New patient has been saved, even though the Form has not
been saved
- If you did not close the table and/or query, you may not see the
person right away. Close the object, and when you open them
you’ll see the new person
3. The report opens in Layout View, adjust the columns to fit the data
8. Close all, save Form as “Patients”
4. Right-click in an empty space and go to the Print Preview
5. Close and Save as Patients

35 36

35 36

6
2023. 4. 13.

Create Appointments Table Create Lookup Location


1. From the Create Tab choose Table Design 1. Change the Data Type for Appt Location to be Lookup Wizard
2. Create Table as shown here - Type in the values: “Gainsville, Starke, Jacksonwille
3. Set Appt ID # to be the primary key 2. Appt Location field type still says SHORT TEXT
- View Lookup tab in the properties at the bottom of the window

37 38

37 38

Create Schedule Query with Multiple Tables


Add an Appointment using Join Operation
1. In Datasheet view, enter a new record 1. Go to the Create Tab and click the Query Design button
2. Enter a new record 2. Add both Tables and close the Show Table window
3. Double-click on the field names to add them to the query
- Pt Med Rec from Appointments
- Pt First Name and Pt Last Name from Patients
- Appt Doctor, Appt Date, Appt Reason from Appointments
4. Connect Pat Med Rec from both tables by dragging

39 40

39 40

[Part 2 – Access Exercise] Q8 [Part 2 – Access Exercise] Q8

SQL code:

SELECT EMPLOYEE.fname, EMPLOYEE.minit, EMPLOYEE.lname, Count(ORDER.quantity) AS


quantity의개수
FROM EMPLOYEE INNER JOIN [ORDER] ON EMPLOYEE.EID = ORDER.sales_rep
GROUP BY EMPLOYEE.fname, EMPLOYEE.minit, EMPLOYEE.lname;

41 42

7
2023. 4. 13.

[Part 2 – Access Exercise] Q10 Backing up Database


1. From the File Tab choose Info
- Choose Compact and Repair
1. You should do this every time it crashes, or begins to run slowly, or starts
acting funny or before you share it

Between #2009-10-01# And


#2009-12-31#
2. From the File Tab choose Save & Publish
3. Exit Access

More info - Examples of using dates as criteria in Access queries (https://support.microsoft.com/en-us/office/examples-


of-using-dates-as-criteria-in-access-queries-aea83b3b-46eb-43dd-8689-5fc961f21762)
44

43 44

You might also like