Docsity

Physical Database Design: Comparing DBMSs, Creating Databases, and Data Types - Prof. LOng, Study notes of Computer Science

Partial preview of the text

Download Physical Database Design: Comparing DBMSs, Creating Databases, and Data Types - Prof. LOng and more Study notes Computer Science in PDF only on Docsity!

Physical Design

  • (^) By the end of this chapter you will be able to:
    • (^) Compare DBMSs and select one DBMS to use
    • (^) Implement physical design based on logical ERD
    • (^) Choose appropriate data types for columns
    • (^) Enter sample data into tables Chapter outcomes

Creating The DB

  1. Right click on Databases 11 2.^ Click on New Database… 22
  1. Key in the DB name
  2. Normally a DB contains two files 1. One for the data file 2. One for the log file
  3. Click Add to create 11 22 33
  • (^) Part of creating physical design is to understand how DBMS stores/manages

files

  • (^) Different DBMSs manages files in different ways.
  • (^) SQL Server databases have at least two files
  • (^) A data file with the extension “.mdf” (can be more data files)
  • (^) A log file with the extension “.ldf” Database Files
  • (^) Second aspect of physical design involves data types
    • (^) The column specification that determines what kind of data can be stored in that column
  • (^) ANSI provides set of basic data types,
    • (^) Different DBMSs will make its own modification
    • (^) We will look at typical data types in SQL Server Data Types

These are frequently used

These are frequently used

  • (^) Fixed-Length Character Data Types
    • (^) The char and nchar are fixed length
    • (^) E.g., char(50) will always write 50 characters, even if you input only 20 (30 spaces are padded)
  • (^) Variable-Length Character Data Types
    • (^) The varchar and nvarchar are variable length
    • (^) E.g., varchar(50) will only use 20 characters if you input only 20 characters (no padded spaces) Things to think about

Physical design of tutor table Logical design (Entity) (^) Physical design (Table)

  • (^) Nulls
    • (^) A null represents the absence of a value.
    • (^) A null value is unknown.
    • (^) A null value could also be not applicable.
  • (^) Notice
    • (^) Empty string is not null
    • (^) Zero is not null Nulls

Activity: Create another table Logical design (Entity) Physical design (Table)

Activity: Create Table TutorCourse Logical design (Entity) Physical design (Table) To create composite PK, select both attributes and right click and set them as key Error: Change this to: *CourseKey nchar(10),

Activity: Create Ethnicity Table Logical design (Entity) Physical design (Table)