In my Qt C++ project I am using SQL database for table view. Everything is working fine, but now I need to create something bigger. I need to show name, school subject, and final assessment for this subject.
The problem is in that, that I've got about 45 subjects, and I need to repeat them twice cause there are 2 periods for each subject.
Do I need to create about 90 tables in SQL for each subject and each final assessment or is there some smarter and easier way?
The answer for your question is here: http://en.wikipedia.org/wiki/Entity%E2%80%93relationship_model
Read carefully and you are going to find out that you don't need to create one table for each subject.
Related
Long in short that I realized that Hue(Hive/Impala) is not like Microsoft SQL server that you run the following to look for the Table of Interest.
Select * from information_schema.columns where column_name like '%The_Table_of_Interest%'
1st scenario: Imagine that I know what my Database is and I target my attention to the right table by searching through the table and find the column of interest.
2nd scenario: I don't know even what database I need to look for the right table and as a result the column of interest.
I realized that in Hue, there is no option to look for a column. All I can see is Table Search!
Having said that for the two above scenarios there should be a way to find the column of interest.
Scenario 2 is of course difficult to approach, however the 1st one looks a bit easier.
Now, I did my research and came of with running some code in Shell Command Line might be helpful to find the target column. However, that require some further investigation in the layer that I am not quite familiar.(Speaking of Metaset, etc.)
Therefore, here is my question.
Assume we are discussing the 1st scenario, now how can I search and find the columns while you have no knowledge about the tables at all. I can not take guesses and try every tables to find the right one to find the column that I am looking for. What would you suggest, and what is your strategy to approach? Thank you in advance. :)
Good Day H2019
Here are some commands that should help you out to explore the different tables that you have access to:
Find a table or a database
show tables like 'ben*'
Look at the table definition
show create table <table>;
Get table information
describe my_table_01;
Get even more information
describe extended table_name
Get more information in a pretty format
describe formatted table_name;
If you have access to Apache Ranger I also find it useful to look into tables permissions. (And see who's using what)
Apache Atlas if you use it it helpful to see where data comes from.(It keeps data lineage information and may help to give you an understanding of how things work)
Don't forget you can look at HDFS to find databases, tables if they're in /hive/warehouse/. This can also be helpful to understand when things are created.
I'm very new to databases and to SQL as well. I am currently running SQL queries on MS Access until our SQL Server gets set up.
I have 2 datasets, 1 which has work information and location of the work, the other has length and width of roadways which I would like to reference. I am trying to get these 2 to talk.
My work dataset has address in 3 columns "On/From/To" format. E.g. on main street, from park place to broadway. I am trying to reference the only similar column in the other dataset, which would correspond with my "on" street.
These 2 datasets have no common keys and the primary key is autonumbered and indexed. These are both large datasets.
How do I proceed to get these 2 datasets to speak?
Sorry for the delay everyone, had some things come up the past few weeks and was unavailable.
Thanks for the replys and for being gentle with such a noobie as myself.
What I was looking for was an Intersect, which Access VBA does not have, and found a way to do so.
I did an inner join on my address field with the other tables address field and was able to accomplish my very simple query.
Appreciate all the help
Here is the problem: I am currently working with a Microsoft Access database that the previous employee created by just adding all the data into one table (yes, all the data into one table). There are about 186 columns in that one table.
I am now responsible for dividing each category of data into its own table. Everything is going fine although progress is too slow. Is there perhaps an SQL command that will somehow divide each category of data into its proper table? As of now I am manually looking at the main table and carefully transferring groups of data into each respective table along with its proper IDs making sure data is not corrupted. Here is the layout I have so far:
Note: I am probably one of the very few at my campus with database experience.
I would approach this as a classic normalisation process. Your single hugely wide table should contain all of the entities within your domain so as long as you understand the domain you should be able to normalise the structure until you're happy with it.
To create your foreign key lookups run distinct queries against the columns your going to remove and then add the key values back in.
It sounds like you know what you're doing already ? Are you just looking for reassurance that you're on the right track ? (Which it looks like you are).
Good luck though, and enjoy it - it sounds like a good little piece of work.
I'm given a task from a prospective employer which involves SQL tables. One requirement that they mentioned is that they want the name retrieved from a table called "Employees" to come in the form at of either "<LastName>, <FirstName>" OR "<FirstName> <MiddleName> <LastName> <Suffix>".
This appears confusing to me because this kind of sounds like they're asking me to make a function or something. I could probably do this in a programming language and have the information retrieved that way, but to do this in the SQL table exclusively is weird to me. Since I'm rather new to SQL and my familiarity with SQL doesn't exceed simple tasks such as creating databases, tables, fields, inserting data into fields, updating fields in records, deleting records in tables which meet a specific condition, and selecting fields from tables.
I hope that this isn't considered cheating since I mentioned that this was for a prospective employer, but if I was still in school then I could just outright ask a professor where I can find a clue for this or he would've outright told me in class. But, for a prospective job, I'm not sure who I would ask about any confusion. Thanks in advance for anyone's help.
A SQL query has a fixed column output: you can't change it. To achieve this. you could have a concatenate with a CASE statement to make it one varchar column, but then you need something (parameter) to switch the CASE.
So, this is presentation, not querying SQL.
I'd return all 4 columns mentioned and decide how I want them in the client.
Unless you have just been asked for 2 different queries on the same SQL table
You haven't specified the RDBMS, but in SQL Server you could accomplish this using Computed Columns.
Typically, you would use a View over the table..
Im creating a little database that has employee, emp_shift, shift, tables
now im suppose to be able to calculate at the end of the month which employee
has done the most number of shifts.
Ive created the SQL creation, insert statements for the tables, and a little diagram to explain what im trying to acomplish, im a beginner and this is a homework ive been trying to do for the last 4 days.
Diagram: http://latinunit.net/emp_shift.jpg
SQL: http://latinunit.net/emp_shift.txt
can you please guys check it, deadline is 2 days and this is just a part of the whole database
That is a reasonable start. Will you have more tables? If not, it will be hard to identify how to pay people -- for example, it seems that you might want a "pay-period" table. Then you could find the start and end dates and be able to count the shifts within that period.
But if all you need to do is exactly what you said, that is a fair start.
(I am assuming you have other columns in mind, such as employee name, but that would be obvious).
You could start by telling us whoch RDBMS you are using, as some of the finer details might be different between RDMSs.
You need to create a link between tables (Called JOINS, Read this) and then perform a count of the requested data.
After you have read some of these, show us what you have done, and we can help you where you are having trouble.
also, it would be better practive to use a single numeric as the primary key instead of 'A', 'B', 'C' etc.