Telerik Software Academy Telerik School Academy Creating E/R Diagrams with SQL Server.

Slides:



Advertisements
Similar presentations
Windows Basic and Dynamic Disk Borislav Varadinov Telerik Software Academy academy.telerik.com System Administrator Marian Marinov CEO of 1H Ltd.
Advertisements

Creating Databases and E/R Diagrams with SQL Server Management Studio Svetlin Nakov Telerik Corporation
HTML Forms, GET, POST Methods Tran Anh Tuan Edit from Telerik Academy
Make swiftly iOS development Telerik Academy Telerik Academy Plus.
Amazon S 3, App Engine Blobstore, Google Cloud Storage, Azure Blobs Svetlin Nakov Telerik Software Academy academy.telerik.com.
RPN and Shunting-yard algorithm Ivaylo Kenov Telerik Software Academy academy.telerik.com Technical Assistant
Shortest paths in edge-weighted digraph Krasin Georgiev Technical University of Sofia g.krasin at gmail com Assistant Professor.
Telerik Software Academy Telerik School Academy.
Asynchronous Programming with C# and WinRT
Character sequences, C-strings and the C++ String class, Working with Strings Learning & Development Team Telerik Software Academy.
Hybrid or Native?! Doncho Minkov Telerik Software Academy Senior Technical Trainer
Done already for your convenience! Telerik School Academy Unity 2D Game Development.
Processing Sequences of Elements Telerik School Academy C# Fundamentals – Part 1.
NoSQL Concepts, Redis, MongoDB, CouchDB
The Business Plan and the Business Model Margarita Antonova Volunteer Telerik Academy academy.telerik.com Business System Analyst Telerik Corporation.
What are ADTs, STL Intro, vector, list, queue, stack Learning & Development Team Telerik Software Academy.
Making JavaScript code by template! Learning & Development Team Telerik Software Academy.
Svetlin Nakov Telerik Software Academy academy.telerik.com Manager Technical Training Who, What, Why?
Svetlin Nakov Telerik Software Academy Manager Technical Training
Access to known folders, using pickers, writing to and reading from files, caching files for future access George Georgiev Telerik Software Academy academy.telerik.com.
Accessing SQL Server and MySQL – Live Demo Svetlin Nakov Telerik Software Academy academy.telerik.com Manager Technical Training
Processing Matrices and Multidimensional Tables Svetlin Nakov Telerik Software Academy academy.telerik.com Technical Trainer
Learning & Development Telerik Software Academy.
Reading and Writing Text Files Svetlin Nakov Telerik Software Academy academy.telerik.com Technical Trainer
Telerik Software Academy ASP.NET Web Forms.
Classical OOP in JavaScript Classes and stuff Telerik Software Academy
Using Selenium for Mobile Web Testing Powered by KendoUI Telerik QA Academy Atanas Georgiev Senior QA Engineer KendoUI Team.
NoSQL Concepts, Redis, MongoDB, CouchDB Svetlin Nakov Telerik Software Academy academy.telerik.com Manager Technical Training
New features: classes, generators, iterators, etc. Telerik Academy Plus JavaScript.Next.
Creating E/R Diagrams with SQL Server Management Studio and MySQL Workbench Svetlin Nakov Telerik Software Academy Manager Technical.
Throwing and Catching Exceptions Tran Anh Tuan Edit from Telerik Software Academy
Loops, Conditional Statements, Functions Tran Anh Tuan Edit from Telerik Academy
Telerik Software Academy ASP.NET Web Forms.
Private/Public fields, Module, Revealing Module Learning & Development Team Telerik Software Academy.
Building Data-Driven ASP.NET Web Forms Apps Telerik Software Academy ASP.NET Web Forms.
Course Introduction Svetlin Nakov Telerik Software Academy academy.telerik.com Manager Technical Training
Nikolay Kostov Telerik Software Academy Senior Software Developer and Trainer
Telerik Software Academy End-to-end JavaScript Applications.
What is a Database, MySQL Specifics Trần Anh Tuấn Edit from Telerik Software Academy
Planning and Tracking Software Quality Yordan Dimitrov Telerik Corporation Team Leader, Team Pulse, Team Leader, Team Pulse, Telerik Corporation,
What you need to know Ivaylo Kenov Telerik Corporation Telerik Academy Student.
Data binding concepts, Bindings in WinJS George Georgiev Telerik Software Academy academy.telerik.com Technical Trainer itgeorge.net.
Pavel Kolev Telerik Software Academy Senior.Net Developer and Trainer
Objects, Properties, Primitive and Reference Types Learning & Development Team Telerik Software Academy.
When and How to Refactor? Refactoring Patterns Alexander Vakrilov Telerik Corporation Senior Developer and Team Leader.
Free Training and Job for Software Engineers Svetlin Nakov, PhD Manager Technical Training Telerik Corp. Telerik Software Academy.
Free Training and Job for Software Engineers Svetlin Nakov, PhD Manager Technical Training Telerik Corp. Telerik Software Academy.
Access to known folders, using pickers, writing to and reading from files, caching files for future access George Georgiev Telerik Software Academy academy.telerik.com.
Doing the Canvas the "easy way"! Learning & Development Telerik Software Academy.
Creating and Running Your First C# Program Svetlin Nakov Telerik Software Academy academy.telerik.com Manager Technical Training
Data Types, Primitive Types in C++, Variables – Declaration, Initialization, Scope Telerik Software Academy academy.telerik.com Learning and Development.
The past, the present, the future Learning & Development Team Telerik Software Academy.
Data Modeling Creating E/R Diagrams SoftUni Team Technical Trainers Software University
Connecting, Queries, Best Practices Tran Anh Tuan Edit from Telerik Software Academy
Processing Sequences of Elements Telerik Software Academy C# Fundamentals – Part 2.
Telerik JavaScript Framework Telerik Software Academy Hybrid Mobile Applications.
Building Rock-Solid Software Nikolay Kostov Telerik Software Academy academy.telerik.com Senior Software Developer and Technical Trainer
Telerik Software Academy Databases.
Things start to get serious Telerik Software Academy JavaScript OOP.
Learning & Development Mobile apps for iPhone & iPad.
Processing Matrices and Multidimensional Tables Telerik Software Academy C# Fundamentals – Part 2.
Nikolay Kostov Telerik Software Academy academy.telerik.com Team Lead, Senior Developer and Trainer
Functions and Function Expressions Closures, Function Scope, Nested Functions Telerik Software Academy
Implementing Control Logic in C# Svetlin Nakov Telerik Software Academy academy.telerik.com Manager Technical trainer
Inheritance, Abstraction, Encapsulation, Polymorphism Telerik Software Academy Mobile apps for iPhone & iPad.
Mocking tools for easier unit testing Telerik Software Academy High Quality Code.
Creating E/R Diagrams with SQL Server Management Studio, Writing SQL Queries D0ncho Minkov Telerik School Academy schoolacademy.telerik.com Technical Trainer.
What why and how? Telerik School Academy Unity 2D Game Development.
Windows Security Model Borislav Varadinov Telerik Software Academy academy.telerik.com System Administrator
Data Definition and Data Types
Presentation transcript:

