Creating E/R Diagrams with SQL Server Management Studio, Writing SQL Queries D0ncho Minkov Telerik School Academy schoolacademy.telerik.com Technical Trainer.

Slides:



Advertisements
Similar presentations
Creating Databases and E/R Diagrams with SQL Server Management Studio Svetlin Nakov Telerik Corporation
Advertisements

MS-Access XP Lesson 1. Introduction to MS-Access Database Management System Software (DBMS) Store data in databases Database is a collection of table.
Microsoft SQL Server 2008 From the Program menu choose: Microsoft SQL Server 2008 R2  SQL Server Management Studio. You may see a window indicating the.
UNIVERSITY OF PALESTINE business computer application College of Business Instructor: Mr. Ahmed Abumosameh.
Access Lesson 2 Creating a Database
Module 4: Creating Data Types and Tables. Overview Creating Data Types Creating Tables Generating Column Values Generating Scripts.
Data Modelling. EAR model This modelling language allows a very small vocabulary: Just as English has nouns, verbs, adjectives, pronouns.., EAR models.
Creating Tables, Defining Constraints Rose-Hulman Institute of Technology Curt Clifton.
FIRST COURSE Access Tutorial 2 Building a Database and Defining Table Relationships.
Telerik Software Academy Telerik School Academy Creating E/R Diagrams with SQL Server.
Using ER/Studio.
Copyright ©2014 Pearson Education, Inc. Chapter 6 Physical Design Chapter6.1.
ACCESS CHAPTER 1. OBJECTIVES Tables Queries Forms Reports Primary and Foreign Keys Relationship.
Creating E/R Diagrams with SQL Server Management Studio and MySQL Workbench Svetlin Nakov Telerik Software Academy Manager Technical.
Part 06 – A More Complex Data Model Entity Framework and MVC NTPCUG Tom Perkins.
Access Tutorial 2 Building a Database and Defining Table Relationships
Databases in Visual Studio. Database in VisualStudio An MS SQL database are built in Visual studio The Name can be something like ”(localdb)\Projects”
Microsoft Access 2003 Define some key Access terminology: Field – A single characteristic or attribute of a person, place, object, event, or idea. Record.
Chapter 7 SQL HUANG XUEHUA. SQL SQL server2005 introduction Install components  management studio.
Management Information Systems MS Access MS Access is an application software that facilitates us to create Database Management Systems (DBMS)
WEEK 11 Database Design. TABLE INSTANCE CHARTS Create Tables.
SQL, Data Storage Technologies, and Web-Data Integration Week 2.
1 All Powder Board and Ski SQL Server Workbook Chapter 2: Database Design Jerry Post Copyright © 2004.
Introduction to Databases Trisha Cummings. What is a database? A database is a tool for collecting and organizing information. Databases can store information.
MIS 215 Lab Revision I. MSQL Server Installation II. Create a New Database III. Create a New Table IV. Relationships.
SQL Data Definition Language (DDL) Using Microsoft SQL Server 1SDL Data Definition Language (DDL)
® Microsoft Access 2010 Tutorial 2 Building a Database and Defining Table Relationships.
MS Access 2007 Management Information Systems 1. Overview 2  What is MS Access?  Access Terminology  Access Window  Database Window  Create New Database.
M1G Introduction to Database Development 2. Creating a Database.
Module 3: Creating Data Types and Tables. Overview Working with Data Types Working with Tables Generating Column Values Generating Scripts.
WHAT IS A DATABASE? A DATABASE IS A COLLECTION OF DATA RELATED TO A PARTICULAR TOPIC OR PURPOSE OR TO PUT IT SIMPLY A GENERAL PURPOSE CONTAINER FOR STORING.
® Microsoft Office 2013 Access Creating a Database.
McGraw-Hill/Irwin © The McGraw-Hill Companies, All Rights Reserved TECHNOLOGY PLUG-IN T6 Basic Skills Using Access.
INFORMATION TECHNOLOGY DATABASE MANAGEMENT. Adding a new field 1Right click the table name and select design view 2Type the field information at the end.
Advanced Web 2012 Lecture 3 Sean Costain What is a Database? Sean Costain 2012 A database is a structured way of dealing with structured information.
Session 11 Creating Tables and Using Data Types. RDBMS and Data Management/Session 11/2 of 40 Session Objectives Define the data types and list the categories.
3 Copyright © 2004, Oracle. All rights reserved. Working in the Forms Developer Environment.
Database Basics BCIS 3680 Enterprise Programming.
Data Modeling Creating E/R Diagrams SoftUni Team Technical Trainers Software University
Constraints Lesson 8. Skills Matrix Constraints Domain Integrity: A domain refers to a column in a table. Domain integrity includes data types, rules,
Work with Tables and Database Records Lesson 3. NAVIGATING AMONG RECORDS Access users who prefer using the keyboard to navigate records can press keys.
Task #1 Create a relational database on computers in computer classroom 308, using MySQL server and any client. Create the same database, using MS Access.
What is MySQL? MySQL is a relational database management system (RDBMS) based on SQL (Structured Query Language). First released in January, Many.
McGraw-Hill Career Education© 2008 by the McGraw-Hill Companies, Inc. All Rights Reserved. Concept 1 Database – Organized collection of related information.
* Database is a group of related objects * Objects can be Tables, Forms, Queries or Reports * All data reside in Tables * A Row in a Table is a record.
Exploring Microsoft Access Chapter 5 One-to-Many Relationships: Subforms and Multiple Table Queries.
SQL server Section 2&3. What are Data Types Character Data Types Number Data Types Date and Time Data Types CAST and CONVERT functions TRY_PARSE and TRY_CONVERT.
Microsoft Access Prepared by the Academic Faculty Members of IT.
Ch 3. Working with Tables and Views. Data type Specify type of data to be entered into a column (text, number, datetime, etc) Unicode (National) Datatypes.
CSCI 3327 Visual Basic Chapter 13: Databases and LINQ UTPA – Fall 2011.
SSMS SQL Server Management System. SQL Server Microsoft SQL Server is a Relational Database Management System (RDBMS) Relational Database Management System.
COMPREHENSIVE Access Tutorial 1 Creating a Database.
David M. Kroenke and David J. Auer Database Processing Fundamentals, Design, and Implementation Appendix E: Getting Started with MySQL Workbench Data Modeling.
Lecture 7 Data Model Implementation Dan Ames Hydroinformatics Fall 2013 This work was funded by National Science Foundation Grants EPS and EPS.
Databases and SQL Designing a database with tables and primary keys
Database Design and Rules
Managing Tables, Data Integrity, Constraints by Adrienne Watt
Data Definition and Data Types
Module 2: Creating Data Types and Tables
Basic Database Concepts
Data Definition and Data Types
Lesson 7 Managing Data Creating a database with Web Matrix.
Access Creating a Database
Access Creating a Database
Database systems Lecture 2 – Data Types
CIS16 Application Programming with Visual Basic
PT2520 Unit 5: Physical Design
Presentation transcript:

