Lesson 7 Managing Data Creating a database with Web Matrix
Connecting to a Database Steps to connect to a Database in Web Matrix 1. Click on Data explorer which is located on the right of your screen. 2. Click on New Connection
Connect to Database Your Server name by default is localhost You will now click on Create a new database
Name your database Type Movies as the name of your database Notice on the data explorer, you’re connected to the Movies database
Creating Tables Click on Tables Click on new item
Type JamesBondSeries for your Table Name Naming your Table Type JamesBondSeries for your Table Name
Creating Field Names You’re screen should like this one….
Quick lesson on DataTypes Web Matrix allows you to capture Text Numbers Dates
Description of Data Types used for Text Type of data Name Description Text Char Nchar Default=50 characters Nchar stores as Unicode 16bit VarChar NVarChar Default=50 characters NVarChar stores as 16bit Text NText Stores as pages 8KB NText stores as 16bit
Description of Data Types used for Numbers Type of data Data Type Name Description Numbers Int - 2 billion to + 2 billion Small Int -32,768 to +32,767 Tiny Int 0 to 255 Big Int Stores 1 billion times larger than Int
Description of Data Types used for Numbers Type of data Data Type Name Description Numbers Bit 0 or 1 True/False Yes/No Float Real Not whole numbers Decimal Numbers with fractional parts Money Small Money Monetary values
Description of Data Types used for Date & Times Type of data Data Type Name Description Dates & Times DateTime 1/1/1753-12/31/9999 SmallDateTime 1/1/1900-6/6/2079
Enter Field names to Table In the Column properties name, type ID For data type select Int Click the following: Required; Primary key and Auto Increment Click New when finished
More field names Select Column 2 Change name to MovieName Change data type to char Change Field size to 20 Click New when finished Select Column 3 Change name to Actor Change data type to char Change Field size to 20 Click New when finished
More field names Select Column 4 Change name to Actress Change data type to char Change Field size to 20 Click New when finished Select Column 5 Change name to Director Change data type to char Change Field size to 20 Click New when finished
More field names Select Column 6 Change name to Release date Change data type to Date Click New when finished Select Column 7 Change name to Rating Change data type to Int Click New when finished
More field names Select Column 8 Change name to MPAA Change data type to char Click New when finished Select Column 9 Change name to RunTime Change data type to Int Click OK when finished
Entering records into your database Click on Table Double Click on JamesBondSeries You’re ready to add records
Entering records Enter the following records: Press tab to move to next field/column More to enter on next slide
Finish entering record