Telerik Software Academy Telerik School Academy Creating E/R Diagrams with SQL Server Management Studio and MySQL Workbench

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

3

 Steps in the database design process: 1.Identification of the entities 2.Identification of the columns in the tables 3.Defining a primary key for each entity table 4.Identification and modeling of relationships  Multiplicity of relationships 5.Defining other constraints 6.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.

10

 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

15

 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

 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 20

21

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

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

 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] 24 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 25

26

 Defining a primary key 27 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 28

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

30

 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

33

 Tables  Each word is capitalized (Pascal Case)  In English, plural  Examples: Users, PhotoAlbums, Countries  Columns  In English, singular  Each word is capitalized (Pascal Case)  Avoid reserved words (e.g. key, int, date )  Examples: FirstName, OrderDate, Price 34

 Primary key  Use " Id " or name_of_the_table + " Id "  Example: in the Users table the PK column should be be called Id or UserId  Foreign key  Use the name of the referenced table + " Id "  Example: in the Users table the foreign key column that references the Groups table should be named GroupId 35

 Relationship names (constraints)  In English, Pascal Case  " FK_ " + table1 + " _ " + table2  For example: FK_Users_Groups  Index names  " IX_ " + table + " _ " + column  For example: IX_Users_UserName 36

 Unique key constraints names  " UK_ " + table + " _ " + column  For instance: UK_Users_UserName  Views names  " V_ " + name  Example: V_BGCompanies  Stored procedures names  " usp_ " + name  Example: 37

Live Demo

39

 MySQL Workbench supports database schema design (E/R diagrams)  Can reverse engineer an existing database  Can forward engineer the diagram into SQL script / existing / new database  Can synchronize schema changes with existing database  User-unfriendly UI but better than nothing  Edit tables, relationships, indices, triggers, … 40

Live Demo

форум програмиране, форум уеб дизайн курсове и уроци по програмиране, уеб дизайн – безплатно програмиране за деца – безплатни курсове и уроци безплатен SEO курс - оптимизация за търсачки уроци по уеб дизайн, HTML, CSS, JavaScript, Photoshop уроци по програмиране и уеб дизайн за ученици ASP.NET MVC курс – HTML, SQL, C#,.NET, ASP.NET MVC безплатен курс "Разработка на софтуер в cloud среда" BG Coder - онлайн състезателна система - online judge курсове и уроци по програмиране, книги – безплатно от Наков безплатен курс "Качествен програмен код" алго академия – състезателно програмиране, състезания ASP.NET курс - уеб програмиране, бази данни, C#,.NET, ASP.NET курсове и уроци по програмиране – Телерик академия курс мобилни приложения с iPhone, Android, WP7, PhoneGap free C# book, безплатна книга C#, книга Java, книга C# Николай Костов - блог за програмиране

1.Create the following database diagram in SQL Server: 2.Fill some sample data in the tables with SQL Server Management Studio. 43

3.Typical universities have: faculties, departments, professors, students, courses, etc. Faculties have name and could have several departments. Each department has name, professors and courses. Each professor has name, a set of titles (Ph. D, academician, senior assistant, etc.) and a set of courses. Each course consists of several students. Each student belongs to some faculty and to several of the courses. Your task is to create a data model (E/R diagram) for the typical university in SQL Server using SQL Server Management Studio (SSMS). 4.Create the same data model in MySQL. 44

5.We should design a multilingual dictionary. We have a set of words in the dictionary. Each word can be in some language and can have synonyms and explanations in the same language and translation words and explanations in several other languages. The synonyms and translation words are sets of words from the dictionary. The explanations are textual descriptions. Design a database schema (a set of tables and relationships) to store the dictionary. 45

6.Add support in the previous database for storing antonym pairs. Add support for storing part-of-speech information (e.g. verb, noun, adjective, …). Add support for storing hypernym / hyponym chains (e.g. tree  oak, pine, walnut-tree, …). 46

 C# Telerik Academy  csharpfundamentals.telerik.com csharpfundamentals.telerik.com  Telerik Software Academy  academy.telerik.com academy.telerik.com  Telerik Facebook  facebook.com/TelerikAcademy facebook.com/TelerikAcademy  Telerik Software Academy Forums  forums.academy.telerik.com forums.academy.telerik.com