Тёмный
No video :(

SQL Database Table Creation - A TimCo Retail Manager Video 

IAmTimCorey
Подписаться 419 тыс.
Просмотров 40 тыс.
50% 1

** TimCo source code now at: www.iamtimcore...
Full Courses: www.iamtimcore...
Mailing List: signup.iamtimc...
One-off tutorials are awesome but they aren't the only thing you should be doing to learn C#. Another vital part of learning is learning how to put it all together. This interactive course is all about putting the pieces together. You can watch each video on its own or you can watch them in order and see a bigger picture. The choice is yours.
This course focuses on real-world development. As such, we are simulating that we work for TimCo Enterprise Solutions on a brand new product, the TimCo Retail Manager. Just like in the real world, we are starting out with one set of requirements but know that over time they will change.

Опубликовано:

 

26 авг 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 204   
@mikemcgrumpy
@mikemcgrumpy 5 лет назад
For me (and probably many others), the most valuable parts of your videos is when you explain your thinking behind *why* you make certain choices (especially when you debate with yourself about a design choice mid-stream). I find watching someone ruminating over whether they should code or architecture something this way or that very helpful, well beyond just learning syntax or the framework. I hope to see some real debugging sessions down the track for the same reason. You can learn heaps by watching how a professional goes about identifying a real bug, and how they go about fixing it. Thanks Tim!
@IAmTimCorey
@IAmTimCorey 5 лет назад
I'm glad you appreciate it. I've debated leaving it in or not but I've come to the conclusion that people relate better when they realize I'm not perfect. And you are right, hearing how someone works through an issue can help you do the same. As for debugging, I'll be shocked if we don't have an intense debugging session or two in our future. I'm doing this project for the first time on video. I don't pre-create the content and then do it on video so, just like with any real development process, I'll make mistakes and have to fix them. That's part of coding. Besides, that is the best time possible to teach people how to debug.
@rafaeltab
@rafaeltab 5 лет назад
Yoyoyo, just got home, sat down, thought 'hey would there be a new tim corey video' and right and that moment I got a notification for this video. Like whaaaat how?
@IAmTimCorey
@IAmTimCorey 5 лет назад
Awesome!
@patrickdaems6558
@patrickdaems6558 5 лет назад
As allways a great tutorial. Never done the creation of the tables with Visual studio before I always did it with the SQL Management Studio. Like every I learned something new ;-) Thanks a lot Tim PS in Belgium you got different Tax percentage per product ( p.e. food is 6% a car 21%)
@IAmTimCorey
@IAmTimCorey 5 лет назад
I'm glad you enjoyed it and it sounds like the feedback was correct and the new way will better handle various situations.
@michaelkaip
@michaelkaip 5 лет назад
Hi Tim, thanks a lot for this great video series. I love the style you do it. Just had the idea, that it might be useful to also add a supplier table and refer to it from the inventory table. I think it make sense, because it allows, for instance, to rate different suppliers (ABC). Another thing I've in my mind, is to store from which suppliers a certain product can be ordered and to which price.
@IAmTimCorey
@IAmTimCorey 5 лет назад
I will add it to the list. Thanks for the suggestion.
@michaelhaddad2190
@michaelhaddad2190 5 лет назад
Oh yeah, best tutorial ever is here again.
@IAmTimCorey
@IAmTimCorey 5 лет назад
Thanks!
@grampygamer8584
@grampygamer8584 5 лет назад
As a fellow dev (for me just after punch cards.....) I love how you structure your courses, like you would a IRL project. Breaking things down into small bite size chunks. Great work! Looking forward to the .NET Core aspect of this project. Great to see things like these courses you lovingly prepare, evolve.
@IAmTimCorey
@IAmTimCorey 5 лет назад
I appreciate the kind words.
@moihawk666
@moihawk666 4 года назад
Heck yessss I've always wanted to do my database work in studio but never really knew how to ..... GOOD BYE MANAGEMENT STUDIO!!!!! (well not really but you know)
@IAmTimCorey
@IAmTimCorey 4 года назад
It is pretty awesome.
@NiquelBones
@NiquelBones Год назад
for the "last-modified" field of the product table you could use an event that updates it every time the table is updated
@IAmTimCorey
@IAmTimCorey Год назад
You can, but that can be a lie eventually, which is why I'm not a huge fan of doing it that way. Imagine you use a system where an order is captured offline. When you get back online, the data syncs. However, if the field updated automatically on insert, you might see multiple orders with identical times when in reality, they were ordered well before that modified date.
@TheKevlar
@TheKevlar Год назад
I am not a fan of using triggers as a software developer. We leave Triggers for client customization that way version upgrades do not overwrite their business logic...
@vrace271
@vrace271 5 лет назад
I am using your tutorials to build an application for organizing tasks ... a bit of twist in terms of the idea but following exactly the same principles and techniques which you are using. Thanks a lot ... you are making it look all so simple!
@IAmTimCorey
@IAmTimCorey 5 лет назад
Awesome!
@scwyldspirit
@scwyldspirit 5 лет назад
Tim I know from one of your other courses you are a huge fan of dapper. I prefer code first migrations. When you are creating your classes you can setup either data annotations or use the fluent api to construct out the table design you prefer
@benetnashetamime650
@benetnashetamime650 5 лет назад
This is exactly what I was going to ask.
@IAmTimCorey
@IAmTimCorey 5 лет назад
Yep, I prefer Dapper (especially for full .NET Framework projects since EF6 is slow on top of the other issues). My biggest issue is all of the auto-generated code that EF creates that you then have to maintain (I've seen that go very bad a couple times). I've considered using EF Core for part of this app once we convert to .NET Core and I'm still kicking that around. Either way, I'll probably do a video or two on EF Core at some point.
@tinumurymury38
@tinumurymury38 5 лет назад
Hello Tim, Big picture in mind, from experience, in time the quantity column type will probably have to change to store decimal points, usually up to 3 (at least for the metric system). If the store sells products by the pound or kilogram, you should be able to enter decimals. Again, in time, the Sales table could store the payment method (cash, card, check etc.) and the amount for each one. Sometimes the customer wants to pay cash and credit etc. Great video as always. PS: as I remember, the Jaffa cakes case was about them being classified as cookies or cakes.
@IAmTimCorey
@IAmTimCorey 5 лет назад
Interesting. I hadn't considered partial quantities to handle goods that are sold by weight. It would seem like we would then need to add in a field that identified what the number represented (items, pounds, kilograms, ounces, liters, etc.) I'll have to think on that, since it makes things more complex. I'd want to include it in the easiest way possible. I'll add splitting the payments to the list. It is something we can add in down the road without difficulty. Thanks for the suggestions!
@nasben66
@nasben66 5 лет назад
@@IAmTimCorey as tinumurymury38 said all you need to do just change the type from int to decimal with 3 decimal points, this way to calculate the sub-total it's just the purchaseprice * qty
@nasben66
@nasben66 5 лет назад
Hi Tim, Thank you for the nice video, few suggestions I think we do need discount fields, also if you going to handle Tax then we need to know which items have tax on them, so in the product table I think you need to have TaxCode i.e 1,2,3 etc if you going to allow for more than one TaxCode or just check box to say if the item is Taxable or not, , also we need to have a settings table which need to hold the general settings for the business i.e. name of the shop, address, telephone numbers and the value of the TaxCode can go into this table, i.e. in the UK the VAT as we call is 20% which has changed few years ago from 17.5% so if it changes again then we will only change it in one place.
@IAmTimCorey
@IAmTimCorey 5 лет назад
Don't you love how complicated it gets to do something "simple"? Thanks for the suggestions. We will discuss taxes and what to do with them in an upcoming video. I'll add this feedback to the list to discuss.
@harag9
@harag9 5 лет назад
@@IAmTimCorey Agree with nas ben, I think you need a tax code on each product, as some products are not "VAT" rated (e.g. food) in the UK. - e.g. the issue with Jaffa cakes being luxury or food item.
@HenrikRClausen
@HenrikRClausen 4 года назад
So far, so good (I'm taking this as a refresher. Lots of nice details in there!). One question: How come my tables ended up under 'Projects' rather than 'SQL Server'? Everything seems OK for now, but I'd like to be sure that I don't run into trouble later.
@IAmTimCorey
@IAmTimCorey 4 года назад
The Projects folder you are referring to is just a visualization of the SQL database you are building. When you publish your database, you will publish it under SQL Server.
@talkathiriify
@talkathiriify 5 лет назад
Hi Tom, Glad to see you with a new video Innovated as usual. Thank you very much
@IAmTimCorey
@IAmTimCorey 5 лет назад
You are welcome.
@arlandmv4053
@arlandmv4053 4 года назад
This is gold!
@IAmTimCorey
@IAmTimCorey 4 года назад
Thanks!
@EmmaCG2X
@EmmaCG2X 4 года назад
Hi Tim! First time in the comment section but I am trying to watch all your videos since the beginning of the year. You are the best, your explanations and projects are helping me a lot while trying to get my first dev job. Regarding about the database setup, it always gives me headaches when it's the moment to name the tables. I see that you are using a singular naming convention, but I see others use a plural convention. It's just a detail, but do you know what's the best approach? Thank you so much and greetings from Argentina!
@IAmTimCorey
@IAmTimCorey 4 года назад
Good question. It is actually one I flip flop on. There is a case to be made either way. The key is to just be consistent in your database. Beyond that, I don't think there is one clear winner.
@marmictanghus
@marmictanghus 4 года назад
In Denmark we our sales Tax is called MOMS And it is 25%
@IAmTimCorey
@IAmTimCorey 4 года назад
Interesting.
@harag9
@harag9 5 лет назад
Great Tutorial Tim, thanks for explaining your changes and thoughts. However I did have a "What!" moment when you changed the user table. I think you should have kept it the way you had initially with a Primary Key on the Id as INT and then have the AuthUserId. The CashierId would then be an INT field (I would have named it "UserId" though) - because you have a separate database I think you should keep them separate as much as possible and the one link in the user table to the auth tables should be the only one. Having the CashierId as int, will also mean retrieving data from that table will be quicker (once you add an index to it) again, would be better to index INT tables than nvvarchar() for performance reasons. By having the Id on the user table as nvarchar(128) every time you insert a new row, it will be slower as you explained, due to re-indexing / sorting etc. You should NEVER have a nvarchar column as a primary key really. Foreign Keys - You've not got any, so dirty data can be inserted / left behind. I've read in a comment below that you will be adding these in, but it might have been worth mentioning it in the video, along with extra indexes on the table. But still a great tutorial!
@IAmTimCorey
@IAmTimCorey 5 лет назад
This is one of those exceptions to the rule where you need to look at the bigger picture. For every API call, I will know the user's GUID. I will use that to get their info, identify who they are, and more across a number of tables. If I need to first translate that GUID to an ID, I will need to make an additional database call every time the user calls the API. That is expensive. Compare that to how often we add new users to our system (not very often, even if we are including customers in that table) and the benefits of an int ID are outweighed by the drawbacks in this particular system. This is why I try hard to not say things like "never". There is an exception to every rule. SQL can handle this one exception and the slowdown on insert will not cause a big issue, especially since it will make every subsequent call the user makes faster. We will be adding Foreign Keys to the database in an upcoming video. Index tuning doesn't happen until the end since you really should not optimize until you can observe.
@ArticcTrinax
@ArticcTrinax 5 лет назад
What's your thought on using Code-First instead of manually creating the database?
@IAmTimCorey
@IAmTimCorey 5 лет назад
I'm not a huge fan of EF, although EF Core is trying to win me over. I'll be doing a video soon on it.
@karatekid559
@karatekid559 5 лет назад
Hello Tim just putting this message here for all other viewers. I'm on Visual Studio 2019 and whenever I attempt to edit anything in the bottom half text rather than on the top design it crashes Visual Studio. So if you're on VS 2019 be sure to save and then maybe test it yourself. It would be a shame to do all the work, attempt to make one change, and lose everything. One quick sidenote, sometimes it won't immediately crash it, but after you make a change in the bottom text based window go to properties and you'll notice that identity specification wont have the + next to it anymore.
@IAmTimCorey
@IAmTimCorey 5 лет назад
Update your version of Visual Studio. They fixed this in one of the most recent patches (I put in a support ticket on it).
@aaronhernandez1447
@aaronhernandez1447 Год назад
Hello Tim, this is another excellent tutorial. I am a little bit confused with this process of creating database and tables. I would think that possibly in the following videos I will find an answer to this following question. Where is the data being stored exactly in? to be more specific, where is data going to be saved? I am possibly asking a silly question. Thank you. I can see that tables were published to local database. So, I am understanding this up to this point. I guess my question would be. What about if I do not want database to be local? or need to store data at another location examples, a shared folder, another computer, or hard drive? It is possible that I will get my answer as I continue learning this MVVM programming process 🤔....
@aaronhernandez1447
@aaronhernandez1447 Год назад
I guess, I found my answer which it has to do with AzureStorageEmulator which mimics what can be done when using Azure services. In this case tables, blobs and Queues. Main purpose is for testing purposes before deploying to azure services. In my case I will be using azure services. Thank you again for such great tutorial.
@ukaszpytel334
@ukaszpytel334 5 лет назад
Hi :) I recomende to consciously change table constraints name in SQL. instead: PruchaseDate DATETIME2 NOT NULL Set: PruchaseDate DATETIME2 NOT NULL CONSTRAINT PruchaseDate DEFAULT getutcdate() It works the same but on Your DB after deploy you got: DF_PruchaseDate instead: DF__Inventory__QUANT__3F466844 It's easier to in futher maintain
@IAmTimCorey
@IAmTimCorey 5 лет назад
Yeah, those auto-names can be rough.
@nove1398
@nove1398 5 лет назад
Nice video man, looking forward to more videos with connecting to remote sql server instances with asp.net as well.
@IAmTimCorey
@IAmTimCorey 5 лет назад
When we publish this application, we will be connecting to a remote SQL Server. There isn't much of a difference compared to a local copy. Just change your connection string and you are done.
@nove1398
@nove1398 5 лет назад
@@IAmTimCorey Thanks for the fast reply. I thought there was more to it than the connection string, appreciate the education tim
@hashimkz
@hashimkz 3 года назад
Hi Tim, Would there be any downsides to creating your tables in the database EF created for you? I don't really see the point in creating a separate database when you could just use the EF generated one, and modify/use the ASP users table instead of creating a new users table. Thanks.
@moneymaker7307
@moneymaker7307 5 лет назад
Hello Tim, Great tutorial, but I have a question. You did not talk about how the userId that have a relationship to the Id in the identity table or the table entity frame work created. This are completely different database so how would you link them together?
@IAmTimCorey
@IAmTimCorey 5 лет назад
I mentioned it briefly in an earlier video but we will actually implement it when we wire up the API. Basically, when a user logs in, we know who they are on every call. We will use that to associate their EF-created ID to a table in our SQL database. For now, we will populate the record manually. One of our sprints will include adding a system for creating user accounts.
@vladimirmilatovic
@vladimirmilatovic 5 лет назад
I must add that I have to pause watching this video and check this about jaffa cakes. Those cakes are one of the most popular cakes in my country and that's not UK. I didn't try UK version but I hear that is our is better. Jaffa from Serbia.
@IAmTimCorey
@IAmTimCorey 5 лет назад
Did I make you hungry?
@grampygamer8584
@grampygamer8584 5 лет назад
I prefer chocolate digestives :)
@motherlandmuzik
@motherlandmuzik 5 лет назад
I must have missed the part where entity framework created the database tables that you are using as a reference , Can someone help?
@IAmTimCorey
@IAmTimCorey 5 лет назад
The EF database gets created automatically under certain circumstances. Later on in the course, I do recreate it manually. If you want to see how that is done, go here: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-sMPbsA7OTtM.html
@wisedrawesome
@wisedrawesome 5 лет назад
Hello Tim, Great series, looking forward to see the project evolve. Having a few questions to your database design. Seeing a lot of ways this design can end up with inconsistant/partial data, due to a single partial update, that could easily be avoided with another design. 1. Maybe Tax should be in percent and have e.g. EF/code calculate the actual tax and provide that as an extra virtual attribute? 2. Again why not take advantage of e.g. EF/codes ability to fluently calculate all those calculated values (sale total, total tax, etc.) for you and provide those as virtual attributes? I get that it would be nice to query the database and have everything handed to you but imo that is not the job for the db. The db should not be able to provide inconsistant/partial data.
@IAmTimCorey
@IAmTimCorey 5 лет назад
Here is my opinion on this: this is a mindset that is slowly changing. Here's why: you are optimizing for size. I am optimizing for speed. It used to be that we needed to keep database size down. Now storage space is cheap. What isn't cheap is our time. The longer something takes, the less likely we are to do it. By calculating and storing the tax, sub-total, total, etc. in SQL, we are optimizing our system to retrieve that data faster. The danger is, like you said, we get inconsistent. In that case, we will need to recalculate. However, SQL is not really the place to do monetary multiplication (tax calculation). Doing so means you need to use the decimal type and you need to be careful about rounding. Addition/Subtraction isn't a problem. So, I do my monetary calculation in C# once and store it. If I ever had a consistency issue, I would need to address it in a larger manner. You REALLY don't want to have your calculation change after the fact for the amount of tax you charged. If you say you charged the user $1.50 in tax today (and that is what you presented to them), you don't want to "recalculate" it tomorrow and say you charged them $1.25. Otherwise you would have an "extra" $0.25 floating around unaccounted for. Right now, we are doing the calculations and presenting them to the user. They should never change again.
@Balgoriusis
@Balgoriusis 4 года назад
Great stuff as always but I really missed those foreign key constraints, any reason not to include them?
@IAmTimCorey
@IAmTimCorey 4 года назад
We will add foreign keys in. I believe it is coming up soon in the series.
@RonnyRusten
@RonnyRusten 2 года назад
I have been using Entity Framework for a long time (model first), and I have been looking for an alternative way to do things. This looks promising, but a bit more initial work, I guess. I can see that in the long run this might be just as easy. Looking forward to the rest of the videos. One question though; why do you stage things before committing? I really don't see a good reason for that, but I'm very new to Git. I have been using TFS where it's called check in, and staging isn't an option...
@IAmTimCorey
@IAmTimCorey 2 года назад
The reason to stage things before committing is because sometimes you might want to make two commits out of one set of changes (two different things were done). In that case, you wouldn't stage everything. Also, there are times when you don't want to commit a changed file because you aren't pushing those changes centrally. For example, you might change a connection string locally to test things out, but you don't want those changes being committed.
@RonnyRusten
@RonnyRusten 2 года назад
Ok, yes, I see. In TFS you have the option to exclude files from check in, this is not possible in GIT, so then the stage makes sense. You probably has the habit of doing that, but so far in this series, it hasn't been necessary, I guess.
@NeilSearle
@NeilSearle 4 года назад
Excellent video, I am finding all your C# tutorials seriously helpful thank you. However 21:02 'In the England'.. really? ;)
@IAmTimCorey
@IAmTimCorey 4 года назад
😂 Yeah, my brain skipped a beat there and my mouth kept talking.
@Rothbardo
@Rothbardo 3 года назад
Hey Tim, a little feedback. Using stringauthId has some downsides. Aside from slower joins with a larger data type, also not having an identity column is essentially going to make the table a heap instead of a sorted clustered index. Also, with a guid/string, new records could potentiallyy have to be put in older hard disk page files that are partially full .... until that actually fill up, This could cause data to have to be moved around on disk, which is a bigger perf hit.
@Rothbardo
@Rothbardo 3 года назад
Also, using nvarchar(max) is definitely an antipattern
@Rothbardo
@Rothbardo 3 года назад
Having a LastModified date is exteremly beneficial if the data is ever going to be used in a reporting system / data warehouse
@IAmTimCorey
@IAmTimCorey 3 года назад
The Id for the user is a string because that is the ID we get from the authentication system. Just because it is a string does not mean it isn't a primary key. Not having a primary key is what causes your table a heap. The Id field is marked as the primary key for the table. Yes, not having the benefit of inserting in order can be a perf hit, but it is a small one and one that is worth it for certain scenarios like this one. As for nvarchar(max) being an antipattern, that is not true. There is a purpose and a reason behind nvarchar(max). The key is to use it only when appropriate. That's what I did. Note that the only time I used it was for the product description, which can be a significant amount of text (more than 4,000 characters). As for the LastModified, yes, that can be beneficial and I considered it. The balance I'm trying to hit with these videos, though, is time vs benefit. Adding additional columns and maintaining them takes additional time. It doesn't give a lot of additional benefit. I did add it to the Product table but not every table in order to demonstrate the action but not have lots of repetition.
@michelchaghoury870
@michelchaghoury870 2 года назад
great video I just have a question @IAmTimCorey, When to use plural names for our tables (ex: Sale, Sales, and User, Users) i see some developers using singular and other using plural, wich is more prefered and what is the best naming practices for tables in SQL Server, Thank you and keep going
@IAmTimCorey
@IAmTimCorey 2 года назад
It comes down to personal preference. I don't have a strong feeling on it. Some say that User.FirstName more clearly demonstrates a specific user while others say that the Users table more clearly indicate it holds multiple users. In the end, just be consistent.
@slinky7355
@slinky7355 2 года назад
I've worked at a place where the official convention was singular but the reality was a complete mixed bag. My personal preference is singular as plural doesn't add any useful information. It should be self evident that a table called User doesn't contain a single user.
@rafaspimenta
@rafaspimenta 4 года назад
Hi Tim! First of all, I'd like to thank you in advance, because you are doing a great job here. Just one question, why did you not use the EF to generate automatically the DB and tables based on the mapped entity classes? Thank you again!
@IAmTimCorey
@IAmTimCorey 4 года назад
I am not a fan of using Entity Framework: www.iamtimcorey.com/blog/137806/entity-framework
@UrzaRage778
@UrzaRage778 3 года назад
When committing the changes for this section, I also had a, "TRMData.refactorlog" file added... I assume this is something new implemented for Data projects? Hopefully nothing weird/breaking for this series 🤞
@vladimirmilatovic
@vladimirmilatovic 5 лет назад
Hi great video. I see you struggle with pk as I. I am not a big fan of identity and using it as PK. Reason is that it not provide uniqueness of record in meaning that it is not a part of useful information and it allows you to create several records with same informations. Please correct me if I am wrong. I prefer natural PK. Off course, I use surrogate key when I don't have other options. I read about that nature key can become very complex and index file can become bigger than the table. Please for your opinion. Thanks.
@IAmTimCorey
@IAmTimCorey 5 лет назад
I'm on the other side of the fence on this issue. I much prefer surrogate keys (auto-incrementing numbers that have no other meaning) for a couple reasons. First, natural keys can change. Email addresses can change, phone numbers can change, people can get other people's phone numbers, addresses can change, and even sensitive information can change. Also, laws are starting to prevent the use of sensitive data as natural keys because of security concerns. Now you are left without good solutions for a LOT of tables. To add to that, you have a performance hit every time you store a record (records are stored in order by primary key so inserting a new record means shifting all of the existing files on disk "down" for any records after the new record in order). You also have a performance hit when you try to link to the table (linking on multiple rows, text, etc.) All in all, I don't see the benefit (other than saving yourself one int column of "extra" data).
@vladimirmilatovic
@vladimirmilatovic 5 лет назад
@@IAmTimCorey that's exactly what I was expecting to hear. Thanks for taking me from the dark side of the force.
@harag9
@harag9 5 лет назад
@@vladimirmilatovic You can always create "unique" index on data columns, e.g. email address. I personally prefer to have [Id] PK columns on tables, and disagree with the user table Tim created.
@LuisFernandoForeroGuzman
@LuisFernandoForeroGuzman 4 года назад
Hi Tim, I wonder why you didn't use a code-first approach for this project?
@IAmTimCorey
@IAmTimCorey 4 года назад
I am not a big fan of Entity Framework. I'll be doing a video on it sometime soon but I prefer the control and speed of Dapper.
@mohitgupta2769
@mohitgupta2769 2 года назад
Wondering if it makes sense to setup a trigger on Product table, to update the LastModified field to latest datetime whenever that table row is updated?
@SuperDre74
@SuperDre74 4 года назад
I'm not really fond of the CashierId name as now I could expect it to have a separate table Cashier.. I think CashierUserId would be better as it at least makes you think it's the userid of the cashier.
@IAmTimCorey
@IAmTimCorey 4 года назад
It all depends on what works best for you (and your team).
@ZoidbergForPresident
@ZoidbergForPresident 5 лет назад
19:00 Wouldn't it be better to call that cashierID field, refUserId or something linking it to the other table? It's logically a foreign key, right?
@IAmTimCorey
@IAmTimCorey 5 лет назад
That isn't my preferred naming method. It doesn't read well and it doesn't describe what that field actually holds. Is that refUserId a cashier or the customer? What if you added another column for floor manager (who was in charge of the cashier at the time)? What would you call that column? refUserId2? I like the idea of trying to communicate that it is a foreign key but that is what Id does. It indicates that the column is an identifier column (a moniker I reserve for primary and foreign key columns). The only thing it doesn't do well is tell you which table it refers to (although the column details will communicate that).
@grampygamer8584
@grampygamer8584 5 лет назад
I think from a tutorial point of view, it's sufficient.. but yes, if you where going to create this as a Full Production Application, I think you would need to look at the required data and do a full Database normalisation process and a Full ERD (Entity Relationship Diagram). I see this initial stage of design, more of a prototype.
@rodrigo6459
@rodrigo6459 5 лет назад
Great info as always Tim! Today i Just found some time to catch up, have been working HARD on creating an app for Raspberry Pi 3 working with Windows 10 IoT!. do you think you can do a video on creating Windows Universal Aplications?
@IAmTimCorey
@IAmTimCorey 5 лет назад
I can add it to the suggestion list.
@mohitgupta2769
@mohitgupta2769 2 года назад
I am confused why are we maintaining two different databases? One for Auth Users and one for our Retail Manager? Can't the two be merged? Or just for separation of concern?
@IAmTimCorey
@IAmTimCorey 2 года назад
I keep it separate for separation of concerns. Just best practice.
@deathofthemagi
@deathofthemagi 2 года назад
Sorry if you answer this later in the video but it seems we are moving on from the topic and I wanted to make sure to ask. You said to start the seed at 1 , at work I was building a ticket system and they were insistent that I seed the DB at 1200. They did not give me an answer when I tried to find out why. Is there some benefit to seeding a table at a higher value? It was an ID that is visible to the end user (internal employee) so it's not like they were trying to stop them from guessing an ID. Obviously it can be useful for some reason since we are given the ability to change the seed but I can't think of anything outside of wanting customers to think you have been doing this for a while or preventing ID's from being guessed by using a higher Seed and a higher increment.
@beautifulheartsoothingreci28
@beautifulheartsoothingreci28 3 года назад
Question: Don't we need an "AccessToken" column in the User table so we can use it for subsequent calls to the api?
@Empathies92
@Empathies92 3 года назад
I think we're going to store the AccessToken in a variable while the program runs as it's only valid for x amount of time. + if anyone were able to recover information from this database (in any way) they'd have access to all those tokens, which could pose a security risk. With just the UserId there's nothing anybody can do.
@craigmartin3267
@craigmartin3267 4 года назад
Hi Tim, I am really enjoying this course thanks for all the effort you put into it I have a question regarding the use of visual studio to create the database, can you explain the difference between using visual studio and MSSQL Server Management Studio and which is the better option for a small database with around 10 to 15 tables
@IAmTimCorey
@IAmTimCorey 4 года назад
Using Visual Studio to create your database allows you to use source control and to deploy it with your code. Using SSMS is the traditional way and does not offer either of those benefits natively. SSMS is better for database management. Visual Studio is better for database development.
@craigmartin3267
@craigmartin3267 4 года назад
@@IAmTimCorey Thanks a lot Tim that is very helpful for me
@harryperales
@harryperales 5 лет назад
Hi Tim, thanks for always making time to create this wonderful videos. Are we gonna go about building the WPF app on the next video? I'm just a bit eager to get started developing a wpf app, i've been a winforms developer since visual basic 2.0/delphi 2.0 and i've been wanting to get started making wpf app but was a bit reluctant, because i don't really have the time to figure things all by myself. Well thanks to you, that could change. :D
@harryperales
@harryperales 5 лет назад
my bad i had jumped to the comment before the last few seconds of the vid :)
@IAmTimCorey
@IAmTimCorey 5 лет назад
Good luck on your WPF project. I do recommend you build a few test applications in WPF before jumping right into a "real" application. It will make your life easier. I cover that in this video: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-h7aIzCkmbl8.html
@patrickdeault6503
@patrickdeault6503 2 года назад
Maybe this is addressed further in the series, but what about when you have two batches of purchased products and the sale uses up the last of one batch and pulls from the next batch to fulfill the sale. The purchase price would be different for the same item. Ex: sale for 10 shirts - inventory has 7 shirts purchased at $2 each, and the next 1000 shirts were purchased at $1.50 each. I assume you would take care of this in the logic as technically the ItemId's in the inventory would be different when they are purchased? Would that mean that you'd show the user that there are only a quantity of 7 X-batch-shirts left in stock, so the store would show a separate item of Y-batch-shirts with a quantity of 1000 remaining? I think this is a fairly simple problem but just wondering how you would solve this one. Thanks, Pat
@Jogvann
@Jogvann 2 года назад
I think the solution is that the user would still see the total number in stock, and then just use logic to see that the oldest stock of shirts was bought for $2 but there was only 7 left, and then make a new db entry for the other 3 at the new price. The ItemId should be the same if it's the same product. It would just exist multiple times in the Inventory table, one row for each batch that the store has purchased.
@NeilSearle
@NeilSearle 2 года назад
The price that the user will see is RetailPrice in the Product table which is independent of the stock purchase price which is used internally to calculate markup. The stock level would just be product line summed up. You could write business logic that would calculate the total PurchasePrice of the purchased items from different stock entries in order to get the aggregate markup.
@mov4736
@mov4736 3 года назад
Hi Tim, I have three questions: 1) for the LastModified column, rather than updating manually, wouldnt it make more sense to use a trigger? (probably beyond the scope of this series) 2) My publishLocations folder shows me an empty folder despite the profile existing (doesnt get shown in visual studio), do you happen have any idea about this? If I publish the entire DB project rather than the profile, would I still get the version control and other benefits? (I am using the latest VS available today) 3) I am aware that testing is important but what is your opinion on TDD (Test-Driven Development)? thanks in advance :)
@avav3457
@avav3457 3 года назад
I'm having the same problem with the PublishLocations folder. In the Solution Explorer I click the Icon to "Show All Files" and several files appear, including the publish.xml. However, when I go to SQL Server Object Explorer my tables are not showing up in the SQL Server DB, but in a folder labeled "Projects".... No idea where that folder came from... I'm trying to follow the tutorial step-by-step, but I'm not getting the same results. @alireda - Did you ever figure out what the issue with your PublishLocations folder was?? Thanks
@mov4736
@mov4736 3 года назад
@@avav3457 Hi, Sorry for the delay, I just saw it. Nope, I restarted the series from scratch on a new system. and it seems like an issue with the older visual studio version.
@danail_iliev
@danail_iliev 4 года назад
It is a good idea to start your IDs from a higher value than 1, i.e. 100, because this enables you to set aside the DB slots (those first 100 users) for system users, administrators, moderators etc. That's my thought, I hope it makes sense.
@IAmTimCorey
@IAmTimCorey 4 года назад
I don't do this because I don't reserve specific numbers for specific people/roles. My rule is to not apply meaning to an auto-generated number. It is just an identifier. Trying to force it into a system as well makes the system fragile.
@adamschneider868
@adamschneider868 3 года назад
What happens when your organization exceeds 100 system users?
@beautifulheartsoothingreci28
@beautifulheartsoothingreci28 3 года назад
@@adamschneider868 exactly
@parko1965
@parko1965 4 года назад
In your sale table why would you have SubTotal and Total columns if they will be calculated values? I think they are unnecessary fields in the DB.
@IAmTimCorey
@IAmTimCorey 4 года назад
Speed of querying. Instead of doing a calculation for each of them when I need those values, I just ask for them. This is especially important when you have hundreds of sales and want to do a sales report. Instead of calculating values for each sale and then totaling them up, you just do the total. Also, by providing these values, we know what the actual sale value was at that point. If the tax rate changes or there is a slightly different rounding value, the numbers could look different then they actually were.
@parko1965
@parko1965 4 года назад
@@IAmTimCorey Tim, but normalisation eliminates these fields, which in effect reduces bandwidth and load on the DB server. Why don't we just have the client app do the calcs.
@IAmTimCorey
@IAmTimCorey 4 года назад
Normalization isn't done in a vacuum. You need to take into account how you will use a database, not just blindly normalize a database. In this case, it is more efficient to have these two fields rather than re-calculating them each time you need them. As for having the client app do it, there are a couple problems with that. First, that means you now need to load all of the transaction child records when doing a report, not just the summary record. That is a LOT more transmission across the wire (greatly increasing your bandwidth usage and your load on the database). Second, we are trying to avoid doing the calculations repeatedly in the first place. Also, since the calculation is what they paid, it is also a protection against future changes such as tax rates, product rates, etc. that might change what the total would become.
@parko1965
@parko1965 4 года назад
@@IAmTimCorey Ah yes, so where ever its practical, I get it. Thanks Tim.
@SuperDre74
@SuperDre74 4 года назад
@@parko1965 Ok, now you have one million saleslips which each have multiple items, what do you think would be faster? having to recalculate ALL totals, or just getting the totals itself. Also it has another benefit (not a situation you hope would happen), if a record in the item goes missing, you still have the original price (and you can have a check on that). I agree with you that there are more than enough times you don't record a total in a separate field.. But in this case I would also do it, so I only have to get the data from 1 table when I want to have a report of all the saleslips..
@olanrewajuatanda533
@olanrewajuatanda533 4 года назад
Please, how do I resolve this error? "A project which specifies SQL Server 2016 as the target cannot be published to SQL Server 2014" Thank you as you provide a solution. Thanks
@IAmTimCorey
@IAmTimCorey 4 года назад
Your SQL project is expecting to publish to SQL Server 2016 but when you publish it, you are pointing it at a SQL Server 2014 server. To fix this, you can either point it to a different SQL Server to publish or you can go into the properties of your SQL project and change the target version to SQL Server 2014.
@WaqasAli-ev7ge
@WaqasAli-ev7ge 5 лет назад
Advance Thanks before watching
@IAmTimCorey
@IAmTimCorey 5 лет назад
You are welcome.
@WaqasAli-ev7ge
@WaqasAli-ev7ge 5 лет назад
@@IAmTimCorey Sir, I am waiting for the next video. Please upload soon.
@kolavennusreeram2870
@kolavennusreeram2870 Год назад
Sir! Could you please provide me the proper playlists for sql?
@umairrajan
@umairrajan 4 года назад
Hi Tim great content. One question though how come you did not use any foreign keys at all? as in i should not be able to delete a Product if there was an inventory line for it.
@IAmTimCorey
@IAmTimCorey 4 года назад
There are foreign key relationships set up in our database.
@ErinMcLaughlin
@ErinMcLaughlin 4 года назад
What would you use as the Id in the User table if we were using Windows authentication instead? Using Windows auth does not generate a database in the same way that the individual user accounts option does. We could use the username here, but that doesn't seem ideal since technically IT could reissue an old username to a new user. Is there some kind of unique ID built into Windows auth that we could use here? Thanks!
@IAmTimCorey
@IAmTimCorey 4 года назад
I thought that even with Windows authentication that the record got an ID.
@nogo1880
@nogo1880 3 года назад
In the past, I got this to work using OPENQUERY in SQL, which uses LDAP to query Active Directory to get guids assigned to AD accounts. Below is the article I used to OPENQUERY in SQL. You could create a stored procedure, and then call it from the application: blog.sqlauthority.com/2016/03/30/sql-server-query-active-directory-data-using-adsi-ldap-linked-server/ Here is a Reddit post that will help if you have a large number of user accounts: www.reddit.com/r/SQLServer/comments/4dsck7/active_directory_query_for_users/ Being that it works with SQL, I figured there must be an assembly you could reference to do this. Sure enough I found an answer. Here is a StackOverflow response where they use the System.DirectoryServices.AccountManagement namespace to get the guid: stackoverflow.com/questions/27447823/get-guid-or-native-guid-from-active-directory You'll have to keep in mind that regardless of the direction you take, you'll have to be conscious of Active Directory permissions. And if you're using local user accounts (not Active Directory), the SQL solution won't work. But I believe the StackOverflow solution will, with some changes. You'll probably have to modify it since I don't think the domain context will work without a domain. Hope this answers your question
@Nick-bu5lu
@Nick-bu5lu 4 года назад
Hi Tim, on my Server Explorer at Data Connections I only have a DefaultConnection to TRMDataManager, how do I add localdb to my Data Connections? I published the database to localdb but I cannot see it. Thanks
@IAmTimCorey
@IAmTimCorey 4 года назад
You might need to add a connection to the LocalDB. Normally it is mapped if you have it installed though. Check your installation of Visual Studio to be sure you have "Data Storage and Processing" installed. Go to the Tools menu and look under the first option "Get Tools and Features" to check. If it is installed, you will just need to open up SQL Server Object Explorer and use the Add Connection button at the top to add a connection to LocalDB (the same path as what you published to).
@Nick-bu5lu
@Nick-bu5lu 4 года назад
@@IAmTimCorey Thanks for the reply, that's basically what I did. But I needed to start localdb from the command prompt first. I followed the instructions listed here stackoverflow.com/questions/21563940/how-to-connect-to-localdb-in-visual-studio-server-explorer/30098918#30098918
@Eric-im6nn
@Eric-im6nn 4 года назад
Thanks a lot! I encountered a problem: design view not showing when creating the table, and vs2019 would crash and restart when I click around..it looks like many people on the net also have this problem but not solved. any idea why this happened?
@IAmTimCorey
@IAmTimCorey 4 года назад
I had an issue with this about a year ago but updating Visual Studio fixed it. Check to see if you have the latest update. If you do, you might have a bad installation.
@Eric-im6nn
@Eric-im6nn 4 года назад
@@IAmTimCorey It's the latest version. solved by reinstalling vs. Thanks!
@objectaware5296
@objectaware5296 5 лет назад
Great Video! Why no foreign keys? W/o them the chance of a corrupted database increases does it not? As an aside, I believe all tables should have created, modified and modified by columns as it they provide a means to archive and to provide time period reporting such as yearly closing, quarterly reporting, etc. There is also the question of concurrent access so the records should contain rowversion as we already know that this is a concurrent user application.
@IAmTimCorey
@IAmTimCorey 5 лет назад
We will be adding foreign keys, although there won't be cascading deletes, etc. attached since we won't be deleting records. As for the other columns you are wanting, these can be added later if necessary. Right now I don't think they are at this level. As we get bigger and want more features, maybe. As for the first part with who and when, that is better suited (in my opinion) to an archive table since last modified date/user only tells us the latest info, not a history. Not terribly useful. Instead, if I REALLY need it, I put an insert/update/delete trigger on the table that logs the new values, who did it, and when. That way you can get a history of the data all the way back to the beginning for any row. The concurrency issue isn't really an issue until we get into allowing offline access or until we start allowing heavy modifications of critical data. For instance, we won't be modifying purchases, inventory records, or pretty much anything except item quantities (and that will be in transactions and will be decrements, not overwriting the inventory amount). Therefore, we don't need heavy modification protection.
@objectaware5296
@objectaware5296 5 лет назад
Great on the foreign keys. I do believe that cascading deletes have a place at the table even if the final product would rarely use them. I've seen too many instances where I need to delete test data where deleting a single row also deletes the dependent rows. It is a valuable time saver in that case and in future cases where you wish to move the data off. The other fields are included not so much for creating an audit history but for accountability. Are they necessary for every record type? No. But the process to provide the information simple. Having the information available from the start allows so many possibilities, e.g. closing the books, archiving, and reporting not to mention ETL. Concurrency, IMHO, is an issue as this application appears to be a SOA that could have multiple UI clients hitting it at some point. Might as well have the rowversion in place to handle the eventuality - consider Inventory where the same item needs to have the quantity reduced because of a sale. Thanks for considering. By the way, I learn something new from each of your lessons and I'm a Patreon.
@nogo1880
@nogo1880 3 года назад
Other than having the Id on our User table match the data type of the Id field in the Entity Framework AspNetUsers table, is there a reason that we are storing guids in the database as nvarchar(128) instead of using the uniqueidentifier data type? The performance when querying a field with a uniqueidentifier data type is better than querying an nvarchar field. And in terms of storage, the uniqueidentifier field is the better data type since it's smaller than nvarchar(128). I know this is a small project, so none of that will matter. But if you're building a large POS system for a retail chain, would you still use nvarchar(128) or would you design it differently?
@IAmTimCorey
@IAmTimCorey 3 года назад
I talked about this when we set up the guid to be the unique identifier. Yes, I would definitely do this in a large POS application because the way I did it is more performant. The trick with evaluating performance is to evaluate the whole system, not just one piece in a vacuum. In this instance, we lose a (very) little bit of performance by using a guid instead of an integer. Mainly on the insert of the record (which does not happen often - once per record). Lookups are just about as fast as integer lookups because the records are stored sequentially on disk and we only do individual record lookups by the ID. The difference, though, is in the lookups. We are going to have the guid of the logged-in user for every call. So, if we want to look up the user's details using my system, we just take that guid and look up the record (a seek operation, which is very fast). If we were to have used an auto-incrementing integer instead, we would need to look up the record by the guid to find the record still. That means doing a seek on a secondary index. Secondary indexes take additional resources on insert and you have to maintain additional records on disk. That means that the actual storage of the table resources will be more this way because of the additional covering index needed.
@nogo1880
@nogo1880 3 года назад
@@IAmTimCorey I'm sorry if my first comment was confusing. I completely agree with using the the guid as a primary key (in this case) instead of making this an int identity field for all the reasons you mentioned, on top of the fact that it has to be maintained. I'm a DBA, and at my last job, I had to clean up tons of data because we had 2 source systems that generated 2 completely different IDs; one generated guids, the other generated auto incrementing identity fields. So if our CRM needed to pull sales data from our POS system, it would throw an exception because the account in CRM had a null value in the field that stored the primary key (guid) of the account in the POS system. It didn't help that we weren't allowed to put a constraint to prevent the record from being created if that guid was missing. DBAs and developers are always at war because of stuff like this, lol. Anyway, my question was in regards to using a "uniqueidentifier" SQL data type, rather than using an "nvarchar" SQL data type to store the guid in the [Id] field in our User table. I've always worked with uniqueidentifiers as my data type for any guids, but I've never stored them as nvarchar because I was always taught that storing guids in varchar/nvarchar was bad. Compared to nvarchar/varchar, the performance is supposed to be better when doing lookups on fields that are uniqueidentifiers and uniqueidentifiers are supposed to take up less storage as well. So couldn't we just cast that nvarchar field to a uniqueidentifier data type?
@leppyr64
@leppyr64 Год назад
​@@nogo1880 I haven't watched the rest of the series to know the answer for certain. However, nvarchar(128) is what is being stored in the auth system. Tim has just used the same data type so that they match. Assuming that we would be querying the auth table for our users, we wouldn't need the overhead of casting from uniqeuidentifier to nvarchar(128) in that direction.
@S8Fii
@S8Fii 4 года назад
Just outta curiosity. Why did you go with the Database First instead of the Code First approach?
@IAmTimCorey
@IAmTimCorey 4 года назад
This isn't database first. I am not using Entity Framework in this project. I prefer Dapper. It is typically faster and it is much less dangerous to use, in my opinion.
@scwyldspirit
@scwyldspirit 4 года назад
Tim you might want to get with Teachable because it is freezing up every other second, that is why I am coming here to get the content.
@IAmTimCorey
@IAmTimCorey 4 года назад
Interesting. Not sure why that it. I'll look into it.
@tamaratiny
@tamaratiny 3 года назад
I'm almost sure decimal(18, 4) is "rounding error safe"? Haven't read up on the money type. Sounds kinda Microsofty?
@tomthelestaff-iamtimcorey7597
@tomthelestaff-iamtimcorey7597 3 года назад
I love that word!
@GMorgan84
@GMorgan84 2 года назад
Money is a byte cheaper than decimal on storage usage. Personally I'd use decimal (19,4) though
@litosebastian9557
@litosebastian9557 4 года назад
Tim, i would like to know how to create data base for apparel from where it does have a size?.
@IAmTimCorey
@IAmTimCorey 4 года назад
You would probably create a table that has sizes in it and then another that linked your items to what sizes they are carried in. So Items table (let's say it holds shirts), a Sizes table (Small, Medium, Large, etc. in rows), and ItemSizes table (that holds Shirt1 has a small, Shirt1 has a medium, etc. in rows).
@winning2049
@winning2049 5 лет назад
Id is changed and Id and primary key are discussed for four minutes at 15 - 19 minutes in.
@IAmTimCorey
@IAmTimCorey 5 лет назад
Yep
@Beast70
@Beast70 5 лет назад
I'm curious why you didn't extend the AspNetUsers table, and add the columns you required. Adding a second Users table is silly.
@IAmTimCorey
@IAmTimCorey 5 лет назад
That table is in a different database. I have a completely separate database for my authentication. If I were going to mix my authentication tables with the rest of my SQL code then I could do that but for a number of reasons, I prefer to keep the databases separate (better security, portability, etc.)
@neilljamieson9606
@neilljamieson9606 4 года назад
Great tutorial as always Tim. I don't seem to have the aspnet-TRMDataManager database though. Entity Framework is installed as far as I can tell. Any ideas?
@IAmTimCorey
@IAmTimCorey 4 года назад
EF auto-creates that the first time you use it. Did you try logging in?
@neilljamieson9606
@neilljamieson9606 4 года назад
@@IAmTimCorey I must have done something wrong somewhere. I'm revisiting the "Creating a WebAPI with Authentication - A TimCo Retail Manager Video" video and the database has been created there. Thank Tim.
@AW-rr3fl
@AW-rr3fl 3 года назад
I am looking at learning SQL and SSRS for a retail environment. Would I be best to download the Free Developer or Express version to do your course but also to be used in the future?
@IAmTimCorey
@IAmTimCorey 3 года назад
Completely up to you. Look at your time available to do the work/study, the deadlines you have and the amount of effort you plan to put in. If you can afford it, and are in a hurry, go for the paid version
@timothywestern6488
@timothywestern6488 5 лет назад
One thing that occurred to me is there could be a Quality to inventory when bought.
@IAmTimCorey
@IAmTimCorey 5 лет назад
That’s an interesting suggestion.
@PelFox
@PelFox 5 лет назад
Is there a reason why you don't add these fields to the ApplicationUser (or add as Claims) created from Identity instead of creating a new User table? It feels like you are having two User tables now, one from Identity and one on your own but your own just adds FirstName and LastName, which you could have added on IdentityUser.
@IAmTimCorey
@IAmTimCorey 5 лет назад
I don't add it in to the Claims or to the Identity because then it bloats the table and it is trying to do two things. I keep them separate and keep the lookups lean.
@grumpydeveloper69
@grumpydeveloper69 5 лет назад
In the product table why did you call the field "LastModified" I tend to use "ModifiedDate" and I have used "CreatedOn" and "ModifiedOn" since I lake that name when also using EF and classes. Ie. Product.ModifiedOn looks and sounds nice. What is your take on naming fields. In older systems I even used "CreatedDtm" where Dtm is short for Datetime. Do you work with specific guidelines for naming fields (and variables) ?
@IAmTimCorey
@IAmTimCorey 5 лет назад
It is purely a preference thing. I prefer Product.LastModified to indicate that this is the date/time when it was modified last (indicating there may be modifications before this). I prefer not to do the abbreviations wherever possible (they don't read well). My preference is on clear, readable names that indicate what the data represents. ModifiedDate, CreatedOn, and ModifiedOn all do this well. I would have no problem using those.
@michaeleichner9797
@michaeleichner9797 4 года назад
Enjoyed the video. I have two questions: 1. Since the authentication system provides an email address in the AspNetUsers table, wouldn't it make sense remove the email address from the User table? 2. I have found it a good practice to put the UserID of the person who created or updated a record on tables that include CreateDate and LastModfied date so that I know who added or changed the record. I was curious what you thought of this idea? Thanks
@IAmTimCorey
@IAmTimCorey 4 года назад
To answer your questions, we store the email in the User table because that is where we will access it from. Essentially, we will never directly access the AspNetUsers table (we won't do queries against it). Since we will want to see the email address of the user commonly, it makes it easier to include it in both places. This does create a duplication of email but that isn't a problem. We know the source of truth (the authentication system) and we don't change the email frequently. As for including the person who last made a change to the record, that is possible and sometimes beneficial but it is of limited use (really, so is the LastModified but that is a bit different - we get to know if a record was just changed or not, which can be helpful). If you really want to know who did what, it would probably be good to create a history table that stores the record after each change so that you can see who made a change, what it was, and what the history of changes have been. You can create a trigger to do this for you and on REALLY important tables, it is valuable. Just remember that you are relying on the sender giving you a valid UserID and not lying about who it was (I could provide your GUID for the change and the system would accept it).
@michaeleichner9797
@michaeleichner9797 4 года назад
@@IAmTimCorey That makes sense. I had forgotten that we were accessing the UserID via RequestContext.Principal.Identity.GetUserId() instead of through a database query.
@lkm75
@lkm75 5 лет назад
I may be wrong, but; if you're going to use the bearer token for the id, won't that reset every 2 weeks?
@IAmTimCorey
@IAmTimCorey 5 лет назад
The bearer token isn't the ID. The GUID of the user is (which never gets reset).
@Noceo
@Noceo 5 лет назад
Why are you using nvarchar for the user id? Doesn't most databases these days support UUID/GUID data types?
@IAmTimCorey
@IAmTimCorey 5 лет назад
I mirrored what Microsoft used for their table.
@omarsebakhi
@omarsebakhi 2 года назад
In real world scenario for a company has a long history of sales, do we need to make the sale ID column type "bigint" or "int" (2,147,483,647) will be more than enough?
@IAmTimCorey
@IAmTimCorey 2 года назад
Int is more than enough. If you have to upgrade to bigint, you will have to do a LOT more updates to make your app performant before then. 2 billion sales would be beyond even Amazon.
@omarsebakhi
@omarsebakhi 2 года назад
@@IAmTimCorey So amazing! Thank you so much.
@lokigaming459
@lokigaming459 5 лет назад
So semi odd question here. As i have little experience with sql. I have other things that could be useful here. The id you changed from `int` is there any way to set it to a `ulong`? The only application I have that needs a ulong is my discord bot which the api returns the user id in a ulong. Is there any way to overload or convert to said data format for this?
@IAmTimCorey
@IAmTimCorey 5 лет назад
ULong is a mess. In SQL, we have BigInt, but it is signed (has the plus and minus capability). That is the equivalent of Long/Int64. The problem is that ULong is an unsigned long, meaning it starts at zero (no negative) and can be twice as large. The closest thing SQL has to store that is Numeric(20,0). The problem with that is that it isn't as efficient as an integer type and it is actually larger than you need. That's only a problem if you are creating data on the SQL side, not the C# side. If you create data on the SQL side, you need to limit the column to be between 0 and 18,446,744,073,709,551,615.
@hamidrezaashkiyan
@hamidrezaashkiyan 4 года назад
Hi, I just ran into problem. some weeks ago i was struggling at work with sql server instance and i created and deleted several times. now i think i deleted the one that entity framework was on. now i have none of the two database here and i cant publish even. Any suggestion? it is good to mention now i have 4 instance running on my PC from 14 to 19.
@IAmTimCorey
@IAmTimCorey 4 года назад
It should be that you just need to run Update-database from the package manager console but if that gives you an error, check out this post: stackoverflow.com/questions/20304058/how-to-re-create-database-for-entity-framework
@MosquitoMurderer
@MosquitoMurderer 5 лет назад
Would it be possible to create an update trigger on the Product table that re-assigns the LastModified column?
@IAmTimCorey
@IAmTimCorey 5 лет назад
We could, although I avoid triggers whenever possible because they can slow things down and cause unexpected results. In our case, I'll probably just do it manually.
@RiderInHell
@RiderInHell 4 года назад
@@IAmTimCorey true. And because we tend to forget it exists down the road when we haven't really messed with the app for so long. I work with sql server as my primary tool and I once had a trigger for a set of opperations, and that created a whole lot of problems and was harder to debug. It's a lot easier a simples stored procedure.
@butterysmooth5808
@butterysmooth5808 2 года назад
What about itemization in SaleDetail? Right now it seems like there can only be one item
@IAmTimCorey
@IAmTimCorey 2 года назад
One item per row. We will have multiple rows per Sale.
@butterysmooth5808
@butterysmooth5808 2 года назад
@@IAmTimCorey thanks!
@Lisaol279
@Lisaol279 3 года назад
Hello Tim, It's great learning from you. I have a problem hope you can address an easy solution. I am working on 2 computers. So git lessons helped me very much. But with one problem. I started the course on my home computer and when I clone the repo from git to my work computer, I no longer have the Asp.net generated databases (aspnet-TRMDataManager-20201111085247) under my (localdb)\MSSQLLocalDB. Is there a way to regenerate and keep on sync within this 2 computers?
@Lisaol279
@Lisaol279 3 года назад
Okay, I don't know if this is the right way to do but I have found a workaround: 1. I added another ASP.Net WebAPI Project to the solution and called it TRMDataManager2 2. Done the updates, added Swagger. 3. On the newly created TRMDataManager2 project, I updated the ValuesController and SwaggerConfig classes to match the ones on the original TRMDataManager. And run in debug mode. Registered a random user. 4. Opened the Web.Config on the original TRMDataManager, and copied the server name at the connectionString line (for me it was aspnet-TRMDataManager-20201111085247.mdf) 5. Opened the {Project Directory}\TRMDataManager2\App_Data folder and copied those 2 files and pasted to {Project Directory}\TRMDataManager\App_Data folder and renamed it to aspnet-TRMDataManager-20201111085247 (it would be different for you) 6. Voila!
@matan7618
@matan7618 4 года назад
Hi Tim, i dont seem to have anything under the folder in publish locations... its just an empty folder. Where did i go wrong and how do i go about fixing it?
@IAmTimCorey
@IAmTimCorey 4 года назад
Did you save your publish profile to that folder?
@matan7618
@matan7618 4 года назад
@@IAmTimCorey anyway to direct me to when you created the publish profile? ive followed the series up until now and dont recall that... anyway thank you so much for this series, im learning a lot!
@randompl
@randompl 4 года назад
@@matan7618 I believe it was at the end of the last video.
@LarryB15
@LarryB15 3 года назад
Hi Tim I am having a problem with Visual Studio 2019 at the moment. I have been following your tutorials and have passed this point. The issue I am having is that every time I load visual studio the database project is empty. The folders exist but there are no tables loaded. I can add the tables using R-Click Add Existing and they get loaded but saving and reloading, bang they are missing again. I have searched internet and cannot find any instances of others reporting this problem. For info, I have a *.sqlproj file which seems to be the definition file for the project and it contains the folder definitions but never creates any associations with the *.sql files used for the tables. Any thoughts.
@benezard1454
@benezard1454 3 года назад
Potentially dumb question, but are you saving your *Solution/Project* file after re-adding the files (i.e. "Save All")?
@LarryB15
@LarryB15 3 года назад
@@benezard1454 Not to silly, but yes I do a save all. When I add tables, etc. VS recognises that the sqlproj has been modified but there are no changes detected. The only way I have got it to behave is to publish the database, but before actually hitting the publish the button, to save the profile. Otherwise the sqlproj never gets updated.
@IAmTimCorey
@IAmTimCorey 3 года назад
Not sure why that is, sorry.
@georgevlassis8319
@georgevlassis8319 3 года назад
Click on the Show All Files button of your solution and then find your tables, right click on them and select Include In Project.
@bujin1977
@bujin1977 5 лет назад
When you said "England" (in reference to VAT), you meant the "UK", right? ;)
@IAmTimCorey
@IAmTimCorey 5 лет назад
lol, yeah, I do.
@jasonmiller1347
@jasonmiller1347 3 года назад
My visual studio keeps freezing! Why!!!!!!!!!!! LOL
@tomthelestaff-iamtimcorey7597
@tomthelestaff-iamtimcorey7597 3 года назад
Man, your A/C must be working great to cause that.
Далее
WPF Login Form Creation - A TimCo Retail Manager Video
1:04:38
C’est qui le plus fort 😂
00:18
Просмотров 7 млн
I Built a WATERPARK In My House!
26:28
Просмотров 15 млн
Liskov: The Liskov Substitution Principle
4:23
Просмотров 21 тыс.
Getting User Data - A TimCo Retail Manager Video
1:13:38
SQL Database Project - A TimCo Retail Manager Video
9:44
Learn Docker in 1 Hour | Full Docker Course for Beginners
1:27:53