enter image description here
enter image description here
Hello, I am doing a homework, the tables I added are obliged to add. It will be like a company website. But since we just started to learn SQL server management studio I don't know how to connect/associate things. For exp. which table needs to have it's own id or which id needs to be connected with. Even a little help is okey, I am so lost.
Even though this question is very vague and need a lot of research to understand the whole concepts. I can suggest the following topics to understand database structure
Primary Key and Foreign Key
Relations in Database
Normalization
To understand these things you must have clear understanding of Database entities and structures. Tables,Columns,Entries
Related
I am making a database diagram using SQL Server 2014 and in my database I have foreign keys constrains that respectively are shown on the diagram (auto generated by the studio). The keys don't point exactly from the column to the column that the constraint is made on. So my question is if I should move them a little (to the exact column) and if this is a good practice or no?
This is not a good practice. Microsoft's diagrams are not an exact science when it comes to foreign keys. If you move them to exactly correspond, and then someone bumps them later, you could be thinking they point to the wrong column.
A better practice is to name them the same in both tables, or closely enough that you can tell at a glance. Don't think of the diagrams as a machine--just a blueprint.
I'm not sure if anyone can help me here, but I've begun the undertaking of attempting to map my databases 846 views into a readable format.
The only issue is, while I am well versed in query writing, the inner workings are somewhat still a mystery to me. I have imported my data dictionary to logical/relational models, but for some reason when I use the View to Table Wizard, the primary keys are not getting found.
I have done some poking around online to learn that primary/foreign keys do not exist on views, as that's exactly what it is, a view. I do not have access to the tables that I know of (someone a little more well versed said this was due to editioning that I can only see the views of tables). I do not know what to Google to remedy that.
As it stands, I just have an exorbitant amount of logical/relational view models on my screen (red and green), but I can't seem to figure out how to go through the view to the table and map out the keys through that way.
I don't know if any of this is making sense, and I really hope someone sees it. I'm going to keep digging. Let me know if I can give anymore information to help answer my question easier.
Nevermind, figured it out. Right click the main driving table, click Primary Key. Set the primary key, then discover foreign keys. Worked for me.
I'm a university student who is completely new to SQL and I don't know what I'm doing, so go easy on me. I have been given an assignment to design a Facebook-like database for a website for people who read books. I have made a very basic data dictionary which gives the general idea.
Is this a valid approach? Is there a better way of doing this? I'd appreciate any feedback I can get.
First of all, I would say good to see your efforts.
Here I would suggests you bit enhancements. Instead of maintaining different tables for
books_liked,books_read,wish_list, etc., you can maintain same with the help of flags in the master table books. This is to normalize your data.
eg. flg_liked, flg_wish_list, flg_read
I've started work on my first Azure application, and I'm learning a lot as I go. One of the features I discovered recently was Federations in SQL Azure, essentially the SQL Azure sharding implementation so we can scale horizontally.
My project started using SQL Server, and was already largely grouped by user Profile, so I decided that makes the most sense to federate on. I've created the federation, including all of the child tables with one snag - Identity is not supported. I get why it's not supported, what I'm not sure on is what best to replace it with. This seems like a huge problem that someone else must have solved, but I haven't been able to find much.
I could just use UniqueIdentifier, but I read that can be a pain to split on. I'm also not too sure of what other performance issues I could run into using a GUID as my Primary Key for federated tables.
I'm using this with Entity Framework, but haven't got to the point of making that federation friendly yet. From what I can tell, it's not much more complicated than executing some code to select your federation before writing your LINQ query, but I'll cross that bridge when I get to it.
For the moment, I have no idea how best to actually add items to my federation, because there is no good solution to generating an identity.
Any advice would be greatly appreciated.
I'm using the GUID when using the SQL Azure Federation, it's almost the best choice when data sharding. Assuming if you are using Identity in many federation members this will cause the duplicate of your primary value. When you need to merge the data back, or archive, how do you deal with these records.
People thought the GUID is low performance when data insert, especially if we use it as a clustered index. But I never met this problem. Or I should say, there are many tuning places we can do rather than this one.
So I can't talk to the EF question. But I can't comment on the idea of using Uniqueidentifier as your key type. This, in my mind, is the best choice. UniqueIdentifier is actually very easy to split on... the reason people think it's hard is they forget what a UniqueIdentifier is. The GUID that we all know and love is a Hex representation of a 128 bit integer. This means that we can use standard Integer operations with it and thus it's actually as easy to work with as the Int (aut number) you know and love.
While it's not specifically about SQL Azure federations (it's about Windows Azure Storage) this blog post of mine on using the GUID type for sharding should give you all you need to know.
http://www.syringe.net.nz/CommentView,guid,cebe3e19-85e6-4d5b-bc24-afb6f66aaeb1.aspx
Suppose I have a big database, about 800 tables. In this database there is a table that serves as a metatable describing all of the fields of the other tables in the database, for documentation purposes. This table is read by a self written tool of the company I work at.
I'm new at the company and I'm rather inexperienced, so please forgive me for asking this...
In SSMS 2008 R2 I want to make an entity relationship diagram, which seems possible, which is great. I also see that it is possible to show a description for each field in the diagram, without clicking on a table/entity first to show the descriptions. Is there any way to automatically insert the relavant data of the previous mentioned "metatable" into the description/note entry of each field of the corresponding table shapes in the diagram? I could do it manually but I thought I better ask here before I do anything stupid (lot of work). I thought about SQL Procedures, but the thing I am trying to do involves the description fields of the diagram editor itsself, so I don't think that is covered with Transact SQL.
BTW, if somebody knows how to set/show the cardinality of the relationships in the diagramm please tell me.
By the way, we (the company) have Visio 2007 too (not that it would solve any of the problems..), but I'd like to use SSMS 2008 R2 first to set foreign keys (which are not there) and then import that into Visio through the reverse engineering option. Seems more logical for me, instead of using Visio in the first step. Of course I'm using a backup of our database.
The diagram description is not a property of the diagram it is a property of the table itself.
See sp_addextendedproperty in SQL Server books online:
http://msdn.microsoft.com/en-us/library/ms180047.aspx
You need to add an extended property with the name 'MS_Description'.
For a useful extended description, see here:
http://www.simple-talk.com/sql/sql-tools/towards-the-self-documenting-sql-server-database/