Creating E/R Diagrams with SQL Server Management Studio, Writing SQL Queries D0ncho Minkov Telerik School Academy schoolacademy.telerik.com Technical Trainer

1. Data Modeling – Principles 2. Data Types in SQL Server 3. Creating Databases in SQL Server 4. Creating Tables 5. Defining a Primary Key and Identity Columns 6. Creating Relationships between the Tables  One-to-many, Many-to-many, One-to-one 2

Fundamental Concepts

 Steps in the database design process:  Identification of the entities  Identification of the columns in the tables  Defining a primary key for each entity table  Identification and modeling of relationships  Multiplicity of relationships  Defining other constraints  Filling test data in the tables 4

 Entity tables represent objects from the real world  Most often they are nouns in the specification  For example:  Entities: Student, Course, Town 5 We need to develop a system that stores information about students, which are trained in various courses. The courses are held in different towns. When registering a new student the following information is entered: name, faculty number, photo and date.

 Columns in the tables are characteristics of the entities  They have name and type  For example students have:  Name (text)  Faculty number (number)  Photo (binary block)  Date of enlistment (date) 6

 Columns are clarifications for the entities in the text of the specification, for example:  Students have the following characteristics:  Name, faculty number, photo, date of enlistment and a list of courses they visit 7 We need to develop a system that stores information about students, which are trained in various courses. The courses are held in different towns. When registering a new student the following information is entered: name, faculty number, photo and date.

 Always define an additional column for the primary key  Don't use an existing column (for example SSN)  Must be an integer number  Must be declared as a primary key  Use identity to implement auto-increment  Put the primary key as a first column  Exceptions  Entities that have well known ID, e.g. countries (BG, DE, US) and currencies (USD, EUR, BGN) 8

 Relationships are dependencies between the entities:  " Students are trained in courses " – many-to- many relationship  " Courses are held in towns " – many-to-one (or many-to-many) relationship 9 We need to develop a system that stores information about students, which are trained in various courses. The courses are held in different towns. When registering a new student the following information is entered: name, faculty number, photo and date.

 Numeric  bit (1-bit), integer (32-bit), bigint (64-bit)  float, real, numeric (scale, precision)  money – for money (precise) operations  Strings  char(size) – fixed size string  varchar(size) – variable size string  nvarchar(size) – Unicode variable size string  text / ntext – text data block (unlimited size) 11

 Binary data  varbinary(size) – a sequence of bits  image – a binary block up to 1 GB  Date and time  datetime – date and time starting from to , a precision of 1/300 sec.  smalldatetime – date and time (1-minute precision) 12

 Other types  timestamp – automatically generated number whenever a change is made to the data row  uniqueidentifier – GUID identifier  xml – data in XML format 13

 Nullable and NOT NULL types  All types in SQL Server may or may not allow NULL values  Primary key columns  Define the primary key  Identity columns  Automatically increased values when a new row is inserted (auto-increment values)  Used in combination with primary key 14

