Creating a newsfeed in cshtml - mysql

I have the following in database
status table - status_id, status_body, status_date
student table - student_id, student_username, student_firstname, student_lastname
follow table - followId, follow_followerid, follow_followingid`
Now, I want to show the status of the users which a user(say user A) currently follows along with his(user A) own status updates.
How can I do it in cshtml? SQL query for this is necessary.
Any help?

You can't put a sql query in a cshtml file. There is a chain of events that have to happen. You serve the cshtml with only the results of your database query in it. You also need some server-side code to serve the cshtml, for example c# using MVC. And you need a way to access your database, for example an object-relational mapper such as Entity Framework. You have a lot of steps, if you want to make this work.

Related

MS-Access Looking up and updating records based on values in form

I've learned a lot in Access over the last month or so but am now have trouble resolving an issue that I don't know how to approach. I'm sure there's a simple solution but I need help being pointed in the right direction. Here's the background:
This problem deals with three forms:
frmProject - Lists project details it has a
subfrmMilestones - Milestone details
frmProjMsgBox - Collects info to pass to Project table
I have it set that when I click OK on ProjectMsgBox it passes the information to the Project form and starts the creation of a new record.
tblProject stores all details related to projects
tblMilestones stores all details on milestones, contains key for tblProject
tblMilestones_Inf stores a list of common milestones based on project type, has key for tblProjectType, which is on tblProject
My Problem -
When I click okay on the ProjectMsgBox form, I would like it to also look up milestones from tblMilestones_Inf and insert into tblMilestones. I also need to assign the Project_ID that on the form to the creates. What is the best way to go about this?
I've tried a few things in VBA but haven't had success. I can create a query that pulls the milestones in but don't know how to update the milestone table with the relationship to the project table.
I can provide more details but wasn't sure what is helpful and what is not. I'm more or less looking for a resource (or keywords to search) so I can figure this out on my own
Thank you!
UPDATE:
tblProject has 1 to many relationship with tblMilestones
tblProjectType has 1 to many relationship with tblMilestones_Inf
Once I hit okay on the frmProjMsgBox it fills out text boxes that have controls on frmProject to create the parent record (i think that's the term) in tblProject. This works well. I would like access to go out to the tblMilestones_Inf and match the project type (child record?). It would then add 4-5 records based on matching ProjectType on the Milestone_Inf table. I don't want code, but maybe actions/keywords to lookup so I can figure this out on my own. I'll post some of my code later that tries to achieve this.
You might want to look into Query Defs, you can use those to change the SQL statement of your queries from VBA. So if you have something like:
MyQryDef.SQL = "SELECT * FROM MyTable WHERE MyIndex = " & MyControl.Value & ";"
and your control value is set to 5, you then use the execute statement and your Query SQL will then read:
SELECT * FROM MyTable WHERE MyIndex = 5;
There's a few more lines you will have to look up to make this work, but this is a very basic example.

Write a MySQL join query for retrieve project information

I need to write a MySQL join query for retrieve project information as this image below.
project manager able to get list of each developer's workingHours, Overtime, Descriptions, Contributions for specific project his assigned. This is my database table structure.
Can anyone tell me how to to this? I need output like this image using this table structure.

How to post the data into multiple tables using Talend RestFul Services

I have 3 tables called PATIENT, PHONE and PATIENT_PHONE.
The PATIENT table contains the columns: id, firstname, lastname, email and dob.
The PHONE table contains the columns: id, type and number.
The PATIENT_PHONE table contains the columns: patient_id, phone_id.
The PATIENT and PHONE tables are mapped by the PATIENT_PHONE table. So I have to join these 3 tables to post firstname, lastname, email and number fields to the database.
I tried like this:
Schema for first_xmlmap
[
Schema mapping for Patient and Patient_phone
[
I'm assuming you want to write the same data to multiple database tables within the same database instance for each request against the web service.
How about using the tHashOutput and tHashInput components?
If you can't see the tHash* components in your component Pallete, go to:
File > Edit project properties > Designer > Pallete settings...
Highlight the filtered components, click the arrow to move them out of the filter and click OK.
The tHash components allow you to push some data to memory in order to read it back later. Be aware that this data is written to volatile memory (RAM) and will be lost once the JVM exits.
Ensure that "append" in the tHashOutput component is unchecked and that the tHashInput components are set not to clear their cache after reading.
You can see some simple error handling written into my example which guarantees that a client will always get some sort of response from the service, even when something goes wrong when processing the request.
Also note that writing to the database tables is an all-or-nothing transaction - that is, the service will only write data to all the specified tables when there are no errors whilst processing the request.
Hopefully this gives you enough of an idea about how to extend such functionality to your own implementation.

Separate get request and database hit for each post to get like status

So I am trying to make a social network on Django. Like any other social network users get the option to like a post, and each of these likes are stored in a model that is different from the model used for posts that show up in the news feed. Now I have tried two choices to get the like status on the go.
1.Least database hits:
Make one sql query and get the like entry for every post id if they exist.Now I use a custom django template tag to see if the like entry for the current post exist in the Queryset by searching an array that contains like statuses of all posts.
This way I use the database to get all values and search for a particular value from the list using python.
2.Separate Database Query for each query:
Here i use the same custom template tag but rather that searching through a Queryset I use the mysql database for most of the heavy lifting.
I use model.objects.get() for each entry.
Which is a more efficient algorithm. Also I was planning on getting another database server, can this change the choice if network latency is only around 0.1 ms.
Is there anyway that I can get these like statuses on the go as boolean values along with all the posts in a single db query.
An example query for the first method can be like
Let post_list be the post QuerySet
models.likes.objects.filter(user=current_user,post__in = post_list)
This is not a direct answer to your question, but I hope it is useful nonetheless.
and each of these likes are stored in a model that is different from the model used for news feed
I think you have a design issue here. It is better if you create a model that describes a post, and then add a field users_that_liked_it as a many-to-many relationship to your user model. Then, you can do something like post.users_that_liked_it and get a query set of all users that liked your page.
In my eyes you should also avoid putting logic in templates as much as possible. They are simply not made for it. Logic belongs into the model class, or, if it is dependent on the page visited, in the view. (As a rule of thumb).
Lastly, if performance is your main worry, you probably shouldn't be using Django anyway. It is just not that fast. What Django gives you is the ability to write clean, concise code. This is much more important for a new project than performance. Ask yourself: How many (personal) projects fail because their performance is bad? And how many fail because the creator gets caught in messy code?
Here is my advice: Favor clarity over performance. Especially in a young project.

How can i select a table dynamically from mysql

Is there any option to select a table dynamically from mysql..
For example,
If i have 3 tables like
t_tableconfig
t_2013
t_2014
t_tableconfig contains data like,
tableid tablename
1 t_2013
2 t_2014
t_2013 contains
id name
1 David
t_2014 contains
id name
1 joe
If I will pass a table name as a parameter.. Can I view the records from specified table? Please advice me
It depends on what your programming language or ORM(Object-relational Mapping).
Could you please tell me the environment you're using to query sql statement?
// I've added below
As you said you're using hibernate, I hope the link below can help you.
I'm not familiar with hibernate.
Hibernate: Data Object with a dynamic table name by Annotations
Use redbeans ORM . it's awesome ORM. you can change your table dynamically. You can perform crud operation which you usually use in several tools.
Advantage
You can create schema more faster.
Magically perform [CRUD](http://en.wikipedia.org/wiki/Create,_read,_update_and_delete) operation
That has only 1 php file. It has no criteria to installation.
Easy to learn