Reputation: 41158
I have to have a table that saves information about a Course in my university.
I need to save the name of the course, the month it's going to be open, and also the time.
What built in Microsoft SQL server datatypes should I use? I'll be using Linq2SQL as my ORM.
Upvotes: 0
Views: 61
Reputation: 38365
If you only need the month(not date or year) and the time, then you could use an int for the month, and a Time for the time. You could also use the DateTime instead and just work out a convention that ignores the date and year aspect of the date.
I would recommend nvarchar or varchar for the name. Use nvarchar if you anticipate there ever being a point in the future that you will need to support foreign languages that might contain unicode characters that are not supported by varchar. I would look at the longest name I anticipate needing, double it's length and then round up to the nearest 50. So if "Introduction to Partial Differential Equations" at 48 then I would make it varchar(100).
The purpose of making it so much larger is to allow for future values. If I only made it varchar(48) to accomdate the current largest value, I might later have a coursename that's larger than that, and thus would have to modify the database structure and the applications to accomdate this larger size! By making it varchar(100) we have plenty of room for larger course names that might occur in the future.
Upvotes: 0
Reputation: 135021
varchar
if the names can be ascii only, nvarchar
for unicode names, date
for month and time
for time. The ones that look like this
are the SQL Server types
Upvotes: 1
Reputation: 6281
int for ID
string for Course_Name
since you're using SQLS2K8 you can split DATE and TIME fields so..
Date for Opening_Month
Time for Opening_Hour
Upvotes: 1