Creating Database

 When starting SSMS a window pops up  Usually it is enough to just click the "Connect" button without changing anything 16

 Object Explorer is the main tool to use when working with the database and its objects  Enables us:  To create a new database  To create objects in the database (tables, stored procedures, relationships and others)  To change the properties of objects  To enter records into the tables 17

 In Object Explorer we go to the " Databases " and choose " New Database …" from the context menu 18

 In the " New Database " window enter the name of the new database and click [ OK ] 19

Creating E/R Diagrams

 In the " Database Diagrams " menu choose the " New Database Diagram "  We can choose from the existing tables, which we want to add to the diagram 21

Creating Tables

 If the database doesn't show immediately in Object Explorer perform "Refresh" [F 5 ]  Creating new table: 23

 Enter table name and define the table columns (name and type): 24 Enter the name of the column here Choose the data type of the column here Choose whether NULLs are allowed

 Defining a primary key 25 Right click on the column start and select "Set Primary Key"

 Defining an identity columns  Identity means that the values in a certain column are auto generated (for int columns)  These values cannot be assigned manually  Identity Seed – the starting number from which the values in the column begin to increase.  Identity Increment – by how much each consecutive value is increased 26

 Setting an identity through the "Column Properties" window 27

 It is a good practice to set the name of the table at the time it is created  Use the "Properties" window  If it's not visible use "View"  "Properties Window" or press [F4] 28 Table name

 When closing the window for the table, SSMS asks whether to save the table  You can do it manually by choosing “Save Table” from the “File” menu or by pressing Ctrl + S 29

Creating Relationships between Tables

 To create one-to-many relationship drag the foreign key column onto the other table  Drag from the child table to the parent table 31

 Self-relationship can be created by dragging a foreign key onto the same table 32

Questions?